OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/prefs/pref_member.h" | 10 #include "base/prefs/pref_member.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" | 12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" | 18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" |
19 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Key of the UMA DataReductionProxy.StartupState histogram. | 23 // Key of the UMA DataReductionProxy.StartupState histogram. |
24 const char kUMAProxyStartupStateHistogram[] = | 24 const char kUMAProxyStartupStateHistogram[] = |
25 "DataReductionProxy.StartupState"; | 25 "DataReductionProxy.StartupState"; |
26 | 26 |
| 27 void RecordSettingsEnabledState( |
| 28 data_reduction_proxy::DataReductionSettingsEnabledAction action) { |
| 29 UMA_HISTOGRAM_ENUMERATION( |
| 30 "DataReductionProxy.EnabledState", action, |
| 31 data_reduction_proxy::DATA_REDUCTION_SETTINGS_ACTION_BOUNDARY); |
| 32 } |
| 33 |
27 } // namespace | 34 } // namespace |
28 | 35 |
29 namespace data_reduction_proxy { | 36 namespace data_reduction_proxy { |
30 | 37 |
31 const char kDataReductionPassThroughHeader[] = | 38 const char kDataReductionPassThroughHeader[] = |
32 "Chrome-Proxy: pass-through\nCache-Control: no-cache"; | 39 "Chrome-Proxy: pass-through\nCache-Control: no-cache"; |
33 | 40 |
34 DataReductionProxySettings::DataReductionProxySettings() | 41 DataReductionProxySettings::DataReductionProxySettings() |
35 : unreachable_(false), | 42 : unreachable_(false), |
36 deferred_initialization_(false), | 43 deferred_initialization_(false), |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // related prefs. | 254 // related prefs. |
248 if (!prefs) | 255 if (!prefs) |
249 return; | 256 return; |
250 // TODO(marq): Consider moving this so stats are wiped the first time the | 257 // TODO(marq): Consider moving this so stats are wiped the first time the |
251 // proxy settings are actually (not maybe) turned on. | 258 // proxy settings are actually (not maybe) turned on. |
252 if (spdy_proxy_auth_enabled_.GetValue() && | 259 if (spdy_proxy_auth_enabled_.GetValue() && |
253 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) { | 260 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) { |
254 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); | 261 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); |
255 ResetDataReductionStatistics(); | 262 ResetDataReductionStatistics(); |
256 } | 263 } |
| 264 if (!at_startup) { |
| 265 if (IsDataReductionProxyEnabled()) |
| 266 RecordSettingsEnabledState(DATA_REDUCTION_SETTINGS_ACTION_OFF_TO_ON); |
| 267 else |
| 268 RecordSettingsEnabledState(DATA_REDUCTION_SETTINGS_ACTION_ON_TO_OFF); |
| 269 } |
257 // Configure use of the data reduction proxy if it is enabled. | 270 // Configure use of the data reduction proxy if it is enabled. |
258 if (at_startup && !data_reduction_proxy_service_->Initialized()) | 271 if (at_startup && !data_reduction_proxy_service_->Initialized()) |
259 deferred_initialization_ = true; | 272 deferred_initialization_ = true; |
260 else | 273 else |
261 UpdateIOData(at_startup); | 274 UpdateIOData(at_startup); |
262 } | 275 } |
263 | 276 |
264 DataReductionProxyEventStore* DataReductionProxySettings::GetEventStore() | 277 DataReductionProxyEventStore* DataReductionProxySettings::GetEventStore() |
265 const { | 278 const { |
266 if (data_reduction_proxy_service_) | 279 if (data_reduction_proxy_service_) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 int64* received_content_length, | 368 int64* received_content_length, |
356 int64* last_update_time) { | 369 int64* last_update_time) { |
357 DCHECK(thread_checker_.CalledOnValidThread()); | 370 DCHECK(thread_checker_.CalledOnValidThread()); |
358 DCHECK(data_reduction_proxy_service_->compression_stats()); | 371 DCHECK(data_reduction_proxy_service_->compression_stats()); |
359 | 372 |
360 data_reduction_proxy_service_->compression_stats()->GetContentLengths( | 373 data_reduction_proxy_service_->compression_stats()->GetContentLengths( |
361 days, original_content_length, received_content_length, last_update_time); | 374 days, original_content_length, received_content_length, last_update_time); |
362 } | 375 } |
363 | 376 |
364 } // namespace data_reduction_proxy | 377 } // namespace data_reduction_proxy |
OLD | NEW |