Bug 1134596 - Add network.offline-mirrors-connectivity pref to preserve previous behaviour r=honzab
☠☠ backed out by 5c1530d4b38c ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 09 Apr 2015 06:33:03 +0300
changeset 238268 82d6b5523a2bac42d66d517686c57ec3c776a558
parent 238267 35e6bbc2136bfd47adbf9de936fd82053a5ef9f4
child 238269 fb48ee62bab4bf27fde7a25f3e8ae83a1e44f870
push id58170
push uservalentin.gosu@gmail.com
push dateThu, 09 Apr 2015 03:33:33 +0000
treeherdermozilla-inbound@fb48ee62bab4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs1134596
milestone40.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 1134596 - Add network.offline-mirrors-connectivity pref to preserve previous behaviour r=honzab
modules/libpref/init/all.js
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1157,16 +1157,21 @@ pref("network.protocol-handler.external.
 pref("network.protocol-handler.expose-all", true);
 
 // Warning for about:networking page
 pref("network.warnOnAboutNetworking", true);
 
 // Example: make IMAP an exposed protocol
 // pref("network.protocol-handler.expose.imap", true);
 
+// Whether IOService.connectivity and NS_IsOffline depends on connectivity status
+pref("network.manage-offline-status", false);
+// If set to true, IOService.offline depends on IOService.connectivity
+pref("network.offline-mirrors-connectivity", true);
+
 // <http>
 pref("network.http.version", "1.1");      // default
 // pref("network.http.version", "1.0");   // uncomment this out in case of problems
 // pref("network.http.version", "0.9");   // it'll work too if you're crazy
 // keep-alive option is effectively obsolete. Nevertheless it'll work with
 // some older 1.0 servers:
 
 pref("network.http.proxy.version", "1.1");    // default
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -54,16 +54,17 @@
 
 using namespace mozilla;
 using mozilla::net::IsNeckoChild;
 
 #define PORT_PREF_PREFIX           "network.security.ports."
 #define PORT_PREF(x)               PORT_PREF_PREFIX x
 #define AUTODIAL_PREF              "network.autodial-helper.enabled"
 #define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status"
+#define OFFLINE_MIRRORS_CONNECTIVITY "network.offline-mirrors-connectivity"
 
 // Nb: these have been misnomers since bug 715770 removed the buffer cache.
 // "network.segment.count" and "network.segment.size" would be better names,
 // but the old names are still used to preserve backward compatibility.
 #define NECKO_BUFFER_CACHE_COUNT_PREF "network.buffer.cache.count"
 #define NECKO_BUFFER_CACHE_SIZE_PREF  "network.buffer.cache.size"
 #define NETWORK_NOTIFY_CHANGED_PREF   "network.notify.changed"
 
@@ -155,16 +156,17 @@ NS_IMPL_ISUPPORTS(nsAppOfflineInfo, nsIA
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsIOService::nsIOService()
     : mOffline(true)
     , mOfflineForProfileChange(false)
     , mManageLinkStatus(false)
     , mConnectivity(true)
+    , mOfflineMirrorsConnectivity(true)
     , mSettingOffline(false)
     , mSetOfflineValue(false)
     , mShutdown(false)
     , mNetworkLinkServiceInitialized(false)
     , mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY)
     , mAutoDialEnabled(false)
     , mNetworkNotifyChanged(true)
     , mPreviousWifiState(-1)
@@ -222,16 +224,17 @@ nsIOService::Init()
         observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
         observerService->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true);
         observerService->AddObserver(this, kNetworkActiveChanged, true);
     }
     else
         NS_WARNING("failed to get observer service");
 
     Preferences::AddBoolVarCache(&sTelemetryEnabled, "toolkit.telemetry.enabled", false);
+    Preferences::AddBoolVarCache(&mOfflineMirrorsConnectivity, OFFLINE_MIRRORS_CONNECTIVITY, true);
 
     gIOService = this;
 
     InitializeNetworkLinkService();
 
     return NS_OK;
 }
 
@@ -834,17 +837,21 @@ nsIOService::IsLinkUp()
     }
 
     return isLinkUp;
 }
 
 NS_IMETHODIMP
 nsIOService::GetOffline(bool *offline)
 {
-    *offline = mOffline;
+    if (mOfflineMirrorsConnectivity) {
+        *offline = mOffline || !mConnectivity;
+    } else {
+        *offline = mOffline;
+    }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIOService::SetOffline(bool offline)
 {
     // When someone wants to go online (!offline) after we got XPCOM shutdown
     // throw ERROR_NOT_AVAILABLE to prevent return to online state.
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -122,16 +122,19 @@ private:
                                                      uint32_t aProxyFlags,
                                                      nsILoadInfo* aLoadInfo,
                                                      nsIChannel** result);
 private:
     bool                                 mOffline;
     bool                                 mOfflineForProfileChange;
     bool                                 mManageLinkStatus;
     bool                                 mConnectivity;
+    // If true, the connectivity state will be mirrored by IOService.offline
+    // meaning if !mConnectivity, GetOffline() will return true
+    bool                                 mOfflineMirrorsConnectivity;
 
     // Used to handle SetOffline() reentrancy.  See the comment in
     // SetOffline() for more details.
     bool                                 mSettingOffline;
     bool                                 mSetOfflineValue;
 
     bool                                 mShutdown;