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

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

Issue 2956703002: Adds Server Previews protocol UMA plus UMA for not accepting previews (Closed)
Patch Set: Updates from Ben's feedback Created 3 years, 6 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 465ec6cf16bb31ab35a54fef218ea4f3707994cb..83584168c9a509e14edc9e11b520895aba64cd2e 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
@@ -43,6 +43,20 @@ namespace data_reduction_proxy {
namespace {
+// Values of the UMA DataReductionProxy.Protocol.AcceptTransform histogram
+// defined in metrics/histograms/histograms.xml. This enum must remain
+// synchronized with DataReductionProxyProtocolAcceptTransformEvent in
+// tools/metrics/histograms/enums.xml.
+enum AcceptTransformEvent {
+ ACCEPT_LITE_PAGE_SENT = 0,
bengr 2017/06/28 16:45:50 How about: enum AcceptTransformEvent { LITE_PAG
dougarnett 2017/06/28 22:12:38 Done.
+ TRANSFORM_LITE_PAGE_RECEIVED = 1,
+ POLICY_EMPTY_IMAGE_RECEIVED = 2,
+ ACCEPT_EMPTY_IMAGE_SENT = 3,
+ TRANSFORM_EMPTY_IMAGE_RECEIVED = 4,
+ ACCEPT_COMPRESSED_VIDEO_SENT = 5,
bengr 2017/06/28 16:45:50 Why no VIDEO_RECEIVED?
dougarnett 2017/06/28 22:12:38 Because it is a 302 redirect to the compressed vid
+ ACCEPT_TRANSFORM_EVENT_BOUNDARY
+};
+
// Records the occurrence of |sample| in |name| histogram. UMA macros are not
// used because the |name| is not static.
void RecordNewContentLengthHistogram(const std::string& name, int64_t sample) {
@@ -165,6 +179,53 @@ void RecordContentLengthHistograms(bool lofi_low_header_added,
received_content_length);
}
+void RecordAcceptTransformEvent(AcceptTransformEvent event) {
+ UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.Protocol.AcceptTransform",
+ event, ACCEPT_TRANSFORM_EVENT_BOUNDARY);
+}
+
+void RecordAcceptTransformSentUMA(
+ const net::HttpRequestHeaders& request_headers) {
+ switch (ParseRequestTransform(request_headers)) {
+ case TRANSFORM_LITE_PAGE:
+ RecordAcceptTransformEvent(ACCEPT_LITE_PAGE_SENT);
+ break;
+ case TRANSFORM_EMPTY_IMAGE:
+ RecordAcceptTransformEvent(ACCEPT_EMPTY_IMAGE_SENT);
+ break;
+ case TRANSFORM_COMPRESS_VIDEO:
+ RecordAcceptTransformEvent(ACCEPT_COMPRESSED_VIDEO_SENT);
+ break;
+ case TRANSFORM_NONE:
+ break;
+ case TRANSFORM_PAGE_POLICIES_EMPTY_IMAGE:
+ NOTREACHED();
+ break;
+ }
+}
+
+void RecordAcceptTransformReceivedUMA(const net::URLRequest& request) {
+ net::HttpResponseHeaders* response_headers = request.response_headers();
+ if (response_headers) {
bengr 2017/06/28 16:45:50 I prefer the style: if (!response_headers) retu
dougarnett 2017/06/28 22:12:38 Done.
+ switch (ParseResponseTransform(*response_headers)) {
+ case TRANSFORM_LITE_PAGE:
+ RecordAcceptTransformEvent(TRANSFORM_LITE_PAGE_RECEIVED);
+ break;
+ case TRANSFORM_PAGE_POLICIES_EMPTY_IMAGE:
+ RecordAcceptTransformEvent(POLICY_EMPTY_IMAGE_RECEIVED);
+ break;
+ case TRANSFORM_EMPTY_IMAGE:
+ RecordAcceptTransformEvent(TRANSFORM_EMPTY_IMAGE_RECEIVED);
+ break;
+ case TRANSFORM_NONE:
+ break;
+ case TRANSFORM_COMPRESS_VIDEO:
+ NOTREACHED();
+ break;
+ }
+ }
+}
+
// Verifies that the chrome proxy related request headers are set correctly.
// |via_chrome_proxy| is true if the request is being fetched via Chrome Data
// Saver proxy.
@@ -373,6 +434,7 @@ void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal(
data_reduction_proxy_request_options_->AddRequestHeader(headers, page_id);
VerifyHttpRequestHeaders(true, *headers);
+ RecordAcceptTransformSentUMA(*headers);
}
void DataReductionProxyNetworkDelegate::OnBeforeRedirectInternal(
@@ -456,6 +518,7 @@ void DataReductionProxyNetworkDelegate::OnCompletedInternal(
CalculateAndRecordDataUsage(*request, request_type);
RecordContentLength(*request, request_type, original_content_length);
+ RecordAcceptTransformReceivedUMA(*request);
}
void DataReductionProxyNetworkDelegate::OnHeadersReceivedInternal(

Powered by Google App Engine
This is Rietveld 408576698