Chromium Code Reviews| Index: components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
| diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
| index 09f5d2c43e7eccfa675c5a80a891d85f887d288c..1a776904c305a352907c74ef779259f13bfbc642 100644 |
| --- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
| +++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
| @@ -93,7 +93,6 @@ DataReductionProxySettings::DataReductionProxySettings( |
| disabled_on_vpn_(false), |
| unreachable_(false), |
| prefs_(NULL), |
| - local_state_prefs_(NULL), |
| url_request_context_getter_(NULL), |
| configurator_(NULL) { |
| DCHECK(params); |
| @@ -123,14 +122,11 @@ void DataReductionProxySettings::InitPrefMembers() { |
| void DataReductionProxySettings::InitDataReductionProxySettings( |
| PrefService* prefs, |
| - PrefService* local_state_prefs, |
| net::URLRequestContextGetter* url_request_context_getter) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK(prefs); |
| - DCHECK(local_state_prefs); |
| DCHECK(url_request_context_getter); |
| prefs_ = prefs; |
| - local_state_prefs_ = local_state_prefs; |
| url_request_context_getter_ = url_request_context_getter; |
| InitPrefMembers(); |
| RecordDataReductionInit(); |
| @@ -148,15 +144,18 @@ void DataReductionProxySettings::InitDataReductionProxySettings( |
| void DataReductionProxySettings::InitDataReductionProxySettings( |
| PrefService* prefs, |
| - PrefService* local_state_prefs, |
| net::URLRequestContextGetter* url_request_context_getter, |
| DataReductionProxyConfigurator* configurator) { |
| InitDataReductionProxySettings(prefs, |
| - local_state_prefs, |
| url_request_context_getter); |
| SetProxyConfigurator(configurator); |
| } |
| +void DataReductionProxySettings::SetDataReductionProxyStatisticsPrefs( |
| + DataReductionProxyStatisticsPrefs* statistics_prefs) { |
| + statistics_prefs_ = statistics_prefs; |
| +} |
| + |
| void DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
| const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) { |
| on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled; |
| @@ -208,9 +207,10 @@ void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled( |
| int64 DataReductionProxySettings::GetDataReductionLastUpdateTime() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - PrefService* local_state = GetLocalStatePrefs(); |
| + if (!statistics_prefs_) |
| + return 0; |
|
bengr
2014/09/04 21:18:21
What's the significance of 0?
megjablon
2014/09/05 20:56:40
Fixed as discussed offline.
|
| int64 last_update_internal = |
| - local_state->GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate); |
| + statistics_prefs_->GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate); |
| base::Time last_update = base::Time::FromInternalValue(last_update_internal); |
| return static_cast<int64>(last_update.ToJsTime()); |
| } |
| @@ -305,11 +305,6 @@ PrefService* DataReductionProxySettings::GetOriginalProfilePrefs() { |
| return prefs_; |
| } |
| -PrefService* DataReductionProxySettings::GetLocalStatePrefs() { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| - return local_state_prefs_; |
| -} |
| - |
| void DataReductionProxySettings::AddDefaultProxyBypassRules() { |
| // localhost |
| DCHECK(configurator_); |
| @@ -373,11 +368,12 @@ void DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange() { |
| void DataReductionProxySettings::ResetDataReductionStatistics() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - PrefService* prefs = GetLocalStatePrefs(); |
| - if (!prefs) |
| + if (!statistics_prefs_) |
| return; |
| - ListPrefUpdate original_update(prefs, prefs::kDailyHttpOriginalContentLength); |
| - ListPrefUpdate received_update(prefs, prefs::kDailyHttpReceivedContentLength); |
| + base::ListValue* original_update = |
| + statistics_prefs_->GetList(prefs::kDailyHttpOriginalContentLength); |
| + base::ListValue* received_update = |
| + statistics_prefs_->GetList(prefs::kDailyHttpReceivedContentLength); |
| original_update->Clear(); |
| received_update->Clear(); |
| for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
| @@ -482,7 +478,10 @@ DataReductionProxySettings::ContentLengthList |
| DataReductionProxySettings::GetDailyContentLengths(const char* pref_name) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DataReductionProxySettings::ContentLengthList content_lengths; |
| - const base::ListValue* list_value = GetLocalStatePrefs()->GetList(pref_name); |
| + if (!statistics_prefs_) { |
|
bengr
2014/09/04 21:18:21
Is there no way to just ensure that this function
megjablon
2014/09/05 20:56:40
These are only called by JNI calls for Android chr
|
| + return content_lengths; |
| + } |
| + const base::ListValue* list_value = statistics_prefs_->GetList(pref_name); |
| if (list_value->GetSize() == kNumDaysInHistory) { |
| for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
| content_lengths.push_back(GetInt64PrefValue(*list_value, i)); |
| @@ -498,8 +497,7 @@ void DataReductionProxySettings::GetContentLengths( |
| int64* last_update_time) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK_LE(days, kNumDaysInHistory); |
| - PrefService* local_state = GetLocalStatePrefs(); |
| - if (!local_state) { |
| + if (!statistics_prefs_) { |
| *original_content_length = 0L; |
| *received_content_length = 0L; |
| *last_update_time = 0L; |
| @@ -507,9 +505,9 @@ void DataReductionProxySettings::GetContentLengths( |
| } |
| const base::ListValue* original_list = |
| - local_state->GetList(prefs::kDailyHttpOriginalContentLength); |
| + statistics_prefs_->GetList(prefs::kDailyHttpOriginalContentLength); |
| const base::ListValue* received_list = |
| - local_state->GetList(prefs::kDailyHttpReceivedContentLength); |
| + statistics_prefs_->GetList(prefs::kDailyHttpReceivedContentLength); |
| if (original_list->GetSize() != kNumDaysInHistory || |
| received_list->GetSize() != kNumDaysInHistory) { |
| @@ -530,7 +528,7 @@ void DataReductionProxySettings::GetContentLengths( |
| *original_content_length = orig; |
| *received_content_length = recv; |
| *last_update_time = |
| - local_state->GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate); |
| + statistics_prefs_->GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate); |
| } |
| net::URLFetcher* DataReductionProxySettings::GetBaseURLFetcher( |