Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6665)

Unified Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 473723002: Update data reduction proxy statistics prefs less often on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tooManyWritesPatch
Patch Set: Fixing nits Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_network_delegate.cc
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 77abac00de1b6e2699cf068e2e6d57f191d015f6..5c7491fb72c45fd2bd4f3ab26e609bb04c0b4904 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -33,6 +33,7 @@
#include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_statistics_prefs.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
#include "components/domain_reliability/monitor.h"
#include "content/public/browser/browser_thread.h"
@@ -115,7 +116,8 @@ void UpdateContentLengthPrefs(
int received_content_length,
int original_content_length,
data_reduction_proxy::DataReductionProxyRequestType request_type,
- Profile* profile) {
+ Profile* profile,
+ data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0);
@@ -124,10 +126,6 @@ void UpdateContentLengthPrefs(
if (!g_browser_process)
return;
- PrefService* prefs = g_browser_process->local_state();
- if (!prefs)
- return;
-
// Ignore off-the-record data.
if (!g_browser_process->profile_manager()->IsValidProfile(profile) ||
profile->IsOffTheRecord()) {
@@ -143,21 +141,27 @@ void UpdateContentLengthPrefs(
bool with_data_reduction_proxy_enabled = false;
#endif
- data_reduction_proxy::UpdateContentLengthPrefs(received_content_length,
- original_content_length,
- with_data_reduction_proxy_enabled,
- request_type, prefs);
+ data_reduction_proxy::UpdateContentLengthPrefs(
+ received_content_length,
+ original_content_length,
+ with_data_reduction_proxy_enabled,
+ request_type,
+ statistics_prefs);
}
void StoreAccumulatedContentLength(
int received_content_length,
int original_content_length,
data_reduction_proxy::DataReductionProxyRequestType request_type,
- Profile* profile) {
+ Profile* profile,
+ data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&UpdateContentLengthPrefs,
- received_content_length, original_content_length,
- request_type, profile));
+ received_content_length,
+ original_content_length,
+ request_type,
+ profile,
+ statistics_prefs));
}
void RecordContentLengthHistograms(
@@ -253,7 +257,8 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
prerender_tracker_(NULL),
data_reduction_proxy_params_(NULL),
data_reduction_proxy_usage_stats_(NULL),
- data_reduction_proxy_auth_request_handler_(NULL) {
+ data_reduction_proxy_auth_request_handler_(NULL),
+ data_reduction_proxy_statistics_prefs_(NULL) {
DCHECK(enable_referrers);
extensions_delegate_.reset(
ChromeExtensionsNetworkDelegate::Create(event_router));
@@ -322,6 +327,8 @@ void ChromeNetworkDelegate::AllowAccessToAllFiles() {
}
// static
+// TODO(megjablon): Use data_reduction_proxy_delayed_pref_service to read prefs.
+// Until updated the pref values may be up to an hour behind on desktop.
base::Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PrefService* prefs = g_browser_process->local_state();
@@ -817,10 +824,13 @@ void ChromeNetworkDelegate::AccumulateContentLength(
data_reduction_proxy::DataReductionProxyRequestType request_type) {
DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0);
- StoreAccumulatedContentLength(received_content_length,
- original_content_length,
- request_type,
- reinterpret_cast<Profile*>(profile_));
+ if (data_reduction_proxy_statistics_prefs_) {
+ StoreAccumulatedContentLength(received_content_length,
+ original_content_length,
+ request_type,
+ reinterpret_cast<Profile*>(profile_),
+ data_reduction_proxy_statistics_prefs_);
+ }
received_content_length_ += received_content_length;
original_content_length_ += original_content_length;
}
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.h ('k') | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698