Backed out changeset 35e6bbc2136b (bug 1134596) for Android Crashtest failures
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 09 Apr 2015 12:33:41 +0200
changeset 268161 450f08cb8777a873fea94c3c8fdb1fecc80baa83
parent 268160 5c1530d4b38cf911491deab62a4ba6ba8e5a18e6
child 268162 b9fcd818c945f1769dfd4d575428936f3c891a62
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1134596
milestone40.0a1
backs out35e6bbc2136bfd47adbf9de936fd82053a5ef9f4
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
Backed out changeset 35e6bbc2136b (bug 1134596) for Android Crashtest failures
browser/app/profile/firefox.js
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
netwerk/base/nsIIOService.idl
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
netwerk/base/nsNetUtil.h
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -610,17 +610,17 @@ pref("mousewheel.with_shift.action", 2);
 pref("mousewheel.with_meta.action", 1); // win key on Win, Super/Hyper on Linux
 #endif
 pref("mousewheel.with_control.action",3);
 pref("mousewheel.with_win.action", 1);
 
 pref("browser.xul.error_pages.enabled", true);
 pref("browser.xul.error_pages.expert_bad_cert", false);
 
-// If true, network link events will change the value of navigator.onLine
+// Work Offline is best manually managed by the user.
 pref("network.manage-offline-status", false);
 
 // We want to make sure mail URLs are handled externally...
 pref("network.protocol-handler.external.mailto", true); // for mail
 pref("network.protocol-handler.external.news", true);   // for news
 pref("network.protocol-handler.external.snews", true);  // for secure news
 pref("network.protocol-handler.external.nntp", true);   // also news
 #ifdef XP_WIN
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -789,23 +789,21 @@ ContentChild::InitXPCOM()
         return;
     }
 
     mConsoleListener = new ConsoleListener(this);
     if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
         NS_WARNING("Couldn't register console listener for child process");
 
     bool isOffline;
-    bool isConnected;
     ClipboardCapabilities clipboardCaps;
     DomainPolicyClone domainPolicy;
 
-    SendGetXPCOMProcessAttributes(&isOffline, &isConnected, &mAvailableDictionaries, &clipboardCaps, &domainPolicy);
+    SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries, &clipboardCaps, &domainPolicy);
     RecvSetOffline(isOffline);
-    RecvSetConnectivity(isConnected);
 
     if (domainPolicy.active()) {
         nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
         MOZ_ASSERT(ssm);
         ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
         if (!mPolicy) {
             MOZ_CRASH("Failed to activate domain policy.");
         }
@@ -1824,28 +1822,16 @@ ContentChild::RecvSetOffline(const bool&
     nsCOMPtr<nsIIOService> io (do_GetIOService());
     NS_ASSERTION(io, "IO Service can not be null");
 
     io->SetOffline(offline);
 
     return true;
 }
 
-bool
-ContentChild::RecvSetConnectivity(const bool& connectivity)
-{
-    nsCOMPtr<nsIIOService> io(do_GetIOService());
-    nsCOMPtr<nsIIOServiceInternal> ioInternal(do_QueryInterface(io));
-    NS_ASSERTION(ioInternal, "IO Service can not be null");
-
-    ioInternal->SetConnectivity(connectivity);
-
-    return true;
-}
-
 void
 ContentChild::ActorDestroy(ActorDestroyReason why)
 {
     if (AbnormalShutdown == why) {
         NS_WARNING("shutting down early because of crash!");
         QuickExit();
     }
 
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -291,17 +291,16 @@ public:
     virtual bool RecvRegisterChromeItem(const ChromeRegistryItem& item) override;
 
     virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
     virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) override;
     virtual PRemoteSpellcheckEngineChild* AllocPRemoteSpellcheckEngineChild() override;
     virtual bool DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild*) override;
 
     virtual bool RecvSetOffline(const bool& offline) override;
-    virtual bool RecvSetConnectivity(const bool& connectivity) override;
 
     virtual bool RecvSpeakerManagerNotify() override;
 
     virtual bool RecvNotifyVisited(const URIParams& aURI) override;
     // auto remove when alertfinished is received.
     nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
 
     virtual bool RecvSystemMemoryAvailable(const uint64_t& aGetterId,
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -380,17 +380,16 @@ namespace mozilla {
 namespace dom {
 
 #ifdef MOZ_NUWA_PROCESS
 int32_t ContentParent::sNuwaPid = 0;
 bool ContentParent::sNuwaReady = false;
 #endif
 
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
-#define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
 
 class MemoryReportRequestParent : public PMemoryReportRequestParent
 {
 public:
     MemoryReportRequestParent();
     virtual ~MemoryReportRequestParent();
 
     virtual void ActorDestroy(ActorDestroyReason aWhy) override;
@@ -595,17 +594,16 @@ static uint64_t gContentChildID = 1;
 // actually for any app in particular.  Use a magic manifest URL.
 // Can't be a static constant.
 #define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
 
 static const char* sObserverTopics[] = {
     "xpcom-shutdown",
     "profile-before-change",
     NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
-    NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC,
     "child-memory-reporter-request",
     "memory-pressure",
     "child-gc-request",
     "child-cc-request",
     "child-mmu-request",
     "last-pb-context-exited",
     "file-watcher-update",
 #ifdef MOZ_WIDGET_GONK
@@ -2815,24 +2813,22 @@ ContentParent::RecvAddNewProcess(const u
                                 sNuwaPrefUpdates->Length() : 0;
     // Resend pref updates to the forked child.
     for (size_t i = 0; i < numNuwaPrefUpdates; i++) {
         mozilla::unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i));
     }
 
     // Update offline settings.
     bool isOffline;
-    bool isConnected;
     InfallibleTArray<nsString> unusedDictionaries;
     ClipboardCapabilities clipboardCaps;
     DomainPolicyClone domainPolicy;
-    RecvGetXPCOMProcessAttributes(&isOffline, &isConnected, &unusedDictionaries,
+    RecvGetXPCOMProcessAttributes(&isOffline, &unusedDictionaries,
                                   &clipboardCaps, &domainPolicy);
     mozilla::unused << content->SendSetOffline(isOffline);
-    mozilla::unused << content->SendSetConnectivity(isConnected);
     MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() &&
                !clipboardCaps.supportsFindClipboard(),
                "Unexpected values");
 
     PreallocatedProcessManager::PublishSpareProcess(content);
     return true;
 #else
     NS_ERROR("ContentParent::RecvAddNewProcess() not implemented!");
@@ -2915,27 +2911,16 @@ ContentParent::Observe(nsISupports* aSub
 #endif
           if (!SendSetOffline(!strcmp(offline, "true") ? true : false)) {
               return NS_ERROR_NOT_AVAILABLE;
           }
 #ifdef MOZ_NUWA_PROCESS
       }
 #endif
     }
-    else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC)) {
-#ifdef MOZ_NUWA_PROCESS
-        if (!(IsNuwaReady() && IsNuwaProcess())) {
-#endif
-            if (!SendSetConnectivity(NS_LITERAL_STRING("true").Equals(aData))) {
-                return NS_ERROR_NOT_AVAILABLE;
-            }
-#ifdef MOZ_NUWA_PROCESS
-        }
-#endif
-    }
     // listening for alert notifications
     else if (!strcmp(aTopic, "alertfinished") ||
              !strcmp(aTopic, "alertclickcallback") ||
              !strcmp(aTopic, "alertshow") ) {
         if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
                                       nsDependentString(aData)))
             return NS_ERROR_NOT_AVAILABLE;
     }
@@ -3174,29 +3159,25 @@ ContentParent::RecvGetProcessAttributes(
     *aIsForApp = IsForApp();
     *aIsForBrowser = mIsForBrowser;
 
     return true;
 }
 
 bool
 ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
-                                             bool* aIsConnected,
                                              InfallibleTArray<nsString>* dictionaries,
                                              ClipboardCapabilities* clipboardCaps,
                                              DomainPolicyClone* domainPolicy)
 {
     nsCOMPtr<nsIIOService> io(do_GetIOService());
     MOZ_ASSERT(io, "No IO service?");
     DebugOnly<nsresult> rv = io->GetOffline(aIsOffline);
     MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting offline?");
 
-    rv = io->GetConnectivity(aIsConnected);
-    MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting connectivity?");
-
     nsCOMPtr<nsISpellChecker> spellChecker(do_GetService(NS_SPELLCHECKER_CONTRACTID));
     MOZ_ASSERT(spellChecker, "No spell checker?");
 
     spellChecker->GetDictionaryList(dictionaries);
 
     nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
     MOZ_ASSERT(clipboard, "No clipboard?");
 
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -530,17 +530,16 @@ private:
     PProcessHangMonitorParent*
     AllocPProcessHangMonitorParent(Transport* aTransport,
                                    ProcessId aOtherProcess) override;
 
     virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
                                           bool* aIsForApp,
                                           bool* aIsForBrowser) override;
     virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline,
-                                               bool* aIsConnected,
                                                InfallibleTArray<nsString>* dictionaries,
                                                ClipboardCapabilities* clipboardCaps,
                                                DomainPolicyClone* domainPolicy)
         override;
 
     virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
 
     virtual bool DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) override;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -471,17 +471,16 @@ child:
 
     PTestShell();
 
     RegisterChrome(ChromePackage[] packages, ResourceMapping[] resources,
                    OverrideMapping[] overrides, nsCString locale, bool reset);
     RegisterChromeItem(ChromeRegistryItem item);
 
     async SetOffline(bool offline);
-    async SetConnectivity(bool connectivity);
 
     async NotifyVisited(URIParams uri);
 
     async SystemMemoryAvailable(uint64_t getterId, uint32_t memoryAvailable);
 
     PreferenceUpdate(PrefSetting pref);
 
     NotifyAlertsObserver(nsCString topic, nsString data);
@@ -612,19 +611,17 @@ parent:
      * |isForBrowser|, we're loading <browser>.  When |!isForApp &&
      * !isForBrowser|, we're probably loading <xul:browser remote>.
      *
      * Keep the return values in sync with PBrowser()!
      */
     sync GetProcessAttributes()
         returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
     sync GetXPCOMProcessAttributes()
-        returns (bool isOffline,
-                 bool isConnected,
-                 nsString[] dictionaries,
+        returns (bool isOffline, nsString[] dictionaries,
                  ClipboardCapabilities clipboardCaps,
                  DomainPolicyClone domainPolicy);
 
     sync CreateChildProcess(IPCTabContext context,
                             ProcessPriority priority,
                             TabId openerTabId)
         returns (ContentParentId cpId, bool isForApp, bool isForBrowser, TabId tabId);
     sync BridgeToChildProcess(ContentParentId cpId);
--- a/netwerk/base/nsIIOService.idl
+++ b/netwerk/base/nsIIOService.idl
@@ -17,17 +17,17 @@ interface nsILoadInfo;
  * 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(4286de5a-b2ea-446f-8f70-e2a461f42694)]
+[scriptable, uuid(b1c3c61d-2df9-4240-ae16-0355b51a2770)]
 interface nsIIOService : nsISupports
 {
     /**
      * Returns a protocol handler for a given URI scheme.
      *
      * @param aScheme the URI scheme
      * @return reference to corresponding nsIProtocolHandler
      */
@@ -173,21 +173,16 @@ interface nsIIOService : nsISupports
      * available -- that's hard to detect without causing the dialer to 
      * come up).
      *
      * Changing this fires observer notifications ... see below.
      */
     attribute boolean offline;
 
     /**
-     * Returns false if there are no interfaces for a network request
-     */
-    readonly attribute boolean connectivity;
-
-    /**
      * Set whether network appears to be offline for network connections from
      * a given appID.
      *
      * Calling this function may fire the "network:app-offline-status-changed"
      * notification, which is also sent to child processes containing this appId.
      * 'state' must one of nsIAppOfflineInfo::{ONLINE|OFFLINE|WIFI_ONLY}.
      */
     void setAppOffline(in uint32_t appId, in long state);
@@ -268,19 +263,8 @@ interface nsIAppOfflineInfo : nsISupport
 #define NS_IOSERVICE_ONLINE               "online"
 
 /**
  * When network:app-offline-status-changed is fired,
  * the 'Subject' argument is a nsIOfflineAppInfo.
  */
 #define NS_IOSERVICE_APP_OFFLINE_STATUS_TOPIC "network:app-offline-status-changed"
 %}
-
-[builtinclass, uuid(cd66ffef-3bc3-40de-841a-e2dcbea213a2)]
-interface nsIIOServiceInternal : nsISupports
-{
-    /**
-     * This is an internal method that should only be called from ContentChild
-     * in order to pass the connectivity state from the chrome process to the
-     * content process. It throws if called outside the content process.
-     */
-    void SetConnectivity(in boolean connectivity);
-};
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -153,18 +153,17 @@ bool nsIOService::sTelemetryEnabled = fa
 
 NS_IMPL_ISUPPORTS(nsAppOfflineInfo, nsIAppOfflineInfo)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsIOService::nsIOService()
     : mOffline(true)
     , mOfflineForProfileChange(false)
-    , mManageLinkStatus(false)
-    , mConnectivity(true)
+    , mManageOfflineStatus(false)
     , mSettingOffline(false)
     , mSetOfflineValue(false)
     , mShutdown(false)
     , mNetworkLinkServiceInitialized(false)
     , mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY)
     , mAutoDialEnabled(false)
     , mNetworkNotifyChanged(true)
     , mPreviousWifiState(-1)
@@ -280,20 +279,27 @@ nsIOService::InitializeNetworkLinkServic
     if (XRE_GetProcessType() == GeckoProcessType_Default)
     {
         mNetworkLinkService = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv);
     }
 
     if (mNetworkLinkService) {
         mNetworkLinkServiceInitialized = true;
     }
+    else {
+        // We can't really determine if the machine has a usable network connection,
+        // so let's cross our fingers!
+        mManageOfflineStatus = false;
+    }
 
-    // After initializing the networkLinkService, query the connectivity state
-    OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
-
+    if (mManageOfflineStatus)
+        OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
+    else
+        SetOffline(false);
+    
     return rv;
 }
 
 nsIOService*
 nsIOService::GetInstance() {
     if (!gIOService) {
         gIOService = new nsIOService();
         if (!gIOService)
@@ -312,17 +318,16 @@ nsIOService::GetInstance() {
 }
 
 NS_IMPL_ISUPPORTS(nsIOService,
                   nsIIOService,
                   nsIIOService2,
                   nsINetUtil,
                   nsISpeculativeConnect,
                   nsIObserver,
-                  nsIIOServiceInternal,
                   nsISupportsWeakReference)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsresult
 nsIOService::AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
                                     uint32_t flags,
                                     nsAsyncRedirectVerifyHelper *helper)
@@ -912,18 +917,17 @@ nsIOService::SetOffline(bool offline)
             mOffline = false;    // indicate success only AFTER we've
                                     // brought up the services
 
             // trigger a PAC reload when we come back online
             if (mProxyService)
                 mProxyService->ReloadPAC();
 
             // don't care if notification fails
-            // Only send the ONLINE notification if there is connectivity
-            if (observerService && mConnectivity)
+            if (observerService)
                 observerService->NotifyObservers(subject,
                                                  NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                                                  NS_LITERAL_STRING(NS_IOSERVICE_ONLINE).get());
         }
     }
 
     // Don't notify here, as the above notifications (if used) suffice.
     if ((mShutdown || mOfflineForProfileChange) && mOffline) {
@@ -939,82 +943,16 @@ nsIOService::SetOffline(bool offline)
         }
     }
 
     mSettingOffline = false;
 
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsIOService::GetConnectivity(bool *aConnectivity)
-{
-    *aConnectivity = mConnectivity;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsIOService::SetConnectivity(bool aConnectivity)
-{
-    // This should only be called from ContentChild to pass the connectivity
-    // value from the chrome process to the content process.
-    if (XRE_GetProcessType() == GeckoProcessType_Default) {
-        return NS_ERROR_NOT_AVAILABLE;
-    }
-    return SetConnectivityInternal(aConnectivity);
-}
-
-
-nsresult
-nsIOService::SetConnectivityInternal(bool aConnectivity)
-{
-    if (mConnectivity == aConnectivity) {
-        // Nothing to do here.
-        return NS_OK;
-    }
-    mConnectivity = aConnectivity;
-
-    nsCOMPtr<nsIObserverService> observerService =
-        mozilla::services::GetObserverService();
-    if (!observerService) {
-        return NS_OK;
-    }
-    // This notification sends the connectivity to the child processes
-    if (XRE_GetProcessType() == GeckoProcessType_Default) {
-        observerService->NotifyObservers(nullptr,
-            NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC, aConnectivity ?
-            MOZ_UTF16("true") :
-            MOZ_UTF16("false"));
-    }
-
-    if (mOffline) {
-      // We don't need to send any notifications if we're offline
-      return NS_OK;
-    }
-
-    if (aConnectivity) {
-        // If we were previously offline due to connectivity=false,
-        // send the ONLINE notification
-        observerService->NotifyObservers(
-            static_cast<nsIIOService *>(this),
-            NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
-            NS_LITERAL_STRING(NS_IOSERVICE_ONLINE).get());
-    } else {
-        // If we were previously online and lost connectivity
-        // send the OFFLINE notification
-        const nsLiteralString offlineString(MOZ_UTF16(NS_IOSERVICE_OFFLINE));
-        observerService->NotifyObservers(static_cast<nsIIOService *>(this),
-                                         NS_IOSERVICE_GOING_OFFLINE_TOPIC,
-                                         offlineString.get());
-        observerService->NotifyObservers(static_cast<nsIIOService *>(this),
-                                         NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
-                                         offlineString.get());
-    }
-    return NS_OK;
-}
 
 NS_IMETHODIMP
 nsIOService::AllowPort(int32_t inPort, const char *scheme, bool *_retval)
 {
     int16_t port = inPort;
     if (port == -1) {
         *_retval = true;
         return NS_OK;
@@ -1233,46 +1171,47 @@ nsIOService::Observe(nsISupports *subjec
     } else if (!strcmp(topic, kProfileChangeNetTeardownTopic)) {
         if (!mOffline) {
             mOfflineForProfileChange = true;
             SetOffline(true);
         }
     } else if (!strcmp(topic, kProfileChangeNetRestoreTopic)) {
         if (mOfflineForProfileChange) {
             mOfflineForProfileChange = false;
-            SetOffline(false);
-        }
+            if (!mManageOfflineStatus ||
+                NS_FAILED(OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN))) {
+                SetOffline(false);
+            }
+        } 
     } else if (!strcmp(topic, kProfileDoChange)) { 
         if (data && NS_LITERAL_STRING("startup").Equals(data)) {
             // Lazy initialization of network link service (see bug 620472)
             InitializeNetworkLinkService();
             // Set up the initilization flag regardless the actuall result.
             // If we fail here, we will fail always on.
             mNetworkLinkServiceInitialized = true;
-
-            // The browser starts off as offline. We go into online mode after this.
-            SetOffline(false);
-
             // And now reflect the preference setting
             nsCOMPtr<nsIPrefBranch> prefBranch;
             GetPrefBranch(getter_AddRefs(prefBranch));
             PrefsChanged(prefBranch, MANAGE_OFFLINE_STATUS_PREF);
         }
     } else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
         // Remember we passed XPCOM shutdown notification to prevent any
         // changes of the offline status from now. We must not allow going
         // online after this point.
         mShutdown = true;
 
         SetOffline(true);
 
         // Break circular reference.
         mProxyService = nullptr;
     } else if (!strcmp(topic, NS_NETWORK_LINK_TOPIC)) {
-        OnNetworkLinkEvent(NS_ConvertUTF16toUTF8(data).get());
+        if (!mOfflineForProfileChange && mManageOfflineStatus) {
+            OnNetworkLinkEvent(NS_ConvertUTF16toUTF8(data).get());
+        }
     } else if (!strcmp(topic, NS_WIDGET_WAKE_OBSERVER_TOPIC)) {
         // coming back alive from sleep
         nsCOMPtr<nsIObserverService> observerService =
             mozilla::services::GetObserverService();
 
         NS_ASSERTION(observerService, "The observer service should not be null");
 
         if (observerService && mNetworkNotifyChanged) {
@@ -1406,91 +1345,99 @@ nsIOService::NewSimpleNestedURI(nsIURI* 
 
     NS_IF_ADDREF(*aResult = new nsSimpleNestedURI(safeURI));
     return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 NS_IMETHODIMP
 nsIOService::SetManageOfflineStatus(bool aManage)
 {
-    mManageLinkStatus = aManage;
+    nsresult rv = NS_OK;
 
-    // When detection is not activated, the default connectivity state is true.
-    if (!mManageLinkStatus) {
-        SetConnectivityInternal(true);
-        return NS_OK;
-    }
+    // SetManageOfflineStatus must throw when we fail to go from non-managed
+    // to managed.  Usually because there is no link monitoring service
+    // available.  Failure to do this switch is detected by a failure of
+    // OnNetworkLinkEvent().  When there is no network link available during
+    // call to InitializeNetworkLinkService(), application is put to offline
+    // mode.  And when we change mMangeOfflineStatus to false on the next line
+    // we get stuck on being offline even though the link becomes later
+    // available.
+    bool wasManaged = mManageOfflineStatus;
+    mManageOfflineStatus = aManage;
 
     InitializeNetworkLinkService();
-    // If the NetworkLinkService is already initialized, it does not call
-    // OnNetworkLinkEvent. This is needed, when mManageLinkStatus goes from
-    // false to true.
-    OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
-    return NS_OK;
+
+    if (mManageOfflineStatus && !wasManaged) {
+        rv = OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
+        if (NS_FAILED(rv))
+            mManageOfflineStatus = false;
+    }
+    return rv;
 }
 
 NS_IMETHODIMP
-nsIOService::GetManageOfflineStatus(bool* aManage)
-{
-    *aManage = mManageLinkStatus;
+nsIOService::GetManageOfflineStatus(bool* aManage) {
+    *aManage = mManageOfflineStatus;
     return NS_OK;
 }
 
 // input argument 'data' is already UTF8'ed
 nsresult
 nsIOService::OnNetworkLinkEvent(const char *data)
 {
     if (!mNetworkLinkService)
         return NS_ERROR_FAILURE;
 
     if (mShutdown)
         return NS_ERROR_NOT_AVAILABLE;
 
-    if (!mManageLinkStatus) {
+    if (!mManageOfflineStatus) {
       return NS_OK;
     }
 
     if (!strcmp(data, NS_NETWORK_LINK_DATA_DOWN)) {
         // check to make sure this won't collide with Autodial
         if (mSocketTransportService) {
             bool autodialEnabled = false;
             mSocketTransportService->GetAutodialEnabled(&autodialEnabled);
             // If autodialing-on-link-down is enabled, check if the OS auto
             // dial option is set to always autodial. If so, then we are
             // always up for the purposes of offline management.
             if (autodialEnabled) {
-                bool isUp = true;
 #if defined(XP_WIN)
                 // On Windows, we should first check with the OS to see if
                 // autodial is enabled.  If it is enabled then we are allowed
                 // to manage the offline state.
-                isUp = nsNativeConnectionHelper::IsAutodialEnabled();
+                if (nsNativeConnectionHelper::IsAutodialEnabled()) {
+                    return SetOffline(false);
+                }
+#else
+                return SetOffline(false);
 #endif
-                return SetConnectivityInternal(isUp);
             }
         }
     }
 
-    bool isUp = true;
+    bool isUp;
     if (!strcmp(data, NS_NETWORK_LINK_DATA_CHANGED)) {
         // CHANGED means UP/DOWN didn't change
         return NS_OK;
     } else if (!strcmp(data, NS_NETWORK_LINK_DATA_DOWN)) {
         isUp = false;
     } else if (!strcmp(data, NS_NETWORK_LINK_DATA_UP)) {
         isUp = true;
     } else if (!strcmp(data, NS_NETWORK_LINK_DATA_UNKNOWN)) {
         nsresult rv = mNetworkLinkService->GetIsLinkUp(&isUp);
         NS_ENSURE_SUCCESS(rv, rv);
     } else {
         NS_WARNING("Unhandled network event!");
         return NS_OK;
     }
 
-    return SetConnectivityInternal(isUp);
+    return SetOffline(!isUp);
 }
 
 NS_IMETHODIMP
 nsIOService::EscapeString(const nsACString& aString,
                           uint32_t aEscapeType,
                           nsACString& aResult)
 {
   NS_ENSURE_ARG_MAX(aEscapeType, 4);
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -21,17 +21,16 @@
 #include "mozilla/Attributes.h"
 
 #define NS_N(x) (sizeof(x)/sizeof(*x))
 
 // We don't want to expose this observer topic.
 // Intended internal use only for remoting offline/inline events.
 // See Bug 552829
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
-#define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
 
 static const char gScheme[][sizeof("resource")] =
     {"chrome", "file", "http", "https", "jar", "data", "resource"};
 
 class nsAsyncRedirectVerifyHelper;
 class nsINetworkLinkService;
 class nsIPrefBranch;
 class nsIProtocolProxyService2;
@@ -45,26 +44,24 @@ namespace net {
 } // namespace net
 } // namespace mozilla
 
 class nsIOService final : public nsIIOService2
                         , public nsIObserver
                         , public nsINetUtil
                         , public nsISpeculativeConnect
                         , public nsSupportsWeakReference
-                        , public nsIIOServiceInternal
 {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIIOSERVICE
     NS_DECL_NSIIOSERVICE2
     NS_DECL_NSIOBSERVER
     NS_DECL_NSINETUTIL
     NS_DECL_NSISPECULATIVECONNECT
-    NS_DECL_NSIIOSERVICEINTERNAL
 
     // Gets the singleton instance of the IO Service, creating it as needed
     // Returns nullptr on out of memory or failure to initialize.
     // Returns an addrefed pointer.
     static nsIOService* GetInstance();
 
     nsresult Init();
     nsresult NewURI(const char* aSpec, nsIURI* aBaseURI,
@@ -84,17 +81,16 @@ public:
     void SetAppOfflineInternal(uint32_t appId, int32_t status);
 
 private:
     // These shouldn't be called directly:
     // - construct using GetInstance
     // - destroy using Release
     nsIOService();
     ~nsIOService();
-    nsresult SetConnectivityInternal(bool aConnectivity);
 
     nsresult OnNetworkLinkEvent(const char *data);
 
     nsresult GetCachedProtocolHandler(const char *scheme,
                                                   nsIProtocolHandler* *hdlrResult,
                                                   uint32_t start=0,
                                                   uint32_t end=0);
     nsresult CacheProtocolHandler(const char *scheme,
@@ -120,18 +116,17 @@ private:
     nsresult NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
                                                      nsIURI* aProxyURI,
                                                      uint32_t aProxyFlags,
                                                      nsILoadInfo* aLoadInfo,
                                                      nsIChannel** result);
 private:
     bool                                 mOffline;
     bool                                 mOfflineForProfileChange;
-    bool                                 mManageLinkStatus;
-    bool                                 mConnectivity;
+    bool                                 mManageOfflineStatus;
 
     // Used to handle SetOffline() reentrancy.  See the comment in
     // SetOffline() for more details.
     bool                                 mSettingOffline;
     bool                                 mSetOfflineValue;
 
     bool                                 mShutdown;
 
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -1951,23 +1951,20 @@ NS_NewNotificationCallbacksAggregation(n
 
 /**
  * Helper function for testing online/offline state of the browser.
  */
 inline bool
 NS_IsOffline()
 {
     bool offline = true;
-    bool connectivity = true;
     nsCOMPtr<nsIIOService> ios = do_GetIOService();
-    if (ios) {
+    if (ios)
         ios->GetOffline(&offline);
-        ios->GetConnectivity(&connectivity);
-    }
-    return offline || !connectivity;
+    return offline;
 }
 
 inline bool
 NS_IsAppOffline(uint32_t appId)
 {
     bool appOffline = false;
     nsCOMPtr<nsIIOService> io(
         do_GetService("@mozilla.org/network/io-service;1"));