diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index b3d97dfd5759..bdcaffa9da7d 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -106,10 +106,6 @@ pref("network.http.max-persistent-connections-per-proxy", 20); pref("network.http.spdy.push-allowance", 32768); pref("network.http.spdy.default-hpack-buffer", 4096); // 4k -// Racing the cache with the network should be disabled to prevent accidental -// data usage. -pref("network.http.rcwn.enabled", false); - // See bug 545869 for details on why these are set the way they are pref("network.buffer.cache.count", 24); pref("network.buffer.cache.size", 16384); diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index d2aae0684887..5a415b3f2a7d 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -112,6 +112,7 @@ #include "nsIMIMEInputStream.h" #include "nsIMultiplexInputStream.h" #include "../../cache2/CacheFileUtils.h" +#include "nsINetworkLinkService.h" #ifdef MOZ_TASK_TRACER #include "GeckoTaskTracer.h" @@ -9122,6 +9123,23 @@ nsHttpChannel::TriggerNetwork() nsresult nsHttpChannel::MaybeRaceCacheWithNetwork() { + nsresult rv; + + nsCOMPtr netLinkSvc = + do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + uint32_t linkType; + rv = netLinkSvc->GetLinkType(&linkType); + NS_ENSURE_SUCCESS(rv, rv); + + if (!(linkType == nsINetworkLinkService::LINK_TYPE_UNKNOWN || + linkType == nsINetworkLinkService::LINK_TYPE_ETHERNET || + linkType == nsINetworkLinkService::LINK_TYPE_USB || + linkType == nsINetworkLinkService::LINK_TYPE_WIFI)) { + return NS_OK; + } + // Don't trigger the network if the load flags say so. if (mLoadFlags & (LOAD_ONLY_FROM_CACHE | LOAD_NO_NETWORK_IO)) { return NS_OK; diff --git a/toolkit/content/aboutNetworking.js b/toolkit/content/aboutNetworking.js index d81e63e6599e..01e8826bfed5 100644 --- a/toolkit/content/aboutNetworking.js +++ b/toolkit/content/aboutNetworking.js @@ -12,6 +12,8 @@ const gDashboard = Cc["@mozilla.org/network/dashboard;1"] .getService(Ci.nsIDashboard); const gDirServ = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIDirectoryServiceProvider); +const gNetLinkSvc = Cc["@mozilla.org/network/network-link-service;1"] + .getService(Ci.nsINetworkLinkService); const gRequestNetworkingData = { "http": gDashboard.requestHttpConnections, @@ -127,6 +129,14 @@ function displayWebsockets(data) { function displayRcwnStats(data) { let status = Services.prefs.getBoolPref("network.http.rcwn.enabled"); + let linkType = gNetLinkSvc.linkType; + if (!(linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN || + linkType == Ci.nsINetworkLinkService.LINK_TYPE_ETHERNET || + linkType == Ci.nsINetworkLinkService.LINK_TYPE_USB || + linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI)) { + status = false; + } + let cacheWon = data.rcwnCacheWonCount; let netWon = data.rcwnNetWonCount; let total = data.totalNetworkRequests;