Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_data_use_observer.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_use_observer.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_use_observer.cc |
index b7683d292a91ac57443e4759d254b7df9cccb317..3812a8d531e86d9caf96af83dd515f3250c3a7c9 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_use_observer.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_use_observer.cc |
@@ -40,6 +40,10 @@ class DataUseUserDataBytes : public base::SupportsUserData::Data { |
int64_t original_bytes_; |
}; |
+// Hostname used for the other bucket which consists of chrome-services traffic. |
+// This should be in sync with the same in DataReductionSiteBreakdownView.java |
+const char kOtherHostName[] = "Other"; |
+ |
// static |
const void* DataUseUserDataBytes::kUserDataKey = |
&DataUseUserDataBytes::kUserDataKey; |
@@ -84,16 +88,14 @@ void DataReductionProxyDataUseObserver::OnPageResourceLoad( |
data_use_measurement::DataUse* data_use) { |
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
- if (data_use->traffic_type() != |
- data_use_measurement::DataUse::TrafficType::USER_TRAFFIC) { |
- return; |
- } |
- |
if (!request.url().SchemeIs(url::kHttpsScheme) && |
!request.url().SchemeIs(url::kHttpScheme)) { |
return; |
} |
+ if (request.GetTotalReceivedBytes() <= 0) |
+ return; |
+ |
int64_t network_bytes = request.GetTotalReceivedBytes(); |
DataReductionProxyRequestType request_type = GetDataReductionProxyRequestType( |
request, data_reduction_proxy_io_data_->configurator()->GetProxyConfig(), |
@@ -105,7 +107,9 @@ void DataReductionProxyDataUseObserver::OnPageResourceLoad( |
request, request_type == VIA_DATA_REDUCTION_PROXY, |
data_reduction_proxy_io_data_->lofi_decider()); |
- if (!data_use->url().is_valid()) { |
+ if (data_use->traffic_type() == |
+ data_use_measurement::DataUse::TrafficType::USER_TRAFFIC && |
+ !data_use->url().is_valid()) { |
// URL will be empty until pageload navigation commits. Save the data use of |
// these mainframe, subresource, redirected requests in user data until |
// then. |
@@ -120,7 +124,11 @@ void DataReductionProxyDataUseObserver::OnPageResourceLoad( |
} |
} else { |
data_reduction_proxy_io_data_->UpdateDataUseForHost( |
- network_bytes, original_bytes, data_use->url().HostNoBrackets()); |
+ network_bytes, original_bytes, |
+ data_use->traffic_type() == |
+ data_use_measurement::DataUse::TrafficType::USER_TRAFFIC |
+ ? data_use->url().HostNoBrackets() |
+ : kOtherHostName); |
} |
} |