Bug 1366822 - Part2: Revert changes of NotifyCurrentTopLevelContentWindowChange, r=mayhemer
authorKershaw Chang <kechang@mozilla.com>
Thu, 27 Jul 2017 23:42:00 +0200
changeset 420413 dca733c0467ff3133c5862728d4a0a5d9e03ee3c
parent 420412 43a17f4d5399bcca8f67b3756aadf670792873d2
child 420414 ac9dcc2cad707b4d16e0b7059510b79b1470cec3
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1366822
milestone56.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 1366822 - Part2: Revert changes of NotifyCurrentTopLevelContentWindowChange, r=mayhemer
dom/base/nsFocusManager.cpp
dom/base/nsFocusManager.h
dom/ipc/PContent.ipdl
netwerk/base/nsNetUtil.cpp
netwerk/base/nsNetUtil.h
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/NeckoParent.h
netwerk/ipc/PNecko.ipdl
netwerk/protocol/http/nsHttpHandler.cpp
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1871,18 +1871,16 @@ nsFocusManager::Focus(nsPIDOMWindowOuter
   }
 
   // indicate that the window has taken focus.
   if (aWindow->TakeFocus(true, focusMethod))
     aIsNewDocument = true;
 
   SetFocusedWindowInternal(aWindow);
 
-  NotifyCurrentTopLevelContentWindowChange(aWindow);
-
   // Update the system focus by focusing the root widget.  But avoid this
   // if 1) aAdjustWidgets is false or 2) aContent is a plugin that has its
   // own widget and is either already focused or is about to be focused.
   nsCOMPtr<nsIWidget> objectFrameWidget;
   if (aContent) {
     nsIFrame* contentFrame = aContent->GetPrimaryFrame();
     nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
     if (objectFrame)
@@ -3684,30 +3682,16 @@ nsFocusManager::SetFocusedWindowInternal
       doc->SetLastFocusTime(now);
     }
   }
 
   mFocusedWindow = aWindow;
 }
 
 void
-nsFocusManager::NotifyCurrentTopLevelContentWindowChange(
-                                                   nsPIDOMWindowOuter* aWindow)
-{
-  MOZ_ASSERT(aWindow);
-
-  nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetTop();
-  if (nsGlobalWindow::Cast(topWindow)->IsChromeWindow()) {
-    return;
-  }
-
-  NS_NotifyCurrentTopLevelOuterContentWindowId(topWindow->WindowID());
-}
-
-void
 nsFocusManager::MarkUncollectableForCCGeneration(uint32_t aGeneration)
 {
   if (!sInstance) {
     return;
   }
 
   if (sInstance->mActiveWindow) {
     sInstance->mActiveWindow->
--- a/dom/base/nsFocusManager.h
+++ b/dom/base/nsFocusManager.h
@@ -537,20 +537,16 @@ private:
   // wrong..
   static void NotifyFocusStateChange(nsIContent* aContent,
                                      nsIContent* aContentToFocus,
                                      bool aWindowShouldShowFocusRing,
                                      bool aGettingFocus);
 
   void SetFocusedWindowInternal(nsPIDOMWindowOuter* aWindow);
 
-  // Notify the change of content window ID
-  // belonging to the top level outer window.
-  void NotifyCurrentTopLevelContentWindowChange(nsPIDOMWindowOuter* aWindow);
-
   // the currently active and front-most top-most window
   nsCOMPtr<nsPIDOMWindowOuter> mActiveWindow;
 
   // the child or top-level window that is currently focused. This window will
   // either be the same window as mActiveWindow or a descendant of it.
   // Except during shutdown use SetFocusedWindowInternal to set mFocusedWindow!
   nsCOMPtr<nsPIDOMWindowOuter> mFocusedWindow;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -698,19 +698,17 @@ parent:
 
     async AccumulateMixedContentHSTS(URIParams aURI, bool aActive, bool aHasHSTSPriming,
                                      OriginAttributes aOriginAttributes);
 
     nested(inside_cpow) async PHal();
 
     async PHeapSnapshotTempFileHelper();
 
-    // Giving high priority to prevent other messages sending before this one.
-    // See bug 1360549 for details.
-    prio(high) async PNecko();
+    async PNecko();
 
     async PPrinting();
 
     async PChildToParentStream();
 
     async PSpeechSynthesis();
 
     nested(inside_cpow) async PStorage();
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -2831,37 +2831,16 @@ NS_IsOffline()
     nsCOMPtr<nsIIOService> ios = do_GetIOService();
     if (ios) {
         ios->GetOffline(&offline);
         ios->GetConnectivity(&connectivity);
     }
     return offline || !connectivity;
 }
 
-nsresult
-NS_NotifyCurrentTopLevelOuterContentWindowId(uint64_t aWindowId)
-{
-  nsCOMPtr<nsIObserverService> obs =
-    do_GetService("@mozilla.org/observer-service;1");
-  if (!obs) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsISupportsPRUint64> wrapper =
-    do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID);
-  if (!wrapper) {
-    return NS_ERROR_FAILURE;
-  }
-
-  wrapper->SetData(aWindowId);
-  return obs->NotifyObservers(wrapper,
-                              "net:current-toplevel-outer-content-windowid",
-                              nullptr);
-}
-
 namespace mozilla {
 namespace net {
 
 bool
 InScriptableRange(int64_t val)
 {
     return (val <= kJS_MAX_SAFE_INTEGER) && (val >= kJS_MIN_SAFE_INTEGER);
 }
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -963,21 +963,16 @@ nsresult NS_GetSecureUpgradedURI(nsIURI*
 nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel);
 
 /**
  * Return default referrer policy which is controlled by user
  * pref network.http.referer.userControlPolicy
  */
 uint32_t NS_GetDefaultReferrerPolicy();
 
-/**
- * Update the window id of the current focused top level content window.
- */
-nsresult NS_NotifyCurrentTopLevelOuterContentWindowId(uint64_t aWindowId);
-
 namespace mozilla {
 namespace net {
 
 const static uint64_t kJS_MAX_SAFE_UINTEGER = +9007199254740991ULL;
 const static  int64_t kJS_MIN_SAFE_INTEGER  = -9007199254740991LL;
 const static  int64_t kJS_MAX_SAFE_INTEGER  = +9007199254740991LL;
 
 // Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -946,26 +946,16 @@ NeckoParent::RecvRemoveRequestContext(co
   }
 
   rcsvc->RemoveRequestContext(rcid);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-NeckoParent::RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWindowId)
-{
-  if (NS_FAILED(NS_NotifyCurrentTopLevelOuterContentWindowId(aWindowId))) {
-    NS_WARNING("NS_NotifyCurrentTopLevelOuterContentWindowId failed!");
-  }
-
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
 NeckoParent::RecvGetExtensionStream(const URIParams& aURI,
                                     GetExtensionStreamResolver&& aResolve)
 {
   nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
   if (!deserializedURI) {
     return IPC_FAIL_NO_REASON(this);
   }
 
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -230,18 +230,16 @@ protected:
   virtual mozilla::ipc::IPCResult RecvPredLearn(const ipc::URIParams& aTargetURI,
                                                 const ipc::OptionalURIParams& aSourceURI,
                                                 const PredictorPredictReason& aReason,
                                                 const OriginAttributes& aOriginAttributes) override;
   virtual mozilla::ipc::IPCResult RecvPredReset() override;
 
   virtual mozilla::ipc::IPCResult RecvRemoveRequestContext(const uint64_t& rcid) override;
 
-  virtual mozilla::ipc::IPCResult RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWindowId) override;
-
   /* WebExtensions */
   virtual mozilla::ipc::IPCResult
     RecvGetExtensionStream(const URIParams& aURI,
                            GetExtensionStreamResolver&& aResolve) override;
 
   virtual mozilla::ipc::IPCResult
     RecvGetExtensionFD(const URIParams& aURI,
                        GetExtensionFDResolver&& aResolve) override;
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -121,18 +121,16 @@ parent:
   async OnAuthCancelled(uint64_t callbackId, bool userCancel);
 
   async RemoveRequestContext(uint64_t rcid);
 
   async PAltDataOutputStream(nsCString type, PHttpChannel channel);
 
   async PStunAddrsRequest();
 
-  prio(high) async NotifyCurrentTopLevelOuterContentWindowId(uint64_t windowId);
-
   /**
    * WebExtension-specific remote resource loading
    */
   async GetExtensionStream(URIParams uri) returns (OptionalIPCStream stream);
   async GetExtensionFD(URIParams uri) returns (FileDescriptor fd);
 
 child:
   /*
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -518,19 +518,22 @@ nsHttpHandler::Init()
         obsService->AddObserver(this, "net:clear-active-logins", true);
         obsService->AddObserver(this, "net:prune-dead-connections", true);
         // Sent by the TorButton add-on in the Tor Browser
         obsService->AddObserver(this, "net:prune-all-connections", true);
         obsService->AddObserver(this, "last-pb-context-exited", true);
         obsService->AddObserver(this, "browser:purge-session-history", true);
         obsService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
         obsService->AddObserver(this, "application-background", true);
-        obsService->AddObserver(this,
-                                "net:current-toplevel-outer-content-windowid",
-                                true);
+
+        if (!IsNeckoChild()) {
+            obsService->AddObserver(this,
+                                    "net:current-toplevel-outer-content-windowid",
+                                    true);
+        }
 
         if (mFastOpenSupported) {
             obsService->AddObserver(this, "captive-portal-login", true);
             obsService->AddObserver(this, "captive-portal-login-success", true);
         }
 
         // disabled as its a nop right now
         // obsService->AddObserver(this, "net:failed-to-process-uri-content", true);
@@ -2372,29 +2375,22 @@ nsHttpHandler::Observe(nsISupports *subj
     } else if (!strcmp(topic, "net:current-toplevel-outer-content-windowid")) {
         nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(subject);
         MOZ_RELEASE_ASSERT(wrapper);
 
         uint64_t windowId = 0;
         wrapper->GetData(&windowId);
         MOZ_ASSERT(windowId);
 
-        if (IsNeckoChild()) {
-            if (gNeckoChild) {
-                gNeckoChild->SendNotifyCurrentTopLevelOuterContentWindowId(
-                    windowId);
-            }
-        } else {
-            static uint64_t sCurrentTopLevelOuterContentWindowId = 0;
-            if (sCurrentTopLevelOuterContentWindowId != windowId) {
-                sCurrentTopLevelOuterContentWindowId = windowId;
-                if (mConnMgr) {
-                    mConnMgr->UpdateCurrentTopLevelOuterContentWindowId(
-                        sCurrentTopLevelOuterContentWindowId);
-                }
+        static uint64_t sCurrentTopLevelOuterContentWindowId = 0;
+        if (sCurrentTopLevelOuterContentWindowId != windowId) {
+            sCurrentTopLevelOuterContentWindowId = windowId;
+            if (mConnMgr) {
+                mConnMgr->UpdateCurrentTopLevelOuterContentWindowId(
+                    sCurrentTopLevelOuterContentWindowId);
             }
         }
     } else if (!strcmp(topic, "captive-portal-login") ||
                !strcmp(topic, "captive-portal-login-success")) {
          // We have detected a captive portal and we will reset the Fast Open
          // failure counter.
          ResetFastOpenConsecutiveFailureCounter();
     }