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 b0c1616243cb6edd7339cdf758b32cc88d9c75b5..036f91d1e099c094b2f858bdba92a4a57dddaa8f 100644 |
| --- a/chrome/browser/net/chrome_network_delegate.cc |
| +++ b/chrome/browser/net/chrome_network_delegate.cc |
| @@ -31,6 +31,7 @@ |
| #include "chrome/browser/task_manager/task_manager.h" |
| #include "chrome/common/pref_names.h" |
| #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h" |
| +#include "components/data_reduction_proxy/browser/data_reduction_proxy_delayed_pref_service.h" |
| #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" |
| @@ -114,7 +115,8 @@ void UpdateContentLengthPrefs( |
| int received_content_length, |
| int original_content_length, |
| data_reduction_proxy::DataReductionProxyRequestType request_type, |
| - Profile* profile) { |
| + Profile* profile, |
| + data_reduction_proxy::DataReductionProxyDelayedPrefService* pref_service) { |
|
bengr
2014/08/14 17:39:41
DCHECK(pref_service)
Also, after the class renami
megjablon
2014/08/26 19:28:40
Done.
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| DCHECK_GE(received_content_length, 0); |
| DCHECK_GE(original_content_length, 0); |
| @@ -123,8 +125,7 @@ void UpdateContentLengthPrefs( |
| if (!g_browser_process) |
| return; |
| - PrefService* prefs = g_browser_process->local_state(); |
| - if (!prefs) |
| + if (!pref_service) |
|
bengr
2014/08/14 17:39:41
Why would this ever be null?
megjablon
2014/08/26 19:28:40
Done.
|
| return; |
| // Ignore off-the-record data. |
| @@ -142,21 +143,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, |
| + pref_service); |
| } |
| void StoreAccumulatedContentLength( |
| int received_content_length, |
| int original_content_length, |
| data_reduction_proxy::DataReductionProxyRequestType request_type, |
| - Profile* profile) { |
| + Profile* profile, |
| + data_reduction_proxy::DataReductionProxyDelayedPrefService* pref_service) { |
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| base::Bind(&UpdateContentLengthPrefs, |
| received_content_length, original_content_length, |
| - request_type, profile)); |
| + request_type, profile, pref_service)); |
| } |
| void RecordContentLengthHistograms( |
| @@ -252,7 +256,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_delayed_pref_service_(NULL) { |
| DCHECK(enable_referrers); |
| extensions_delegate_.reset( |
| ChromeExtensionsNetworkDelegate::Create(event_router)); |
| @@ -321,6 +326,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. |
|
bengr
2014/08/14 17:39:41
Please file a bug to fix this.
megjablon
2014/08/26 19:28:40
Done.
|
| base::Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| PrefService* prefs = g_browser_process->local_state(); |
| @@ -801,10 +808,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_delayed_pref_service_) { |
| + StoreAccumulatedContentLength(received_content_length, |
| + original_content_length, |
| + request_type, |
| + reinterpret_cast<Profile*>(profile_), |
| + data_reduction_proxy_delayed_pref_service_); |
| + } |
| received_content_length_ += received_content_length; |
| original_content_length_ += original_content_length; |
| } |