Bug 1307491 - (Part 2) Remove support for per-app-offline in dom/ [nukeb2g] r=baku
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 17 Oct 2016 03:58:54 +0200
changeset 318244 b0c3f48a9c5d4e510e686c2e74253a66113eae81
parent 318243 5c0780a3a6cb086946c029404ead160f866010e0
child 318245 fe032494b41092c33c8d85bbeb3e40d4decdc59b
push id20716
push usercbook@mozilla.com
push dateTue, 18 Oct 2016 08:45:23 +0000
treeherderfx-team@dc89484d4b45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1307491
milestone52.0a1
Bug 1307491 - (Part 2) Remove support for per-app-offline in dom/ [nukeb2g] r=baku MozReview-Commit-ID: DV58awPq98
dom/base/Navigator.cpp
dom/base/nsGlobalWindow.cpp
dom/html/nsHTMLDNSPrefetch.cpp
dom/workers/RuntimeService.cpp
dom/workers/WorkerPrivate.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -684,21 +684,16 @@ Navigator::CookieEnabled()
   }
 
   return cookieEnabled;
 }
 
 bool
 Navigator::OnLine()
 {
-  if (mWindow && mWindow->GetDoc()) {
-    return !NS_IsOffline() &&
-      !NS_IsAppOffline(mWindow->GetDoc()->NodePrincipal());
-  }
-
   return !NS_IsOffline();
 }
 
 NS_IMETHODIMP
 Navigator::GetBuildID(nsAString& aBuildID)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10771,27 +10771,25 @@ nsPIDOMWindowInner::InvalidateServiceWor
 }
 
 void
 nsGlobalWindow::FireOfflineStatusEventIfChanged()
 {
   if (!AsInner()->IsCurrentInnerWindow())
     return;
 
-  bool isOffline = NS_IsOffline() || NS_IsAppOffline(GetPrincipal());
-
   // Don't fire an event if the status hasn't changed
-  if (mWasOffline == isOffline) {
-    return;
-  }
-
-  mWasOffline = isOffline;
+  if (mWasOffline == NS_IsOffline()) {
+    return;
+  }
+
+  mWasOffline = !mWasOffline;
 
   nsAutoString name;
-  if (isOffline) {
+  if (mWasOffline) {
     name.AssignLiteral("offline");
   } else {
     name.AssignLiteral("online");
   }
   // The event is fired at the body element, or if there is no body element,
   // at the document.
   nsCOMPtr<EventTarget> eventTarget = mDoc.get();
   nsHTMLDocument* htmlDoc = mDoc->AsHTMLDocument();
@@ -11405,18 +11403,17 @@ nsGlobalWindow::UnregisterIdleObserver(n
 
   return NS_OK;
 }
 
 nsresult
 nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
                         const char16_t* aData)
 {
-  if (!nsCRT::strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC) ||
-      !nsCRT::strcmp(aTopic, NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC)) {
+  if (!nsCRT::strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC)) {
     if (!IsFrozen()) {
         // Fires an offline status event if the offline status has changed
         FireOfflineStatusEventIfChanged();
     }
     return NS_OK;
   }
 
   if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
@@ -14048,17 +14045,17 @@ nsGlobalWindow::Create(nsGlobalWindow *a
   RefPtr<nsGlobalWindow> window = new nsGlobalWindow(aOuterWindow);
   window->InitWasOffline();
   return window.forget();
 }
 
 void
 nsGlobalWindow::InitWasOffline()
 {
-  mWasOffline = NS_IsOffline() || NS_IsAppOffline(GetPrincipal());
+  mWasOffline = NS_IsOffline();
 }
 
 void
 nsGlobalWindow::GetReturnValueOuter(JSContext* aCx,
                                     JS::MutableHandle<JS::Value> aReturnValue,
                                     nsIPrincipal& aSubjectPrincipal,
                                     ErrorResult& aError)
 {
--- a/dom/html/nsHTMLDNSPrefetch.cpp
+++ b/dom/html/nsHTMLDNSPrefetch.cpp
@@ -92,20 +92,16 @@ nsHTMLDNSPrefetch::Shutdown()
   NS_IF_RELEASE(sDNSListener);
   
   return NS_OK;
 }
 
 bool
 nsHTMLDNSPrefetch::IsAllowed (nsIDocument *aDocument)
 {
-  if (NS_IsAppOffline(aDocument->NodePrincipal())) {
-    return false;
-  }
-
   // There is no need to do prefetch on non UI scenarios such as XMLHttpRequest.
   return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow();
 }
 
 nsresult
 nsHTMLDNSPrefetch::Prefetch(Link *aElement, uint16_t flags)
 {
   if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2718,22 +2718,16 @@ RuntimeService::Observe(nsISupports* aSu
     CycleCollectAllWorkers();
     MemoryPressureAllWorkers();
     return NS_OK;
   }
   if (!strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC)) {
     SendOfflineStatusChangeEventToAllWorkers(NS_IsOffline());
     return NS_OK;
   }
-  if (!strcmp(aTopic, NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC)) {
-    BROADCAST_ALL_WORKERS(OfflineStatusChangeEvent,
-                          NS_IsOffline() ||
-                          NS_IsAppOffline(workers[index]->GetPrincipal()));
-    return NS_OK;
-  }
 
   NS_NOTREACHED("Unknown observer topic!");
   return NS_OK;
 }
 
 /* static */ void
 RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
 {
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -3963,17 +3963,17 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
   if (aParent) {
     aParent->AssertIsOnWorkerThread();
     aParent->GetAllPreferences(mPreferences);
     mOnLine = aParent->OnLine();
   }
   else {
     AssertIsOnMainThread();
     RuntimeService::GetDefaultPreferences(mPreferences);
-    mOnLine = !NS_IsOffline() && !NS_IsAppOffline(aLoadInfo.mPrincipal);
+    mOnLine = !NS_IsOffline();
   }
 
   nsCOMPtr<nsIEventTarget> target;
 
   if (aParent) {
     target = aParent->MainThreadEventTarget();
   }