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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc

Issue 390533003: Bypassed Bytes UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Addressed bengr comments" Created 6 years, 5 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/browser/data_reduction_proxy_usage_stats.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
index 61a26f2cfd7dcf2cc39ef58da66b5ce04fbda096..a52dd8d5880318c800849200c352af6034aa560d 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/metrics/histogram.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
+#include "net/base/net_errors.h"
#include "net/proxy/proxy_retry_info.h"
#include "net/proxy/proxy_server.h"
#include "net/proxy/proxy_service.h"
@@ -11,6 +13,7 @@
using base::MessageLoopProxy;
using net::HostPortPair;
using net::ProxyServer;
+using net::ProxyService;
using net::NetworkChangeNotifier;
namespace data_reduction_proxy {
@@ -20,6 +23,8 @@ DataReductionProxyUsageStats::DataReductionProxyUsageStats(
MessageLoopProxy* ui_thread_proxy,
MessageLoopProxy* io_thread_proxy)
: data_reduction_proxy_params_(params),
+ bypass_type_(ProxyService::BYPASS_EVENT_TYPE_MAX),
+ triggering_request_(true),
ui_thread_proxy_(ui_thread_proxy),
io_thread_proxy_(io_thread_proxy),
eligible_num_requests_through_proxy_(0),
@@ -93,6 +98,143 @@ void DataReductionProxyUsageStats::ClearRequestCountsOnUiThread() {
actual_num_requests_through_proxy_ = 0;
}
+void DataReductionProxyUsageStats::SetBypassType(
+ net::ProxyService::DataReductionProxyBypassType type) {
+ bypass_type_ = type;
+ triggering_request_ = true;
+}
+
+void DataReductionProxyUsageStats::RecordBypassedBytesHistograms(
+ const int64 content_length,
+ const net::URLRequest* request) {
+ if (data_reduction_proxy_params_->WasDataReductionProxyUsed(request, NULL)) {
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.NotBypassed", content_length);
+ return;
+ }
+
+ if (request->url().SchemeIs("https")) {
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.SSL", content_length);
+ return;
+ }
+
+ LOG(WARNING) << "Data Reduction Eligible: "
+ << data_reduction_proxy_params_->IsDataReductionProxyEligible(request);
+ if (!data_reduction_proxy_params_->IsDataReductionProxyEligible(request)) {
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.LocalBypassRules", content_length);
+ return;
+ }
+
+ if (triggering_request_) {
+ RecordTriggeringRequestBypassedBytes(bypass_type_, content_length);
+ triggering_request_ = false;
+ }
+
+ if (bypass_type_ ==
+ ProxyService::DataReductionProxyBypassType::SHORT_BYPASS) {
+ std::string mime_type;
+ request->GetMimeType(&mime_type);
+ // MIME types are named by <media-type>/<subtype>. We check to see if the
+ // media type is audio or video.
+ if((mime_type).find("audio/") != string::npos ||
+ (mime_type).find("video/") != string::npos) {
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ShortAudioVideo",
+ content_length);
+ }
+ }
+
+ RecordBypassedBytes(bypass_type_, content_length);
+}
+
+void DataReductionProxyUsageStats::RecordTriggeringRequestBypassedBytes(
+ ProxyService::DataReductionProxyBypassType bypass_type,
+ int64 content_length) {
+ switch(bypass_type) {
+ case ProxyService::DataReductionProxyBypassType::SHORT_BYPASS:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.ShortTriggeringRequest",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::MEDIUM_BYPASS:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.MediumTriggeringRequest",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::LONG_BYPASS:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.LongTriggeringRequest",
+ content_length);
+ break;
+ default:
+ break;
+ }
+}
+
+void DataReductionProxyUsageStats::RecordBypassedBytes(
+ ProxyService::DataReductionProxyBypassType bypass_type,
+ int64 content_length) {
+ switch(bypass_type) {
+ case ProxyService::DataReductionProxyBypassType::CURRENT_BYPASS:
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Current",
bengr 2014/07/14 22:04:30 Why did you shift all of these?
megjablon 2014/07/15 18:02:50 That was not intentional. I have no idea how that
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::SHORT_BYPASS:
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ShortAll",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::MEDIUM_BYPASS:
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.MediumAll",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::LONG_BYPASS:
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.LongAll",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::MISSING_VIA_HEADER_4XX:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.MissingViaHeader4xx",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType
+ ::MISSING_VIA_HEADER_OTHER:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.MissingViaHeaderOther",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType::MALFORMED_407:
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Malformed407",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType
+ ::STATUS_500_HTTP_INTERNAL_SERVER_ERROR:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes."
+ "Status500HttpInternalServerError",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType
+ ::STATUS_502_HTTP_BAD_GATEWAY:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.Status502HttpBadGateway",
+ content_length);
+ break;
+ case ProxyService::DataReductionProxyBypassType
+ ::STATUS_503_HTTP_SERVICE_UNAVAILABLE:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes."
+ "Status503HttpServiceUnavailable",
+ content_length);
+ break;
+ default:
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.BypassedBytes.NetworkErrorOther",
+ content_length);
+ break;
+ }
+}
+
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698