Bug 1507604 - Remove nsINetworkProperties. r=smaug
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 23 Nov 2018 15:53:01 +0000
changeset 507072 61ae20a33f32512939c5239d16fbfca11969ddc7
parent 507071 8c69ece51451f6ae6da33d9475f7225a51b037d3
child 507073 93bf8d17f265bb2767114ac46975f2ff8f02b130
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1507604
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507604 - Remove nsINetworkProperties. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D12135
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/network/Connection.cpp
dom/network/Connection.h
netwerk/base/moz.build
netwerk/base/nsINetworkProperties.idl
netwerk/protocol/http/nsHttpHandler.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1430,22 +1430,16 @@ Navigator::RequestMIDIAccess(const MIDIO
   if (!mWindow) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
   MIDIAccessManager* accessMgr = MIDIAccessManager::Get();
   return accessMgr->RequestMIDIAccess(mWindow, aOptions, aRv);
 }
 
-nsINetworkProperties*
-Navigator::GetNetworkProperties()
-{
-  return GetConnection(IgnoreErrors());
-}
-
 network::Connection*
 Navigator::GetConnection(ErrorResult& aRv)
 {
   if (!mConnection) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -18,17 +18,16 @@
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/dom/MediaKeySystemAccessManager.h"
 
 class nsPluginArray;
 class nsMimeTypeArray;
 class nsPIDOMWindowInner;
 class nsIDOMNavigatorSystemMessages;
-class nsINetworkProperties;
 class nsIPrincipal;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 class BodyExtractorBase;
 class Geolocation;
 class systemMessageCallback;
@@ -178,17 +177,16 @@ public:
   void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
   void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
   VRServiceTest* RequestVRServiceTest();
   bool IsWebVRContentDetected() const;
   bool IsWebVRContentPresenting() const;
   void RequestVRPresentation(VRDisplay& aDisplay);
-  nsINetworkProperties* GetNetworkProperties();
   already_AddRefed<Promise> RequestMIDIAccess(const MIDIOptions& aOptions, ErrorResult& aRv);
 
   Presentation* GetPresentation(ErrorResult& aRv);
 
   bool SendBeacon(const nsAString& aUrl,
                   const Nullable<fetch::BodyInit>& aData,
                   ErrorResult& aRv);
 
--- a/dom/network/Connection.cpp
+++ b/dom/network/Connection.cpp
@@ -17,23 +17,19 @@
  */
 #define CHANGE_EVENT_NAME NS_LITERAL_STRING("typechange")
 
 namespace mozilla {
 namespace dom {
 
 namespace network {
 
-NS_IMPL_QUERY_INTERFACE_INHERITED(Connection, DOMEventTargetHelper,
-                                  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, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(dom::network::Connection, DOMEventTargetHelper)
+NS_IMPL_ISUPPORTS_INHERITED0(dom::network::Connection, DOMEventTargetHelper)
 
 Connection::Connection(nsPIDOMWindowInner* aWindow)
   : DOMEventTargetHelper(aWindow)
   , mType(static_cast<ConnectionType>(kDefaultType))
   , mIsWifi(kDefaultIsWifi)
   , mDHCPGateway(kDefaultDHCPGateway)
   , mBeenShutDown(false)
 {
@@ -54,36 +50,16 @@ Connection::Shutdown()
   if (mBeenShutDown) {
     return;
   }
 
   mBeenShutDown = true;
   ShutdownInternal();
 }
 
-NS_IMETHODIMP
-Connection::GetIsWifi(bool* aIsWifi)
-{
-  NS_ENSURE_ARG_POINTER(aIsWifi);
-  NS_ASSERT_OWNINGTHREAD(Connection);
-
-  *aIsWifi = mIsWifi;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Connection::GetDhcpGateway(uint32_t* aGW)
-{
-  NS_ENSURE_ARG_POINTER(aGW);
-  NS_ASSERT_OWNINGTHREAD(Connection);
-
-  *aGW = mDHCPGateway;
-  return NS_OK;
-}
-
 JSObject*
 Connection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return NetworkInformation_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 void
 Connection::Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
--- a/dom/network/Connection.h
+++ b/dom/network/Connection.h
@@ -6,37 +6,33 @@
 
 #ifndef mozilla_dom_network_Connection_h
 #define mozilla_dom_network_Connection_h
 
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/NetworkInformationBinding.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsINetworkProperties.h"
 
 namespace mozilla {
 
 namespace hal {
 class NetworkInformation;
 } // namespace hal
 
 namespace dom {
 
 class WorkerPrivate;
 
 namespace network {
 
 class Connection : public DOMEventTargetHelper
-                 , public nsINetworkProperties
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSINETWORKPROPERTIES
-  NS_DECL_OWNINGTHREAD
 
   static Connection*
   CreateForWindow(nsPIDOMWindowInner* aWindow);
 
   static already_AddRefed<Connection>
   CreateForWorker(WorkerPrivate* aWorkerPrivate,
                   ErrorResult& aRv);
 
@@ -48,16 +44,29 @@ public:
                                JS::Handle<JSObject*> aGivenProto) override;
 
   ConnectionType Type() const
   {
     return nsContentUtils::ShouldResistFingerprinting() ?
              static_cast<ConnectionType>(ConnectionType::Unknown) : mType;
   }
 
+  bool GetIsWifi()
+  {
+    NS_ASSERT_OWNINGTHREAD(Connection);
+
+    return mIsWifi;
+  }
+  uint32_t GetDhcpGateway()
+  {
+    NS_ASSERT_OWNINGTHREAD(Connection);
+
+    return mDHCPGateway;
+  }
+
   IMPL_EVENT_HANDLER(typechange)
 
 protected:
   Connection(nsPIDOMWindowInner* aWindow);
   virtual ~Connection();
 
   void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
               bool aNotify);
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -64,17 +64,16 @@ XPIDL_SOURCES += [
     'nsINetAddr.idl',
     'nsINetUtil.idl',
     'nsINetworkConnectivityService.idl',
     'nsINetworkInfoService.idl',
     'nsINetworkInterceptController.idl',
     'nsINetworkLinkService.idl',
     'nsINetworkPredictor.idl',
     'nsINetworkPredictorVerifier.idl',
-    'nsINetworkProperties.idl',
     'nsINullChannel.idl',
     'nsIParentChannel.idl',
     'nsIParentRedirectingChannel.idl',
     'nsIPermission.idl',
     'nsIPermissionManager.idl',
     'nsIPrivateBrowsingChannel.idl',
     'nsIProgressEventSink.idl',
     'nsIPrompt.idl',
deleted file mode 100644
--- a/netwerk/base/nsINetworkProperties.idl
+++ /dev/null
@@ -1,18 +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"
-
-/* This interface provides supplemental information
-   to that which is provided by the network info definition. It is
-   reasonable to expect it to grow.
-*/
-
-
-[scriptable, builtinclass, uuid(0af94dec-7ffc-4301-8937-766c214ac688)]
-interface nsINetworkProperties : nsISupports
-{
-    readonly attribute boolean isWifi;
-    readonly attribute unsigned long dhcpGateway;
-};
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -11,17 +11,16 @@
 
 #include "nsError.h"
 #include "nsHttp.h"
 #include "nsHttpHandler.h"
 #include "nsHttpChannel.h"
 #include "nsHttpAuthCache.h"
 #include "nsStandardURL.h"
 #include "nsIDOMWindow.h"
-#include "nsINetworkProperties.h"
 #include "nsIHttpChannel.h"
 #include "nsIStandardURL.h"
 #include "LoadContextInfo.h"
 #include "nsCategoryManagerUtils.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsSocketProviderService.h"
@@ -64,16 +63,17 @@
 #include "mozilla/net/RequestContextService.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "mozilla/BasePrincipal.h"
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/Navigator.h"
+#include "mozilla/dom/network/Connection.h"
 
 #include "nsNSSComponent.h"
 
 #if defined(XP_UNIX)
 #include <sys/utsname.h>
 #endif
 
 #if defined(XP_WIN)
@@ -2650,31 +2650,23 @@ nsHttpHandler::TickleWifi(nsIInterfaceRe
     nsCOMPtr<nsPIDOMWindowOuter> piWindow = do_QueryInterface(domWindow);
     if (!piWindow)
         return;
 
     RefPtr<dom::Navigator> navigator = piWindow->GetNavigator();
     if (!navigator)
         return;
 
-    nsCOMPtr<nsINetworkProperties> networkProperties =
-        navigator->GetNetworkProperties();
+    RefPtr<dom::network::Connection> networkProperties =
+        navigator->GetConnection(IgnoreErrors());
     if (!networkProperties)
         return;
 
-    uint32_t gwAddress;
-    bool isWifi;
-    nsresult rv;
-
-    rv = networkProperties->GetDhcpGateway(&gwAddress);
-    if (NS_SUCCEEDED(rv))
-        rv = networkProperties->GetIsWifi(&isWifi);
-    if (NS_FAILED(rv))
-        return;
-
+    uint32_t gwAddress = networkProperties->GetDhcpGateway();
+    bool isWifi = networkProperties->GetIsWifi();
     if (!gwAddress || !isWifi)
         return;
 
     mWifiTickler->SetIPV4Address(gwAddress);
     mWifiTickler->Tickle();
 }
 
 //-----------------------------------------------------------------------------