Chromium Code Reviews| 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 413033ba0e91195da63da70affd6e0b564995028..a02df2fc0f0bc958a12235aa4920e05f4080bdcc 100644 |
| --- a/chrome/browser/net/chrome_network_delegate.cc |
| +++ b/chrome/browser/net/chrome_network_delegate.cc |
| @@ -34,6 +34,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" |
| @@ -116,7 +117,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); |
| @@ -125,10 +127,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()) { |
| @@ -144,21 +142,24 @@ 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, |
|
bengr
2014/09/04 21:18:21
Put each parameter on its own line.
megjablon
2014/09/05 20:56:38
Done.
|
| received_content_length, original_content_length, |
| - request_type, profile)); |
| + request_type, profile, statistics_prefs)); |
| } |
| void RecordContentLengthHistograms( |
| @@ -254,7 +255,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), |
| + statistics_prefs_(NULL) { |
| DCHECK(enable_referrers); |
| extensions_delegate_.reset( |
| ChromeExtensionsNetworkDelegate::Create(event_router)); |
| @@ -323,6 +325,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 +821,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 (statistics_prefs_) { |
| + StoreAccumulatedContentLength(received_content_length, |
| + original_content_length, |
| + request_type, |
| + reinterpret_cast<Profile*>(profile_), |
| + statistics_prefs_); |
| + } |
| received_content_length_ += received_content_length; |
| original_content_length_ += original_content_length; |
| } |