Bug 1134596 - Add network.offline-mirrors-connectivity pref to preserve previous behaviour r=honzab

This commit is contained in:
Valentin Gosu 2015-04-09 06:33:03 +03:00
parent 68ee4c948d
commit 7ed5b37119
3 changed files with 16 additions and 1 deletions

View File

@ -1162,6 +1162,11 @@ 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

View File

@ -59,6 +59,7 @@ using mozilla::net::IsNeckoChild;
#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,
@ -160,6 +161,7 @@ nsIOService::nsIOService()
, mOfflineForProfileChange(false)
, mManageLinkStatus(false)
, mConnectivity(true)
, mOfflineMirrorsConnectivity(true)
, mSettingOffline(false)
, mSetOfflineValue(false)
, mShutdown(false)
@ -227,6 +229,7 @@ nsIOService::Init()
NS_WARNING("failed to get observer service");
Preferences::AddBoolVarCache(&sTelemetryEnabled, "toolkit.telemetry.enabled", false);
Preferences::AddBoolVarCache(&mOfflineMirrorsConnectivity, OFFLINE_MIRRORS_CONNECTIVITY, true);
gIOService = this;
@ -839,7 +842,11 @@ nsIOService::IsLinkUp()
NS_IMETHODIMP
nsIOService::GetOffline(bool *offline)
{
*offline = mOffline;
if (mOfflineMirrorsConnectivity) {
*offline = mOffline || !mConnectivity;
} else {
*offline = mOffline;
}
return NS_OK;
}

View File

@ -127,6 +127,9 @@ private:
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.