Chromium Code Reviews| 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/browser/data_reduction_proxy_settings. h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. 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/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/sparse_histogram.h" | |
| 11 #include "base/prefs/pref_member.h" | 12 #include "base/prefs/pref_member.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" | 19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" |
| 19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura tor.h" | 20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura tor.h" |
| 20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 21 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 46 CHANGE_EVENT_COUNT = 2 // This must always be last. | 47 CHANGE_EVENT_COUNT = 2 // This must always be last. |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 // Key of the UMA DataReductionProxy.StartupState histogram. | 50 // Key of the UMA DataReductionProxy.StartupState histogram. |
| 50 const char kUMAProxyStartupStateHistogram[] = | 51 const char kUMAProxyStartupStateHistogram[] = |
| 51 "DataReductionProxy.StartupState"; | 52 "DataReductionProxy.StartupState"; |
| 52 | 53 |
| 53 // Key of the UMA DataReductionProxy.ProbeURL histogram. | 54 // Key of the UMA DataReductionProxy.ProbeURL histogram. |
| 54 const char kUMAProxyProbeURL[] = "DataReductionProxy.ProbeURL"; | 55 const char kUMAProxyProbeURL[] = "DataReductionProxy.ProbeURL"; |
| 55 | 56 |
| 57 // Key of the UMA DataReductionProxy.ProbeURLNetError histogram. | |
| 58 const char kUMAProxyProbeURLNetError[] = "DataReductionProxy.ProbeURLNetError"; | |
| 59 | |
| 56 // Record a network change event. | 60 // Record a network change event. |
| 57 void RecordNetworkChangeEvent(DataReductionProxyNetworkChangeEvent event) { | 61 void RecordNetworkChangeEvent(DataReductionProxyNetworkChangeEvent event) { |
| 58 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.NetworkChangeEvents", | 62 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.NetworkChangeEvents", |
| 59 event, | 63 event, |
| 60 CHANGE_EVENT_COUNT); | 64 CHANGE_EVENT_COUNT); |
| 61 } | 65 } |
| 62 | 66 |
| 63 int64 GetInt64PrefValue(const base::ListValue& list_value, size_t index) { | 67 int64 GetInt64PrefValue(const base::ListValue& list_value, size_t index) { |
| 64 int64 val = 0; | 68 int64 val = 0; |
| 65 std::string pref_value; | 69 std::string pref_value; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 const net::URLFetcher* source) { | 231 const net::URLFetcher* source) { |
| 228 DCHECK(thread_checker_.CalledOnValidThread()); | 232 DCHECK(thread_checker_.CalledOnValidThread()); |
| 229 | 233 |
| 230 // The purpose of sending a request for the warmup URL is to warm the | 234 // The purpose of sending a request for the warmup URL is to warm the |
| 231 // connection to the data_reduction_proxy. The result is ignored. | 235 // connection to the data_reduction_proxy. The result is ignored. |
| 232 if (source == warmup_fetcher_.get()) | 236 if (source == warmup_fetcher_.get()) |
| 233 return; | 237 return; |
| 234 | 238 |
| 235 DCHECK(source == fetcher_.get()); | 239 DCHECK(source == fetcher_.get()); |
| 236 net::URLRequestStatus status = source->GetStatus(); | 240 net::URLRequestStatus status = source->GetStatus(); |
| 237 if (status.status() == net::URLRequestStatus::FAILED && | 241 if (status.status() == net::URLRequestStatus::FAILED) { |
| 238 status.error() == net::ERR_INTERNET_DISCONNECTED) { | 242 if (status.error() == net::ERR_INTERNET_DISCONNECTED) { |
| 239 RecordProbeURLFetchResult(INTERNET_DISCONNECTED); | 243 RecordProbeURLFetchResult(INTERNET_DISCONNECTED); |
| 240 return; | 244 return; |
| 245 } | |
| 246 // TODO(bengr): Remove once we understand the reasons probes are failing. | |
| 247 // Probe errors are either due to fetcher-level errors or modified | |
| 248 // responses. This only tracks the former. | |
| 249 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 250 kUMAProxyProbeURLNetError, std::abs(status.error())); | |
|
mmenke
2014/07/25 18:27:00
UMA_HISTOGRAM_CUSTOM_ENUMERATION(kUMAProxyProbeURL
Alexei Svitkine (slow)
2014/07/25 18:28:21
No, sparse histogram is better in this case, as it
| |
| 241 } | 251 } |
| 242 | 252 |
| 243 std::string response; | 253 std::string response; |
| 244 source->GetResponseAsString(&response); | 254 source->GetResponseAsString(&response); |
| 245 | 255 |
| 246 if ("OK" == response.substr(0, 2)) { | 256 if ("OK" == response.substr(0, 2)) { |
| 247 DVLOG(1) << "The data reduction proxy is unrestricted."; | 257 DVLOG(1) << "The data reduction proxy is unrestricted."; |
| 248 | 258 |
| 249 if (enabled_by_user_) { | 259 if (enabled_by_user_) { |
| 250 if (restricted_by_carrier_) { | 260 if (restricted_by_carrier_) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 SetProxyConfigs(enabled_by_user_, | 590 SetProxyConfigs(enabled_by_user_, |
| 581 IsDataReductionProxyAlternativeEnabled(), | 591 IsDataReductionProxyAlternativeEnabled(), |
| 582 restricted_by_carrier_, | 592 restricted_by_carrier_, |
| 583 false); | 593 false); |
| 584 } | 594 } |
| 585 disabled_on_vpn_ = false; | 595 disabled_on_vpn_ = false; |
| 586 return false; | 596 return false; |
| 587 } | 597 } |
| 588 | 598 |
| 589 } // namespace data_reduction_proxy | 599 } // namespace data_reduction_proxy |
| OLD | NEW |