Bug 786419 - Part 10 - Fix app wrongly reporting an offline status r=jduell
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 27 Aug 2014 05:25:47 +0300
changeset 233712 129db8233683f0ef0c4c134317f7a5eb7b19aa60
parent 233711 6898b53b3c11d04f422af9d90a5b9bca378d5ad4
child 233713 7e1d2aaeeec1b843ba061552d6e66bd9cc19df85
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs786419, 1058718
milestone35.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 786419 - Part 10 - Fix app wrongly reporting an offline status r=jduell In order for the content process to have an up-to-date table of which apps are offline, we send that status in TabParent::LoadURL. However, the fact that IsAppOffline returned true when the browser was offline, caused us to send the offline status to content processes, and caused Bug 1058718. This also updates the UUID for nsIOService.
dom/base/Navigator.cpp
dom/workers/RuntimeService.cpp
netwerk/base/public/nsIIOService.idl
netwerk/base/src/nsIOService.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -580,17 +580,18 @@ Navigator::CookieEnabled()
 
   return cookieEnabled;
 }
 
 bool
 Navigator::OnLine()
 {
   if (mWindow && mWindow->GetDoc()) {
-    return !NS_IsAppOffline(mWindow->GetDoc()->NodePrincipal());
+    return !NS_IsOffline() &&
+      !NS_IsAppOffline(mWindow->GetDoc()->NodePrincipal());
   }
 
   return !NS_IsOffline();
 }
 
 NS_IMETHODIMP
 Navigator::GetBuildID(nsAString& aBuildID)
 {
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2615,17 +2615,17 @@ RuntimeService::Observe(nsISupports* aSu
 
     uint32_t notificationAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
     info->GetAppId(&notificationAppId);
 
     if (appId != notificationAppId) {
       return NS_OK;
     }
 
-    SendOfflineStatusChangeEventToAllWorkers(NS_IsAppOffline(appId));
+    SendOfflineStatusChangeEventToAllWorkers(NS_IsOffline() || NS_IsAppOffline(appId));
   }
 
   NS_NOTREACHED("Unknown observer topic!");
   return NS_OK;
 }
 
 /* static */ void
 RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
--- a/netwerk/base/public/nsIIOService.idl
+++ b/netwerk/base/public/nsIIOService.idl
@@ -14,17 +14,17 @@ interface nsIFile;
  * nsIIOService provides a set of network utility functions.  This interface
  * duplicates many of the nsIProtocolHandler methods in a protocol handler
  * independent way (e.g., NewURI inspects the scheme in order to delegate
  * creation of the new URI to the appropriate protocol handler).  nsIIOService
  * also provides a set of URL parsing utility functions.  These are provided
  * as a convenience to the programmer and in some cases to improve performance
  * by eliminating intermediate data structures and interfaces.
  */
-[scriptable, uuid(bddeda3f-9020-4d12-8c70-984ee9f7935e)]
+[scriptable, uuid(2d19475d-7557-43f7-9682-0c44417b6c0f)]
 interface nsIIOService : nsISupports
 {
     /**
      * Returns a protocol handler for a given URI scheme.
      *
      * @param aScheme the URI scheme
      * @return reference to corresponding nsIProtocolHandler
      */
@@ -97,16 +97,17 @@ interface nsIIOService : nsISupports
      * 'state' must one of nsIAppOfflineInfo::{ONLINE|OFFLINE|WIFI_ONLY}.
      */
     void setAppOffline(in uint32_t appId, in long state);
 
     /**
      * Returns true if given appId is currently not allowed to make network
      * connections. It will return true if the app is in the wifi-only state
      * and we are currently on a 3G connection.
+     * The returned value does not depend on the offline state of the browser.
      */
     boolean isAppOffline(in uint32_t appId);
 
 
     /**
      * Checks if a port number is banned. This involves consulting a list of
      * unsafe ports, corresponding to network services that may be easily
      * exploitable. If the given port is considered unsafe, then the protocol
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -1504,22 +1504,17 @@ nsIOService::SetAppOfflineInternal(uint3
     }
 
 }
 
 NS_IMETHODIMP
 nsIOService::IsAppOffline(uint32_t aAppId, bool* aResult)
 {
     NS_ENSURE_ARG(aResult);
-    *aResult = mOffline;
-
-    if (mOffline) {
-        // If the entire browser is offline, return that status
-        return NS_OK;
-    }
+    *aResult = false;
 
     if (aAppId == NECKO_NO_APP_ID ||
         aAppId == NECKO_UNKNOWN_APP_ID) {
         return NS_ERROR_NOT_AVAILABLE;
     }
 
     int32_t state;
     if (mAppsOfflineStatus.Get(aAppId, &state)) {