summaryrefslogtreecommitdiff
path: root/chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc')
-rw-r--r--chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc115
1 files changed, 37 insertions, 78 deletions
diff --git a/chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc b/chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
index 39c311ae9bd..1c47b73da76 100644
--- a/chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
+++ b/chromium/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
@@ -11,6 +11,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_util.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
+#include "components/data_reduction_proxy/core/common/data_reduction_proxy_type_info.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/proxy_server.h"
@@ -119,14 +120,16 @@ void DataReductionProxyBypassStats::OnUrlRequestCompleted(
bool started,
int net_error) {
DCHECK(thread_checker_.CalledOnValidThread());
- DataReductionProxyTypeInfo proxy_info;
+
+ base::Optional<DataReductionProxyTypeInfo> proxy_info =
+ data_reduction_proxy_config_->FindConfiguredDataReductionProxy(
+ request->proxy_server());
+
// Ignore requests that did not use the data reduction proxy. The check for
// LOAD_BYPASS_PROXY is necessary because the proxy_server() in the |request|
// might still be set to the data reduction proxy if |request| was retried
// over direct and a network error occurred while retrying it.
- if (!data_reduction_proxy_config_->WasDataReductionProxyUsed(request,
- &proxy_info) ||
- (request->load_flags() & net::LOAD_BYPASS_PROXY) != 0 ||
+ if (!proxy_info || (request->load_flags() & net::LOAD_BYPASS_PROXY) != 0 ||
net_error != net::OK) {
return;
}
@@ -136,15 +139,11 @@ void DataReductionProxyBypassStats::OnUrlRequestCompleted(
// Report the success counts.
UMA_HISTOGRAM_COUNTS_100(
"DataReductionProxy.SuccessfulRequestCompletionCounts",
- proxy_info.proxy_index);
-
- DCHECK(request->proxy_server().host_port_pair().Equals(
- proxy_info.proxy_servers.front().host_port_pair()));
+ proxy_info->proxy_index);
// It is possible that the scheme of request->proxy_server() is different
// from the scheme of proxy_info.proxy_servers.front(). The former may be set
// to QUIC by the network stack, while the latter may be set to HTTPS.
-
UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.ProxySchemeUsed",
util::ConvertNetProxySchemeToProxyScheme(
request->proxy_server().scheme()),
@@ -152,8 +151,8 @@ void DataReductionProxyBypassStats::OnUrlRequestCompleted(
if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) {
UMA_HISTOGRAM_COUNTS_100(
"DataReductionProxy.SuccessfulRequestCompletionCounts.MainFrame",
- proxy_info.proxy_index);
- }
+ proxy_info->proxy_index);
+ }
}
void DataReductionProxyBypassStats::SetBypassType(
@@ -169,49 +168,37 @@ DataReductionProxyBypassStats::GetBypassType() const {
return last_bypass_type_;
}
-void DataReductionProxyBypassStats::RecordBytesHistograms(
- const net::URLRequest& request,
- bool data_reduction_proxy_enabled,
- const net::ProxyConfig& data_reduction_proxy_config) {
- DCHECK(thread_checker_.CalledOnValidThread());
- RecordBypassedBytesHistograms(request, data_reduction_proxy_enabled,
- data_reduction_proxy_config);
- RecordMissingViaHeaderBytes(request);
-}
-
void DataReductionProxyBypassStats::OnProxyFallback(
const net::ProxyServer& bypassed_proxy,
int net_error) {
DCHECK(thread_checker_.CalledOnValidThread());
- DataReductionProxyTypeInfo data_reduction_proxy_info;
- if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() &&
- data_reduction_proxy_config_->IsDataReductionProxy(
- bypassed_proxy, &data_reduction_proxy_info)) {
- proxy_net_errors_count_++;
-
- // To account for the case when the proxy is reachable for sometime, and
- // then gets blocked, we reset counts when number of errors exceed
- // the threshold.
- if (proxy_net_errors_count_ >= kMaxFailedRequestsBeforeReset &&
- successful_requests_through_proxy_count_ >
- kMaxSuccessfulRequestsWhenUnavailable) {
- ClearRequestCounts();
- } else {
- NotifyUnavailabilityIfChanged();
- }
+ if (!bypassed_proxy.is_valid() || bypassed_proxy.is_direct())
+ return;
- if (data_reduction_proxy_info.proxy_index == 0) {
- 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);
- }
+ base::Optional<DataReductionProxyTypeInfo> proxy_type_info =
+ data_reduction_proxy_config_->FindConfiguredDataReductionProxy(
+ bypassed_proxy);
+ if (!proxy_type_info)
+ return;
+
+ proxy_net_errors_count_++;
+
+ // To account for the case when the proxy is reachable for sometime, and
+ // then gets blocked, we reset counts when number of errors exceed
+ // the threshold.
+ if (proxy_net_errors_count_ >= kMaxFailedRequestsBeforeReset &&
+ successful_requests_through_proxy_count_ >
+ kMaxSuccessfulRequestsWhenUnavailable) {
+ ClearRequestCounts();
+ } else {
+ NotifyUnavailabilityIfChanged();
}
+
+ const bool is_first_proxy = proxy_type_info->proxy_index == 0U;
+ RecordDataReductionProxyBypassInfo(is_first_proxy, false, bypassed_proxy,
+ BYPASS_EVENT_TYPE_NETWORK_ERROR);
+ RecordDataReductionProxyBypassOnNetworkError(is_first_proxy, bypassed_proxy,
+ net_error);
}
void DataReductionProxyBypassStats::ClearRequestCounts() {
@@ -247,9 +234,8 @@ void DataReductionProxyBypassStats::RecordBypassedBytesHistograms(
if (!request.url().SchemeIsHTTPOrHTTPS())
return;
- DataReductionProxyTypeInfo data_reduction_proxy_type_info;
- if (data_reduction_proxy_config_->WasDataReductionProxyUsed(
- &request, &data_reduction_proxy_type_info)) {
+ if (data_reduction_proxy_config_->FindConfiguredDataReductionProxy(
+ request.proxy_server())) {
RecordBypassedBytes(last_bypass_type_,
DataReductionProxyBypassStats::NOT_BYPASSED,
content_length);
@@ -266,7 +252,6 @@ void DataReductionProxyBypassStats::RecordBypassedBytesHistograms(
// Now that the data reduction proxy is a best effort proxy, if the effective
// proxy configuration resolves to anything other than direct:// for a URL,
// the data reduction proxy will not be used.
- DCHECK(data_reduction_proxy_type_info.proxy_servers.empty());
if (!request.proxy_server().is_valid() ||
!request.proxy_server().is_direct()) {
RecordBypassedBytes(last_bypass_type_,
@@ -337,32 +322,6 @@ void DataReductionProxyBypassStats::RecordBypassedBytesHistograms(
}
}
-void DataReductionProxyBypassStats::RecordMissingViaHeaderBytes(
- const net::URLRequest& request) {
- DCHECK(thread_checker_.CalledOnValidThread());
- // Responses that were served from cache should have been filtered out
- // already.
- DCHECK(!request.was_cached());
-
- if (!data_reduction_proxy_config_->WasDataReductionProxyUsed(&request,
- nullptr) ||
- HasDataReductionProxyViaHeader(*request.response_headers(), nullptr)) {
- // Only track requests that used the data reduction proxy and had responses
- // that were missing the data reduction proxy via header.
- return;
- }
-
- if (request.GetResponseCode() >= net::HTTP_BAD_REQUEST &&
- request.GetResponseCode() < net::HTTP_INTERNAL_SERVER_ERROR) {
- // Track 4xx responses that are missing via headers separately.
- UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader.Bytes.4xx",
- request.received_response_content_length());
- } else {
- UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader.Bytes.Other",
- request.received_response_content_length());
- }
-}
-
void DataReductionProxyBypassStats::OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) {
DCHECK(thread_checker_.CalledOnValidThread());