mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952084 - Porting nsIDOMMozConnection to WebIDL, r=ehsan, r=bz
This commit is contained in:
parent
2078201c40
commit
826b2527bb
@ -1265,13 +1265,14 @@ Navigator::GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads,
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozConnection(nsIDOMMozConnection** aConnection)
|
||||
Navigator::GetMozConnection(nsISupports** aConnection)
|
||||
{
|
||||
NS_IF_ADDREF(*aConnection = GetMozConnection());
|
||||
nsCOMPtr<nsINetworkProperties> properties = GetMozConnection();
|
||||
properties.forget(aConnection);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMMozConnection*
|
||||
network::Connection*
|
||||
Navigator::GetMozConnection()
|
||||
{
|
||||
if (!mConnection) {
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
ErrorResult& aRv);
|
||||
nsIDOMMozMobileMessageManager* GetMozMobileMessage();
|
||||
Telephony* GetMozTelephony(ErrorResult& aRv);
|
||||
nsIDOMMozConnection* GetMozConnection();
|
||||
network::Connection* GetMozConnection();
|
||||
nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
|
||||
void MozSetMessageHandler(const nsAString& aType,
|
||||
systemMessageCallback* aCallback,
|
||||
|
@ -154,7 +154,6 @@
|
||||
#include "nsIDOMSmsFilter.h"
|
||||
#include "nsIDOMSmsSegmentInfo.h"
|
||||
#include "nsIDOMMozMobileMessageThread.h"
|
||||
#include "nsIDOMConnection.h"
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "nsIDOMIccManager.h"
|
||||
@ -453,9 +452,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
@ -1147,11 +1143,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozMobileConnection, nsIDOMMozMobileConnection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection)
|
||||
|
@ -84,7 +84,6 @@ DOMCI_CLASS(MozSmsFilter)
|
||||
DOMCI_CLASS(MozSmsSegmentInfo)
|
||||
DOMCI_CLASS(MozMobileMessageThread)
|
||||
|
||||
DOMCI_CLASS(MozConnection)
|
||||
#ifdef MOZ_B2G_RIL
|
||||
DOMCI_CLASS(MozMobileConnection)
|
||||
#endif
|
||||
|
@ -800,6 +800,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'mozilla::dom::CellBroadcast',
|
||||
},
|
||||
|
||||
'MozConnection': {
|
||||
'nativeType': 'mozilla::dom::network::Connection',
|
||||
},
|
||||
|
||||
'MozIcc': {
|
||||
'nativeType': 'mozilla::dom::Icc',
|
||||
},
|
||||
@ -1882,7 +1886,6 @@ addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
|
||||
addExternalIface('LockedFile')
|
||||
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
|
||||
addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
|
||||
addExternalIface('MozConnection', headerFile='nsIDOMConnection.h')
|
||||
addExternalIface('MozControllers', nativeType='nsIControllers')
|
||||
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
|
||||
addExternalIface('MozFrameRequestCallback', nativeType='nsIFrameRequestCallback',
|
||||
|
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMConnection.idl',
|
||||
'nsIDOMTCPServerSocket.idl',
|
||||
'nsIDOMTCPSocket.idl',
|
||||
'nsIMozNavigatorNetwork.idl',
|
||||
|
@ -1,16 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
|
||||
[scriptable, uuid(a0eb16f3-5fa2-4cbd-bf7a-4ce7704b13ea)]
|
||||
interface nsIDOMMozConnection : nsISupports
|
||||
{
|
||||
readonly attribute double bandwidth;
|
||||
readonly attribute boolean metered;
|
||||
|
||||
[implicit_jscontext] attribute jsval onchange;
|
||||
};
|
@ -4,10 +4,9 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMMozConnection;
|
||||
|
||||
[uuid(7f021f5d-f704-4a29-b166-829595169aaf)]
|
||||
interface nsIMozNavigatorNetwork : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMMozConnection mozConnection;
|
||||
// This is a MozConnection
|
||||
readonly attribute nsISupports mozConnection;
|
||||
};
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
#include <limits>
|
||||
#include "mozilla/Hal.h"
|
||||
#include "Connection.h"
|
||||
#include "mozilla/dom/network/Connection.h"
|
||||
#include "mozilla/dom/MozConnectionBinding.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDOMEvent.h"
|
||||
@ -17,8 +18,6 @@
|
||||
*/
|
||||
#define CHANGE_EVENT_NAME NS_LITERAL_STRING("change")
|
||||
|
||||
DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
@ -26,25 +25,21 @@ namespace network {
|
||||
const char* Connection::sMeteredPrefName = "dom.network.metered";
|
||||
const bool Connection::sMeteredDefaultValue = false;
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(Connection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINetworkProperties)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
NS_IMPL_QUERY_INTERFACE_INHERITED1(Connection, nsDOMEventTargetHelper,
|
||||
nsINetworkProperties)
|
||||
|
||||
// Don't use |Connection| alone, since that confuses nsTraceRefcnt since
|
||||
// we're not the only class with that name.
|
||||
NS_IMPL_ADDREF_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(Connection, change)
|
||||
|
||||
Connection::Connection()
|
||||
: mCanBeMetered(kDefaultCanBeMetered)
|
||||
, mBandwidth(kDefaultBandwidth)
|
||||
, mIsWifi(kDefaultIsWifi)
|
||||
, mDHCPGateway(kDefaultDHCPGateway)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
void
|
||||
@ -66,29 +61,24 @@ Connection::Shutdown()
|
||||
hal::UnregisterNetworkObserver(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Connection::GetBandwidth(double* aBandwidth)
|
||||
double
|
||||
Connection::Bandwidth() const
|
||||
{
|
||||
if (mBandwidth == kDefaultBandwidth) {
|
||||
*aBandwidth = std::numeric_limits<double>::infinity();
|
||||
return NS_OK;
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
*aBandwidth = mBandwidth;
|
||||
return NS_OK;
|
||||
return mBandwidth;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Connection::GetMetered(bool* aMetered)
|
||||
bool
|
||||
Connection::Metered() const
|
||||
{
|
||||
if (!mCanBeMetered) {
|
||||
*aMetered = false;
|
||||
return NS_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
*aMetered = Preferences::GetBool(sMeteredPrefName,
|
||||
sMeteredDefaultValue);
|
||||
return NS_OK;
|
||||
return Preferences::GetBool(sMeteredPrefName, sMeteredDefaultValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -130,7 +120,12 @@ Connection::Notify(const hal::NetworkInformation& aNetworkInfo)
|
||||
DispatchTrustedEvent(CHANGE_EVENT_NAME);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
Connection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return MozConnectionBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace network
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef mozilla_dom_network_Connection_h
|
||||
#define mozilla_dom_network_Connection_h
|
||||
|
||||
#include "nsIDOMConnection.h"
|
||||
#include "nsINetworkProperties.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -22,14 +21,12 @@ class NetworkInformation;
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
class Connection : public nsDOMEventTargetHelper
|
||||
, public nsIDOMMozConnection
|
||||
, public NetworkObserver
|
||||
, public nsINetworkProperties
|
||||
class Connection MOZ_FINAL : public nsDOMEventTargetHelper
|
||||
, public NetworkObserver
|
||||
, public nsINetworkProperties
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMMOZCONNECTION
|
||||
NS_DECL_NSINETWORKPROPERTIES
|
||||
|
||||
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
|
||||
@ -42,6 +39,17 @@ public:
|
||||
// For IObserver
|
||||
void Notify(const hal::NetworkInformation& aNetworkInfo);
|
||||
|
||||
// WebIDL
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
double Bandwidth() const;
|
||||
|
||||
bool Metered() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(change)
|
||||
|
||||
private:
|
||||
/**
|
||||
* Update the connection information stored in the object using a
|
||||
|
@ -5,6 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS.mozilla.dom.network += [
|
||||
'Connection.h',
|
||||
'Constants.h',
|
||||
'TCPServerSocketChild.h',
|
||||
'TCPServerSocketParent.h',
|
||||
|
@ -19,26 +19,33 @@ function checkInterface(aInterface) {
|
||||
ok(("Moz" + aInterface) in window, aInterface + " should be prefixed");
|
||||
}
|
||||
|
||||
ok('mozConnection' in navigator, "navigator.mozConnection should exist");
|
||||
function test() {
|
||||
ok('mozConnection' in navigator, "navigator.mozConnection should exist");
|
||||
|
||||
ok(navigator.mozConnection, "navigator.mozConnection returns an object");
|
||||
ok(navigator.mozConnection, "navigator.mozConnection returns an object");
|
||||
|
||||
ok(navigator.mozConnection instanceof MozConnection,
|
||||
"navigator.mozConnection is a MozConnection object");
|
||||
ok(navigator.mozConnection instanceof EventTarget,
|
||||
"navigator.mozConnection is a EventTarget object");
|
||||
ok(navigator.mozConnection instanceof MozConnection,
|
||||
"navigator.mozConnection is a MozConnection object");
|
||||
ok(navigator.mozConnection instanceof EventTarget,
|
||||
"navigator.mozConnection is a EventTarget object");
|
||||
|
||||
checkInterface("Connection");
|
||||
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('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('metered' in navigator.mozConnection,
|
||||
"metered should be a Connection attribute");
|
||||
is(navigator.mozConnection.metered, false,
|
||||
"By default the connection is not metered");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["dom.network.enabled", true]]}, test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -619,7 +619,7 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozCellBroadcastEvent", b2g: true, pref: "dom.cellbroadcast.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"MozConnection",
|
||||
{name: "MozConnection", pref: "dom.network.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"mozContact",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
13
dom/webidl/MozConnection.webidl
Normal file
13
dom/webidl/MozConnection.webidl
Normal file
@ -0,0 +1,13 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.network.enabled"]
|
||||
interface MozConnection : EventTarget {
|
||||
readonly attribute unrestricted double bandwidth;
|
||||
readonly attribute boolean metered;
|
||||
|
||||
attribute EventHandler onchange;
|
||||
};
|
||||
|
@ -229,7 +229,6 @@ partial interface Navigator {
|
||||
};
|
||||
|
||||
// nsIDOMMozNavigatorNetwork
|
||||
interface MozConnection;
|
||||
partial interface Navigator {
|
||||
[Pref="dom.network.enabled"]
|
||||
readonly attribute MozConnection? mozConnection;
|
||||
|
@ -229,6 +229,7 @@ WEBIDL_FILES = [
|
||||
'MouseEvent.webidl',
|
||||
'MouseScrollEvent.webidl',
|
||||
'MozActivity.webidl',
|
||||
'MozConnection.webidl',
|
||||
'MozMmsMessage.webidl',
|
||||
'MozNamedAttrMap.webidl',
|
||||
'MozPowerManager.webidl',
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsHttpChannel.h"
|
||||
#include "nsHttpAuthCache.h"
|
||||
#include "nsStandardURL.h"
|
||||
#include "nsIDOMConnection.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIMozNavigatorNetwork.h"
|
||||
@ -2052,7 +2051,7 @@ nsHttpHandler::GetNetworkInfoInner(nsIInterfaceRequestor *cb,
|
||||
if (!networkNavigator)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMMozConnection> mozConnection;
|
||||
nsCOMPtr<nsISupports> mozConnection;
|
||||
networkNavigator->GetMozConnection(getter_AddRefs(mozConnection));
|
||||
nsCOMPtr<nsINetworkProperties> networkProperties =
|
||||
do_QueryInterface(mozConnection);
|
||||
@ -2105,7 +2104,7 @@ nsHttpHandler::GetNetworkEthernetInfoInner(nsIInterfaceRequestor *cb,
|
||||
if (!networkNavigator)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMMozConnection> mozConnection;
|
||||
nsCOMPtr<nsISupports> mozConnection;
|
||||
networkNavigator->GetMozConnection(getter_AddRefs(mozConnection));
|
||||
nsCOMPtr<nsINetworkProperties> networkProperties =
|
||||
do_QueryInterface(mozConnection);
|
||||
|
Loading…
Reference in New Issue
Block a user