Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc

Issue 2804113004: Add UMA to break down data usage by http/https and video/non_video (Closed)
Patch Set: fix erroneous UMA in unit test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
index c336696ce2d7655e141d41d1d2131656b9e264fe..a6e5a123fc55d54629fbcab87d0d26ab4ba8884f 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
@@ -23,6 +23,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.h"
#include "components/data_reduction_proxy/core/common/lofi_decider.h"
#include "net/base/load_flags.h"
+#include "net/base/mime_util.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/nqe/network_quality_estimator.h"
@@ -46,27 +47,31 @@ namespace {
// |freshness_lifetime| contains information on how long the resource will be
// fresh for and how long is the usability.
void RecordContentLengthHistograms(bool lofi_low_header_added,
+ bool is_https_request,
+ bool is_video,
int64_t received_content_length,
int64_t original_content_length,
const base::TimeDelta& freshness_lifetime) {
// Add the current resource to these histograms only when a valid
// X-Original-Content-Length header is present.
if (original_content_length >= 0) {
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL",
- received_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL",
- original_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifferenceWithValidOCL",
- original_content_length - received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthWithValidOCL",
+ received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpOriginalContentLengthWithValidOCL",
+ original_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthDifferenceWithValidOCL",
+ original_content_length - received_content_length);
// Populate Lo-Fi content length histograms.
if (lofi_low_header_added) {
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL.LoFiOn",
- received_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL.LoFiOn",
- original_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifferenceWithValidOCL.LoFiOn",
- original_content_length - received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthWithValidOCL.LoFiOn",
+ received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M(
+ "Net.HttpOriginalContentLengthWithValidOCL.LoFiOn",
+ original_content_length);
+ UMA_HISTOGRAM_COUNTS_1M(
+ "Net.HttpContentLengthDifferenceWithValidOCL.LoFiOn",
+ original_content_length - received_content_length);
}
} else {
@@ -74,11 +79,22 @@ void RecordContentLengthHistograms(bool lofi_low_header_added,
// length if the X-Original-Content-Header is not present.
original_content_length = received_content_length;
}
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLength", received_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLength",
- original_content_length);
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifference",
- original_content_length - received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLength", received_content_length);
+ if (is_https_request) {
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLength_Https",
+ received_content_length);
+ } else {
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLength_Http",
+ received_content_length);
+ }
+ if (is_video) {
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLength_Video",
+ received_content_length);
+ }
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpOriginalContentLength",
+ original_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthDifference",
+ original_content_length - received_content_length);
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.HttpContentFreshnessLifetime",
freshness_lifetime.InSeconds(),
base::TimeDelta::FromHours(1).InSeconds(),
@@ -86,17 +102,17 @@ void RecordContentLengthHistograms(bool lofi_low_header_added,
100);
if (freshness_lifetime.InSeconds() <= 0)
return;
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable",
- received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthCacheable",
+ received_content_length);
if (freshness_lifetime.InHours() < 4)
return;
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable4Hours",
- received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthCacheable4Hours",
+ received_content_length);
if (freshness_lifetime.InHours() < 24)
return;
- UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable24Hours",
- received_content_length);
+ UMA_HISTOGRAM_COUNTS_1M("Net.HttpContentLengthCacheable24Hours",
+ received_content_length);
}
// Given a |request| that went through the Data Reduction Proxy, this function
@@ -448,12 +464,21 @@ void DataReductionProxyNetworkDelegate::RecordContentLength(
->GetFreshnessLifetimes(request.response_info().response_time)
.freshness;
+ bool is_https_request = request.url().SchemeIs("https");
+ bool is_video_response = false;
+ if (request.response_headers()) {
+ std::string mime_type;
+ request.response_headers()->GetMimeType(&mime_type);
sclittle 2017/04/11 20:36:11 nit: GetMimeType() returns a bool, you could reorg
ajo1 2017/04/11 23:08:49 Used the boolean, but organized it in a way that f
+ is_video_response = net::MatchesMimeType("video/*", mime_type);
+ }
+
RecordContentLengthHistograms(
// |data_reduction_proxy_io_data_| can be NULL for Webview.
data_reduction_proxy_io_data_ &&
data_reduction_proxy_io_data_->IsEnabled() &&
data_reduction_proxy_io_data_->lofi_decider() &&
data_reduction_proxy_io_data_->lofi_decider()->IsUsingLoFi(request),
+ is_https_request, is_video_response,
request.received_response_content_length(), original_content_length,
freshness_lifetime);

Powered by Google App Engine
This is Rietveld 408576698