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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram.h"
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h" 6 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h"
7 #include "net/base/net_errors.h"
6 #include "net/proxy/proxy_retry_info.h" 8 #include "net/proxy/proxy_retry_info.h"
7 #include "net/proxy/proxy_server.h" 9 #include "net/proxy/proxy_server.h"
8 #include "net/proxy/proxy_service.h" 10 #include "net/proxy/proxy_service.h"
9 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
10 12
11 using base::MessageLoopProxy; 13 using base::MessageLoopProxy;
12 using net::HostPortPair; 14 using net::HostPortPair;
13 using net::ProxyServer; 15 using net::ProxyServer;
16 using net::ProxyService;
14 using net::NetworkChangeNotifier; 17 using net::NetworkChangeNotifier;
15 18
16 namespace data_reduction_proxy { 19 namespace data_reduction_proxy {
17 20
18 DataReductionProxyUsageStats::DataReductionProxyUsageStats( 21 DataReductionProxyUsageStats::DataReductionProxyUsageStats(
19 DataReductionProxyParams* params, 22 DataReductionProxyParams* params,
20 MessageLoopProxy* ui_thread_proxy, 23 MessageLoopProxy* ui_thread_proxy,
21 MessageLoopProxy* io_thread_proxy) 24 MessageLoopProxy* io_thread_proxy)
22 : data_reduction_proxy_params_(params), 25 : data_reduction_proxy_params_(params),
26 bypass_type_(ProxyService::BYPASS_EVENT_TYPE_MAX),
27 triggering_request_(true),
23 ui_thread_proxy_(ui_thread_proxy), 28 ui_thread_proxy_(ui_thread_proxy),
24 io_thread_proxy_(io_thread_proxy), 29 io_thread_proxy_(io_thread_proxy),
25 eligible_num_requests_through_proxy_(0), 30 eligible_num_requests_through_proxy_(0),
26 actual_num_requests_through_proxy_(0) { 31 actual_num_requests_through_proxy_(0) {
27 NetworkChangeNotifier::AddNetworkChangeObserver(this); 32 NetworkChangeNotifier::AddNetworkChangeObserver(this);
28 }; 33 };
29 34
30 DataReductionProxyUsageStats::~DataReductionProxyUsageStats() { 35 DataReductionProxyUsageStats::~DataReductionProxyUsageStats() {
31 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 36 NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
32 }; 37 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ClearRequestCountsOnUiThread(); 91 ClearRequestCountsOnUiThread();
87 } 92 }
88 } 93 }
89 94
90 void DataReductionProxyUsageStats::ClearRequestCountsOnUiThread() { 95 void DataReductionProxyUsageStats::ClearRequestCountsOnUiThread() {
91 DCHECK(ui_thread_proxy_->BelongsToCurrentThread()); 96 DCHECK(ui_thread_proxy_->BelongsToCurrentThread());
92 eligible_num_requests_through_proxy_ = 0; 97 eligible_num_requests_through_proxy_ = 0;
93 actual_num_requests_through_proxy_ = 0; 98 actual_num_requests_through_proxy_ = 0;
94 } 99 }
95 100
101 void DataReductionProxyUsageStats::SetBypassType(
102 net::ProxyService::DataReductionProxyBypassType type) {
103 bypass_type_ = type;
104 triggering_request_ = true;
105 }
106
107 void DataReductionProxyUsageStats::RecordBypassedBytesHistograms(
108 const int64 content_length,
109 const net::URLRequest* request) {
110 if (data_reduction_proxy_params_->WasDataReductionProxyUsed(request, NULL)) {
111 UMA_HISTOGRAM_COUNTS(
112 "DataReductionProxy.BypassedBytes.NotBypassed", content_length);
113 return;
114 }
115
116 if (request->url().SchemeIs("https")) {
117 UMA_HISTOGRAM_COUNTS(
118 "DataReductionProxy.BypassedBytes.SSL", content_length);
119 return;
120 }
121
122 LOG(WARNING) << "Data Reduction Eligible: "
bengr 2014/07/12 00:11:59 Remove this logging.
megjablon 2014/07/14 19:06:41 Done.
123 << data_reduction_proxy_params_->IsDataReductionProxyEligible(request);
124 if (!data_reduction_proxy_params_->IsDataReductionProxyEligible(request)) {
125 UMA_HISTOGRAM_COUNTS(
bengr 2014/07/14 17:44:03 Can you move all of your UMA into RecordBypassedBy
megjablon 2014/07/14 19:06:41 Should I do this by adding parameter bool is_local
bengr 2014/07/14 22:04:29 I was thinking the former, I think. The RecordBypa
126 "DataReductionProxy.BypassedBytes.LocalBypassRules", content_length);
127 return;
128 }
129
130 if (triggering_request_) {
131 RecordTriggeringRequestBypassedBytes(bypass_type_, content_length);
132 triggering_request_ = false;
133 }
134
135 if (bypass_type_ ==
136 ProxyService::DataReductionProxyBypassType::SHORT_BYPASS) {
137 string* mime_type = new string();
bengr 2014/07/12 00:11:59 std::string and don't new(). std::string mime_typ
megjablon 2014/07/14 19:06:41 Done.
138 request->GetMimeType(mime_type);
139 if((*mime_type).find("audio/") != string::npos ||
bengr 2014/07/12 00:11:59 Add comment that describes how you know that audio
megjablon 2014/07/14 19:06:41 Done.
140 (*mime_type).find("video/") != string::npos) {
141 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ShortAudioVideo",
bengr 2014/07/14 17:44:03 Can you move all of your UMA into RecordBypassedBy
142 content_length);
143 }
144 }
145
146 RecordBypassedBytes(bypass_type_, content_length);
147 }
148
149 void DataReductionProxyUsageStats::RecordTriggeringRequestBypassedBytes(
bengr 2014/07/14 17:44:03 Can you move all of your UMA into RecordBypassedBy
150 ProxyService::DataReductionProxyBypassType bypass_type,
151 int64 content_length) {
152 switch(bypass_type) {
153 case ProxyService::DataReductionProxyBypassType::SHORT_BYPASS:
154 UMA_HISTOGRAM_COUNTS(
155 "DataReductionProxy.BypassedBytes.ShortTriggeringRequest",
156 content_length);
157 break;
158 case ProxyService::DataReductionProxyBypassType::MEDIUM_BYPASS:
159 UMA_HISTOGRAM_COUNTS(
160 "DataReductionProxy.BypassedBytes.MediumTriggeringRequest",
161 content_length);
162 break;
163 case ProxyService::DataReductionProxyBypassType::LONG_BYPASS:
164 UMA_HISTOGRAM_COUNTS(
165 "DataReductionProxy.BypassedBytes.LongTriggeringRequest",
166 content_length);
167 break;
168 default:
169 break;
170 }
171 }
172
173 void DataReductionProxyUsageStats::RecordBypassedBytes(
174 ProxyService::DataReductionProxyBypassType bypass_type,
175 int64 content_length) {
176 switch(bypass_type) {
177 case ProxyService::DataReductionProxyBypassType::CURRENT_BYPASS:
178 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Current",
179 content_length);
180 break;
181 case ProxyService::DataReductionProxyBypassType::SHORT_BYPASS:
182 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.ShortAll",
183 content_length);
184 break;
185 case ProxyService::DataReductionProxyBypassType::MEDIUM_BYPASS:
186 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.MediumAll",
187 content_length);
188 break;
189 case ProxyService::DataReductionProxyBypassType::LONG_BYPASS:
190 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.LongAll",
191 content_length);
192 break;
193 case ProxyService::DataReductionProxyBypassType::MISSING_VIA_HEADER_4XX:
194 UMA_HISTOGRAM_COUNTS(
195 "DataReductionProxy.BypassedBytes.MissingViaHeader4xx",
196 content_length);
197 break;
198 case ProxyService::DataReductionProxyBypassType::MISSING_VIA_HEADER_OTHER:
199 UMA_HISTOGRAM_COUNTS(
200 "DataReductionProxy.BypassedBytes.MissingViaHeaderOther",
201 content_length);
202 break;
203 case ProxyService::DataReductionProxyBypassType::MALFORMED_407:
204 UMA_HISTOGRAM_COUNTS("DataReductionProxy.BypassedBytes.Malformed407",
205 content_length);
206 break;
207 case ProxyService::DataReductionProxyBypassType
208 ::STATUS_500_HTTP_INTERNAL_SERVER_ERROR:
209 UMA_HISTOGRAM_COUNTS(
210 "DataReductionProxy.BypassedBytes.Status500HTTPInternalServerError",
211 content_length);
212 break;
213 case ProxyService::DataReductionProxyBypassType
214 ::STATUS_502_HTTP_BAD_GATEWAY:
215 UMA_HISTOGRAM_COUNTS(
216 "DataReductionProxy.BypassedBytes.Status502HTTPBadGateway",
217 content_length);
218 break;
219 case ProxyService::DataReductionProxyBypassType
220 ::STATUS_503_HTTP_SERVICE_UNAVAILABLE:
221 UMA_HISTOGRAM_COUNTS(
222 "DataReductionProxy.BypassedBytes.Status503HTTPServiceUnavailable",
223 content_length);
224 break;
225 default:
226 UMA_HISTOGRAM_COUNTS(
227 "DataReductionProxy.BypassedBytes.NetworkErrorOther",
228 content_length);
229 }
230 }
231
96 } // namespace data_reduction_proxy 232 } // namespace data_reduction_proxy
97 233
98 234
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698