Bug 1377570 - Enable RCWN on mobile. r=valentin

This patch enables racing cache with network on mobile when cellular data isn't used.
This commit is contained in:
Michal Novotny 2018-05-27 03:59:00 +03:00
Родитель fef50df448
Коммит 63375bc80b
3 изменённых файлов: 28 добавлений и 4 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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<nsINetworkLinkService> 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;

Просмотреть файл

@ -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;