Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc |
similarity index 75% |
rename from components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc |
rename to components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc |
index 6395b8a68dbda37d4076accae4ea6833fd1c920d..e5d1b2d93d197fcfde1ac371145ef075371b00eb 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h" |
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" |
#include "base/bind.h" |
#include "base/callback.h" |
@@ -46,19 +46,17 @@ void RecordDataReductionProxyBypassOnNetworkError( |
int net_error) { |
if (is_primary) { |
UMA_HISTOGRAM_SPARSE_SLOWLY( |
- "DataReductionProxy.BypassOnNetworkErrorPrimary", |
- std::abs(net_error)); |
+ "DataReductionProxy.BypassOnNetworkErrorPrimary", std::abs(net_error)); |
return; |
} |
- UMA_HISTOGRAM_SPARSE_SLOWLY( |
- "DataReductionProxy.BypassOnNetworkErrorFallback", |
- std::abs(net_error)); |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("DataReductionProxy.BypassOnNetworkErrorFallback", |
+ std::abs(net_error)); |
} |
} // namespace |
// static |
-void DataReductionProxyUsageStats::RecordDataReductionProxyBypassInfo( |
+void DataReductionProxyBypassStats::RecordDataReductionProxyBypassInfo( |
bool is_primary, |
bool bypass_all, |
const net::ProxyServer& proxy_server, |
@@ -83,9 +81,9 @@ void DataReductionProxyUsageStats::RecordDataReductionProxyBypassInfo( |
} |
// static |
-void DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode( |
- bool is_primary, |
- const net::HttpResponseHeaders* headers) { |
+void DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode( |
+ bool is_primary, |
+ const net::HttpResponseHeaders* headers) { |
if (HasDataReductionProxyViaHeader(headers, NULL)) { |
// The data reduction proxy via header is present, so don't record anything. |
return; |
@@ -102,7 +100,7 @@ void DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode( |
} |
} |
-DataReductionProxyUsageStats::DataReductionProxyUsageStats( |
+DataReductionProxyBypassStats::DataReductionProxyBypassStats( |
DataReductionProxyConfig* config, |
UnreachableCallback unreachable_callback, |
const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) |
@@ -118,12 +116,13 @@ DataReductionProxyUsageStats::DataReductionProxyUsageStats( |
NetworkChangeNotifier::AddNetworkChangeObserver(this); |
}; |
-DataReductionProxyUsageStats::~DataReductionProxyUsageStats() { |
+DataReductionProxyBypassStats::~DataReductionProxyBypassStats() { |
NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
}; |
-void DataReductionProxyUsageStats::OnUrlRequestCompleted( |
- const net::URLRequest* request, bool started) { |
+void DataReductionProxyBypassStats::OnUrlRequestCompleted( |
+ const net::URLRequest* request, |
+ bool started) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DataReductionProxyTypeInfo proxy_info; |
@@ -163,18 +162,18 @@ void DataReductionProxyUsageStats::OnUrlRequestCompleted( |
} |
} |
-void DataReductionProxyUsageStats::SetBypassType( |
+void DataReductionProxyBypassStats::SetBypassType( |
DataReductionProxyBypassType type) { |
last_bypass_type_ = type; |
triggering_request_ = true; |
} |
-DataReductionProxyBypassType |
-DataReductionProxyUsageStats::GetBypassType() const { |
+DataReductionProxyBypassType DataReductionProxyBypassStats::GetBypassType() |
+ const { |
return last_bypass_type_; |
} |
-void DataReductionProxyUsageStats::RecordBytesHistograms( |
+void DataReductionProxyBypassStats::RecordBytesHistograms( |
const net::URLRequest& request, |
const BooleanPrefMember& data_reduction_proxy_enabled, |
const net::ProxyConfig& data_reduction_proxy_config) { |
@@ -183,13 +182,13 @@ void DataReductionProxyUsageStats::RecordBytesHistograms( |
RecordMissingViaHeaderBytes(request); |
} |
-void DataReductionProxyUsageStats::OnProxyFallback( |
+void DataReductionProxyBypassStats::OnProxyFallback( |
const net::ProxyServer& bypassed_proxy, |
int net_error) { |
DataReductionProxyTypeInfo data_reduction_proxy_info; |
if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() && |
data_reduction_proxy_config_->IsDataReductionProxy( |
- bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { |
+ bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { |
if (data_reduction_proxy_info.is_ssl) |
return; |
@@ -207,30 +206,29 @@ void DataReductionProxyUsageStats::OnProxyFallback( |
} |
if (!data_reduction_proxy_info.is_fallback) { |
- RecordDataReductionProxyBypassInfo( |
- true, false, bypassed_proxy, BYPASS_EVENT_TYPE_NETWORK_ERROR); |
- RecordDataReductionProxyBypassOnNetworkError( |
- true, bypassed_proxy, net_error); |
+ RecordDataReductionProxyBypassInfo(true, false, bypassed_proxy, |
+ BYPASS_EVENT_TYPE_NETWORK_ERROR); |
+ RecordDataReductionProxyBypassOnNetworkError(true, bypassed_proxy, |
+ net_error); |
} else { |
- RecordDataReductionProxyBypassInfo( |
- false, false, bypassed_proxy, BYPASS_EVENT_TYPE_NETWORK_ERROR); |
- RecordDataReductionProxyBypassOnNetworkError( |
- false, bypassed_proxy, net_error); |
+ RecordDataReductionProxyBypassInfo(false, false, bypassed_proxy, |
+ BYPASS_EVENT_TYPE_NETWORK_ERROR); |
+ RecordDataReductionProxyBypassOnNetworkError(false, bypassed_proxy, |
+ net_error); |
} |
} |
} |
-void DataReductionProxyUsageStats::OnConnectComplete( |
+void DataReductionProxyBypassStats::OnConnectComplete( |
const net::HostPortPair& proxy_server, |
int net_error) { |
if (data_reduction_proxy_config_->IsDataReductionProxy(proxy_server, NULL)) { |
- UMA_HISTOGRAM_SPARSE_SLOWLY( |
- "DataReductionProxy.HTTPConnectCompleted", |
- std::abs(net_error)); |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("DataReductionProxy.HTTPConnectCompleted", |
+ std::abs(net_error)); |
} |
} |
-void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
+void DataReductionProxyBypassStats::RecordBypassedBytesHistograms( |
const net::URLRequest& request, |
const BooleanPrefMember& data_reduction_proxy_enabled, |
const net::ProxyConfig& data_reduction_proxy_config) { |
@@ -249,7 +247,7 @@ void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
if (data_reduction_proxy_config_->WasDataReductionProxyUsed( |
&request, &data_reduction_proxy_type_info)) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::NOT_BYPASSED, |
+ DataReductionProxyBypassStats::NOT_BYPASSED, |
content_length); |
// If non-empty, |proxy_server.first| is the proxy that this request used. |
@@ -264,8 +262,7 @@ void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
} |
if (request.url().SchemeIs(url::kHttpsScheme)) { |
- RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::SSL, |
+ RecordBypassedBytes(last_bypass_type_, DataReductionProxyBypassStats::SSL, |
content_length); |
return; |
} |
@@ -276,7 +273,7 @@ void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
DCHECK(!data_reduction_proxy_type_info.proxy_servers.first.is_valid()); |
if (!request.proxy_server().IsEmpty()) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::PROXY_OVERRIDDEN, |
+ DataReductionProxyBypassStats::PROXY_OVERRIDDEN, |
content_length); |
return; |
} |
@@ -284,33 +281,32 @@ void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
if (data_reduction_proxy_config_->IsBypassedByDataReductionProxyLocalRules( |
request, data_reduction_proxy_config)) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, |
+ DataReductionProxyBypassStats::LOCAL_BYPASS_RULES, |
content_length); |
return; |
} |
// Only record separate triggering request UMA for short, medium, and long |
// bypass events. |
- if (triggering_request_ && |
- (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT || |
- last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM || |
- last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) { |
+ if (triggering_request_ && (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT || |
+ last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM || |
+ last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) { |
std::string mime_type; |
request.GetMimeType(&mime_type); |
// MIME types are named by <media-type>/<subtype>. Check to see if the |
// media type is audio or video. Only record when triggered by short bypass, |
// there isn't an audio or video bucket for medium or long bypasses. |
- if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT && |
- (mime_type.compare(0, 6, "audio/") == 0 || |
- mime_type.compare(0, 6, "video/") == 0)) { |
+ if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT && |
+ (mime_type.compare(0, 6, "audio/") == 0 || |
+ mime_type.compare(0, 6, "video/") == 0)) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::AUDIO_VIDEO, |
+ DataReductionProxyBypassStats::AUDIO_VIDEO, |
content_length); |
return; |
} |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::TRIGGERING_REQUEST, |
+ DataReductionProxyBypassStats::TRIGGERING_REQUEST, |
content_length); |
triggering_request_ = false; |
return; |
@@ -318,20 +314,20 @@ void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( |
if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, |
+ DataReductionProxyBypassStats::BYPASSED_BYTES_TYPE_MAX, |
content_length); |
return; |
} |
if (data_reduction_proxy_config_->AreDataReductionProxiesBypassed( |
- request, data_reduction_proxy_config, NULL)) { |
+ request, data_reduction_proxy_config, NULL)) { |
RecordBypassedBytes(last_bypass_type_, |
- DataReductionProxyUsageStats::NETWORK_ERROR, |
+ DataReductionProxyBypassStats::NETWORK_ERROR, |
content_length); |
} |
} |
-void DataReductionProxyUsageStats::RecordMissingViaHeaderBytes( |
+void DataReductionProxyBypassStats::RecordMissingViaHeaderBytes( |
const URLRequest& request) { |
// Responses that were served from cache should have been filtered out |
// already. |
@@ -356,72 +352,70 @@ void DataReductionProxyUsageStats::RecordMissingViaHeaderBytes( |
} |
} |
-void DataReductionProxyUsageStats::OnNetworkChanged( |
+void DataReductionProxyBypassStats::OnNetworkChanged( |
NetworkChangeNotifier::ConnectionType type) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
ClearRequestCounts(); |
} |
-void DataReductionProxyUsageStats::ClearRequestCounts() { |
+void DataReductionProxyBypassStats::ClearRequestCounts() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
successful_requests_through_proxy_count_ = 0; |
proxy_net_errors_count_ = 0; |
} |
-void DataReductionProxyUsageStats::NotifyUnavailabilityIfChanged() { |
+void DataReductionProxyBypassStats::NotifyUnavailabilityIfChanged() { |
bool prev_unavailable = unavailable_; |
unavailable_ = |
(proxy_net_errors_count_ >= kMinFailedRequestsWhenUnavailable && |
- successful_requests_through_proxy_count_ <= |
- kMaxSuccessfulRequestsWhenUnavailable); |
+ successful_requests_through_proxy_count_ <= |
+ kMaxSuccessfulRequestsWhenUnavailable); |
if (prev_unavailable != unavailable_) { |
- ui_task_runner_->PostTask(FROM_HERE, base::Bind( |
- &DataReductionProxyUsageStats::NotifyUnavailabilityOnUIThread, |
- base::Unretained(this), |
- unavailable_)); |
+ ui_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ &DataReductionProxyBypassStats::NotifyUnavailabilityOnUIThread, |
+ base::Unretained(this), unavailable_)); |
} |
} |
-void DataReductionProxyUsageStats::NotifyUnavailabilityOnUIThread( |
+void DataReductionProxyBypassStats::NotifyUnavailabilityOnUIThread( |
bool unavailable) { |
DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
unreachable_callback_.Run(unavailable); |
} |
-void DataReductionProxyUsageStats::RecordBypassedBytes( |
+void DataReductionProxyBypassStats::RecordBypassedBytes( |
DataReductionProxyBypassType bypass_type, |
- DataReductionProxyUsageStats::BypassedBytesType bypassed_bytes_type, |
+ DataReductionProxyBypassStats::BypassedBytesType bypassed_bytes_type, |
int64 content_length) { |
// Individual histograms are needed to count the bypassed bytes for each |
// bypass type so that we can see the size of requests. This helps us |
// remove outliers that would skew the sum of bypassed bytes for each type. |
switch (bypassed_bytes_type) { |
- case DataReductionProxyUsageStats::NOT_BYPASSED: |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.NotBypassed", content_length); |
+ case DataReductionProxyBypassStats::NOT_BYPASSED: |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.NotBypassed", |
+ content_length); |
break; |
- case DataReductionProxyUsageStats::SSL: |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.SSL", content_length); |
+ case DataReductionProxyBypassStats::SSL: |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.SSL", |
+ content_length); |
break; |
- case DataReductionProxyUsageStats::LOCAL_BYPASS_RULES: |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.LocalBypassRules", |
- content_length); |
+ case DataReductionProxyBypassStats::LOCAL_BYPASS_RULES: |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.LocalBypassRules", |
+ content_length); |
break; |
- case DataReductionProxyUsageStats::PROXY_OVERRIDDEN: |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.ProxyOverridden", |
- content_length); |
+ case DataReductionProxyBypassStats::PROXY_OVERRIDDEN: |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ProxyOverridden", |
+ content_length); |
break; |
- case DataReductionProxyUsageStats::AUDIO_VIDEO: |
+ case DataReductionProxyBypassStats::AUDIO_VIDEO: |
if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) { |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.ShortAudioVideo", |
- content_length); |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ShortAudioVideo", |
+ content_length); |
} |
break; |
- case DataReductionProxyUsageStats::TRIGGERING_REQUEST: |
+ case DataReductionProxyBypassStats::TRIGGERING_REQUEST: |
switch (bypass_type) { |
case BYPASS_EVENT_TYPE_SHORT: |
UMA_HISTOGRAM_COUNTS( |
@@ -442,12 +436,11 @@ void DataReductionProxyUsageStats::RecordBypassedBytes( |
break; |
} |
break; |
- case DataReductionProxyUsageStats::NETWORK_ERROR: |
- UMA_HISTOGRAM_COUNTS( |
- "DataReductionProxy.BypassedBytes.NetworkErrorOther", |
- content_length); |
+ case DataReductionProxyBypassStats::NETWORK_ERROR: |
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.NetworkErrorOther", |
+ content_length); |
break; |
- case DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX: |
+ case DataReductionProxyBypassStats::BYPASSED_BYTES_TYPE_MAX: |
switch (bypass_type) { |
case BYPASS_EVENT_TYPE_CURRENT: |
UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Current", |
@@ -478,7 +471,7 @@ void DataReductionProxyUsageStats::RecordBypassedBytes( |
case BYPASS_EVENT_TYPE_MALFORMED_407: |
UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Malformed407", |
content_length); |
- break; |
+ break; |
case BYPASS_EVENT_TYPE_STATUS_500_HTTP_INTERNAL_SERVER_ERROR: |
UMA_HISTOGRAM_COUNTS( |
"DataReductionProxy.BypassedBytes." |
@@ -504,5 +497,3 @@ void DataReductionProxyUsageStats::RecordBypassedBytes( |
} |
} // namespace data_reduction_proxy |
- |
- |