зеркало из https://github.com/mozilla/gecko-dev.git
Bug 960426 - Part 2: Modifications for IDL change. r=blassey
This commit is contained in:
Родитель
02bd1b138b
Коммит
697caff053
|
@ -812,6 +812,7 @@ GK_ATOM(onstkcommand, "onstkcommand")
|
|||
GK_ATOM(onstksessionend, "onstksessionend")
|
||||
GK_ATOM(onsubmit, "onsubmit")
|
||||
GK_ATOM(onsuccess, "onsuccess")
|
||||
GK_ATOM(ontypechange, "ontypechange")
|
||||
GK_ATOM(ontext, "ontext")
|
||||
GK_ATOM(ontouchstart, "ontouchstart")
|
||||
GK_ATOM(ontouchend, "ontouchend")
|
||||
|
|
|
@ -1587,18 +1587,21 @@ Navigator::GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads,
|
|||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozConnection(nsISupports** aConnection)
|
||||
Navigator::GetProperties(nsINetworkProperties** aProperties)
|
||||
{
|
||||
nsCOMPtr<nsINetworkProperties> properties = GetMozConnection();
|
||||
properties.forget(aConnection);
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aProperties = GetConnection(rv));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
network::Connection*
|
||||
Navigator::GetMozConnection()
|
||||
Navigator::GetConnection(ErrorResult& aRv)
|
||||
{
|
||||
if (!mConnection) {
|
||||
NS_ENSURE_TRUE(mWindow, nullptr);
|
||||
if (!mWindow) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
|
||||
|
||||
mConnection = new network::Connection();
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
class nsPluginArray;
|
||||
class nsMimeTypeArray;
|
||||
class nsPIDOMWindow;
|
||||
class nsIDOMMozConnection;
|
||||
class nsIDOMMozMobileMessageManager;
|
||||
class nsIDOMNavigatorSystemMessages;
|
||||
class nsDOMCameraManager;
|
||||
|
@ -199,7 +198,7 @@ public:
|
|||
ErrorResult& aRv);
|
||||
nsIDOMMozMobileMessageManager* GetMozMobileMessage();
|
||||
Telephony* GetMozTelephony(ErrorResult& aRv);
|
||||
network::Connection* GetMozConnection();
|
||||
network::Connection* GetConnection(ErrorResult& aRv);
|
||||
nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
|
||||
void MozSetMessageHandler(const nsAString& aType,
|
||||
systemMessageCallback* aCallback,
|
||||
|
|
|
@ -777,10 +777,6 @@ DOMInterfaces = {
|
|||
'nativeType': 'mozilla::dom::CellBroadcast',
|
||||
},
|
||||
|
||||
'MozConnection': {
|
||||
'nativeType': 'mozilla::dom::network::Connection',
|
||||
},
|
||||
|
||||
'MozIcc': {
|
||||
'nativeType': 'mozilla::dom::Icc',
|
||||
},
|
||||
|
@ -826,6 +822,10 @@ DOMInterfaces = {
|
|||
'previousSibling', 'nextSibling' ]
|
||||
},
|
||||
|
||||
'NetworkInformation': {
|
||||
'nativeType': 'mozilla::dom::network::Connection',
|
||||
},
|
||||
|
||||
'Node': {
|
||||
'nativeType': 'nsINode',
|
||||
'concrete': False,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
var ev = document.createEvent("Events");
|
||||
EventTarget.prototype.dispatchEvent.call(navigator.mozConnection, ev);
|
||||
EventTarget.prototype.dispatchEvent.call(navigator.connection, ev);
|
||||
</script>
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[uuid(7f021f5d-f704-4a29-b166-829595169aaf)]
|
||||
interface nsINetworkProperties;
|
||||
|
||||
[uuid(7956523b-631e-4f80-94a5-3883bcfd6bf3)]
|
||||
interface nsIMozNavigatorNetwork : nsISupports
|
||||
{
|
||||
// This is a MozConnection
|
||||
readonly attribute nsISupports mozConnection;
|
||||
readonly attribute nsINetworkProperties properties;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <limits>
|
||||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/dom/network/Connection.h"
|
||||
#include "mozilla/dom/MozConnectionBinding.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "Constants.h"
|
||||
|
@ -15,15 +14,12 @@
|
|||
* We have to use macros here because our leak analysis tool things we are
|
||||
* leaking strings when we have |static const nsString|. Sad :(
|
||||
*/
|
||||
#define CHANGE_EVENT_NAME NS_LITERAL_STRING("change")
|
||||
#define CHANGE_EVENT_NAME NS_LITERAL_STRING("typechange")
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
const char* Connection::sMeteredPrefName = "dom.network.metered";
|
||||
const bool Connection::sMeteredDefaultValue = false;
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE_INHERITED1(Connection, nsDOMEventTargetHelper,
|
||||
nsINetworkProperties)
|
||||
|
||||
|
@ -33,8 +29,7 @@ NS_IMPL_ADDREF_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
|
|||
NS_IMPL_RELEASE_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
|
||||
|
||||
Connection::Connection()
|
||||
: mCanBeMetered(kDefaultCanBeMetered)
|
||||
, mBandwidth(kDefaultBandwidth)
|
||||
: mType(static_cast<ConnectionType>(kDefaultType))
|
||||
, mIsWifi(kDefaultIsWifi)
|
||||
, mDHCPGateway(kDefaultDHCPGateway)
|
||||
{
|
||||
|
@ -60,26 +55,6 @@ Connection::Shutdown()
|
|||
hal::UnregisterNetworkObserver(this);
|
||||
}
|
||||
|
||||
double
|
||||
Connection::Bandwidth() const
|
||||
{
|
||||
if (mBandwidth == kDefaultBandwidth) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
return mBandwidth;
|
||||
}
|
||||
|
||||
bool
|
||||
Connection::Metered() const
|
||||
{
|
||||
if (!mCanBeMetered) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Preferences::GetBool(sMeteredPrefName, sMeteredDefaultValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Connection::GetIsWifi(bool *aIsWifi)
|
||||
{
|
||||
|
@ -97,8 +72,7 @@ Connection::GetDhcpGateway(uint32_t *aGW)
|
|||
void
|
||||
Connection::UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo)
|
||||
{
|
||||
mBandwidth = aNetworkInfo.bandwidth();
|
||||
mCanBeMetered = aNetworkInfo.canBeMetered();
|
||||
mType = static_cast<ConnectionType>(aNetworkInfo.type());
|
||||
mIsWifi = aNetworkInfo.isWifi();
|
||||
mDHCPGateway = aNetworkInfo.dhcpGateway();
|
||||
}
|
||||
|
@ -106,13 +80,11 @@ Connection::UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo)
|
|||
void
|
||||
Connection::Notify(const hal::NetworkInformation& aNetworkInfo)
|
||||
{
|
||||
double previousBandwidth = mBandwidth;
|
||||
bool previousCanBeMetered = mCanBeMetered;
|
||||
ConnectionType previousType = mType;
|
||||
|
||||
UpdateFromNetworkInfo(aNetworkInfo);
|
||||
|
||||
if (previousBandwidth == mBandwidth &&
|
||||
previousCanBeMetered == mCanBeMetered) {
|
||||
if (previousType == mType) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,7 +94,7 @@ Connection::Notify(const hal::NetworkInformation& aNetworkInfo)
|
|||
JSObject*
|
||||
Connection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return MozConnectionBinding::Wrap(aCx, aScope, this);
|
||||
return NetworkInformationBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace network
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Observer.h"
|
||||
#include "Types.h"
|
||||
#include "mozilla/dom/NetworkInformationBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -44,11 +45,9 @@ public:
|
|||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
double Bandwidth() const;
|
||||
ConnectionType Type() const { return mType; }
|
||||
|
||||
bool Metered() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(change)
|
||||
IMPL_EVENT_HANDLER(typechange)
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -58,14 +57,9 @@ private:
|
|||
void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo);
|
||||
|
||||
/**
|
||||
* If the connection is of a type that can be metered.
|
||||
* The type of current connection.
|
||||
*/
|
||||
bool mCanBeMetered;
|
||||
|
||||
/**
|
||||
* The connection bandwidth.
|
||||
*/
|
||||
double mBandwidth;
|
||||
ConnectionType mType;
|
||||
|
||||
/**
|
||||
* If the connection is WIFI
|
||||
|
@ -76,9 +70,6 @@ private:
|
|||
* DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
|
||||
*/
|
||||
uint32_t mDHCPGateway;
|
||||
|
||||
static const char* sMeteredPrefName;
|
||||
static const bool sMeteredDefaultValue;
|
||||
};
|
||||
|
||||
} // namespace network
|
||||
|
|
|
@ -13,8 +13,7 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
static const double kDefaultBandwidth = -1.0;
|
||||
static const bool kDefaultCanBeMetered = false;
|
||||
static const uint32_t kDefaultType = 5; // ConnectionType::None
|
||||
static const bool kDefaultIsWifi = false;
|
||||
static const uint32_t kDefaultDHCPGateway = 0;
|
||||
|
||||
|
|
|
@ -12,37 +12,25 @@
|
|||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Network API **/
|
||||
function checkInterface(aInterface) {
|
||||
ok(!(aInterface in window), aInterface + " should not exist");
|
||||
ok(!(("Moz" + aInterface) in window), aInterface + " should not exist");
|
||||
}
|
||||
|
||||
/** Test for Network Information API **/
|
||||
function test() {
|
||||
ok('mozConnection' in navigator, "navigator.mozConnection should exist");
|
||||
ok('connection' in navigator, "navigator.connection should exist");
|
||||
|
||||
ok(navigator.mozConnection, "navigator.mozConnection returns an object");
|
||||
ok(navigator.connection, "navigator.connection returns an object");
|
||||
|
||||
ok(navigator.mozConnection instanceof EventTarget,
|
||||
"navigator.mozConnection is a EventTarget object");
|
||||
ok(navigator.connection instanceof EventTarget,
|
||||
"navigator.connection is a EventTarget object");
|
||||
|
||||
checkInterface("Connection");
|
||||
|
||||
ok('bandwidth' in navigator.mozConnection,
|
||||
"bandwidth should be a Connection attribute");
|
||||
is(navigator.mozConnection.bandwidth, Infinity,
|
||||
"By default connection.bandwidth is equals to Infinity");
|
||||
|
||||
ok('metered' in navigator.mozConnection,
|
||||
"metered should be a Connection attribute");
|
||||
is(navigator.mozConnection.metered, false,
|
||||
"By default the connection is not metered");
|
||||
ok('type' in navigator.connection,
|
||||
"type should be a Connection attribute");
|
||||
is(navigator.connection.type, "none",
|
||||
"By default connection.type equals to none");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["dom.network.enabled", true]]}, test);
|
||||
SpecialPowers.pushPrefEnv({'set': [["dom.netinfo.enabled", true]]}, test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -239,7 +239,6 @@ WEBIDL_FILES = [
|
|||
'MouseEvent.webidl',
|
||||
'MouseScrollEvent.webidl',
|
||||
'MozActivity.webidl',
|
||||
'MozConnection.webidl',
|
||||
'MozMmsMessage.webidl',
|
||||
'MozMobileConnection.webidl',
|
||||
'MozNamedAttrMap.webidl',
|
||||
|
@ -251,6 +250,7 @@ WEBIDL_FILES = [
|
|||
'MutationObserver.webidl',
|
||||
'NativeOSFileInternals.webidl',
|
||||
'NetDashboard.webidl',
|
||||
'NetworkInformation.webidl',
|
||||
'NetworkOptions.webidl',
|
||||
'Node.webidl',
|
||||
'NodeFilter.webidl',
|
||||
|
|
|
@ -22,8 +22,7 @@ DisableNetworkNotifications()
|
|||
void
|
||||
GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||
{
|
||||
aNetworkInfo->bandwidth() = dom::network::kDefaultBandwidth;
|
||||
aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
|
||||
aNetworkInfo->type() = dom::network::kDefaultType;
|
||||
aNetworkInfo->isWifi() = dom::network::kDefaultIsWifi;
|
||||
aNetworkInfo->dhcpGateway() = dom::network::kDefaultDHCPGateway;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ struct SensorData {
|
|||
};
|
||||
|
||||
struct NetworkInformation {
|
||||
double bandwidth;
|
||||
bool canBeMetered;
|
||||
uint32_t type;
|
||||
bool isWifi;
|
||||
uint32_t dhcpGateway;
|
||||
};
|
||||
|
|
|
@ -1928,10 +1928,8 @@ nsHttpHandler::TickleWifi(nsIInterfaceRequestor *cb)
|
|||
if (!networkNavigator)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsISupports> mozConnection;
|
||||
networkNavigator->GetMozConnection(getter_AddRefs(mozConnection));
|
||||
nsCOMPtr<nsINetworkProperties> networkProperties =
|
||||
do_QueryInterface(mozConnection);
|
||||
nsCOMPtr<nsINetworkProperties> networkProperties;
|
||||
networkNavigator->GetProperties(getter_AddRefs(networkProperties));
|
||||
if (!networkProperties)
|
||||
return;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче