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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc

Issue 510353004: Fixing DataReductionProxy.BypassedBytes.LocalBypassRules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing comment and adding check if proxy is enabled Created 6 years, 3 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 "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 void DataReductionProxyUsageStats::SetBypassType( 156 void DataReductionProxyUsageStats::SetBypassType(
157 DataReductionProxyBypassType type) { 157 DataReductionProxyBypassType type) {
158 last_bypass_type_ = type; 158 last_bypass_type_ = type;
159 triggering_request_ = true; 159 triggering_request_ = true;
160 } 160 }
161 161
162 void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( 162 void DataReductionProxyUsageStats::RecordBypassedBytesHistograms(
163 net::URLRequest& request, 163 net::URLRequest& request,
164 const BooleanPrefMember& data_reduction_proxy_enabled) { 164 const BooleanPrefMember& data_reduction_proxy_enabled,
165 const net::ProxyConfig& data_reduction_proxy_config) {
165 int64 content_length = request.received_response_content_length(); 166 int64 content_length = request.received_response_content_length();
167
168 if (data_reduction_proxy_enabled.GetValue()) {
169 LOG(WARNING) << "managed pac: " << (!data_reduction_proxy_config.Equals(
170 request.context()->proxy_service()->config()) ? "true" : "false");
171 }
172
173 if (data_reduction_proxy_enabled.GetValue() &&
174 !data_reduction_proxy_config.Equals(
175 request.context()->proxy_service()->config())) {
176 RecordBypassedBytes(last_bypass_type_,
177 DataReductionProxyUsageStats::MANAGED_PROXY_CONFIG,
178 content_length);
179 return;
180 }
181
166 if (data_reduction_proxy_params_->WasDataReductionProxyUsed(&request, NULL)) { 182 if (data_reduction_proxy_params_->WasDataReductionProxyUsed(&request, NULL)) {
167 RecordBypassedBytes(last_bypass_type_, 183 RecordBypassedBytes(last_bypass_type_,
168 DataReductionProxyUsageStats::NOT_BYPASSED, 184 DataReductionProxyUsageStats::NOT_BYPASSED,
169 content_length); 185 content_length);
170 return; 186 return;
171 } 187 }
172 188
173 if (data_reduction_proxy_enabled.GetValue() && 189 if (data_reduction_proxy_enabled.GetValue() &&
174 request.url().SchemeIs(url::kHttpsScheme)) { 190 request.url().SchemeIs(url::kHttpsScheme)) {
175 RecordBypassedBytes(last_bypass_type_, 191 RecordBypassedBytes(last_bypass_type_,
176 DataReductionProxyUsageStats::SSL, 192 DataReductionProxyUsageStats::SSL,
177 content_length); 193 content_length);
178 return; 194 return;
179 } 195 }
180 196
181 if (data_reduction_proxy_enabled.GetValue() && 197 if (data_reduction_proxy_enabled.GetValue() &&
182 !data_reduction_proxy_params_->IsDataReductionProxyEligible(&request)) { 198 data_reduction_proxy_params_->IsBypassedByDataReductionProxyLocalRules(
199 request, data_reduction_proxy_config)) {
183 RecordBypassedBytes(last_bypass_type_, 200 RecordBypassedBytes(last_bypass_type_,
184 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, 201 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES,
185 content_length); 202 content_length);
186 return; 203 return;
187 } 204 }
188 205
189 if (triggering_request_) { 206 if (triggering_request_) {
190 RecordBypassedBytes(last_bypass_type_,
191 DataReductionProxyUsageStats::TRIGGERING_REQUEST,
192 content_length);
193 triggering_request_ = false;
194
195 // We only record when audio or video triggers a bypass. We don't care 207 // We only record when audio or video triggers a bypass. We don't care
196 // about audio and video bypassed as collateral damage. 208 // about audio and video bypassed as collateral damage.
197 std::string mime_type; 209 std::string mime_type;
198 request.GetMimeType(&mime_type); 210 request.GetMimeType(&mime_type);
199 // MIME types are named by <media-type>/<subtype>. We check to see if the 211 // MIME types are named by <media-type>/<subtype>. We check to see if the
200 // media type is audio or video. 212 // media type is audio or video.
201 if (mime_type.compare(0, 6, "audio/") == 0 || 213 if (mime_type.compare(0, 6, "audio/") == 0 ||
202 mime_type.compare(0, 6, "video/") == 0) { 214 mime_type.compare(0, 6, "video/") == 0) {
203 RecordBypassedBytes(last_bypass_type_, 215 RecordBypassedBytes(last_bypass_type_,
204 DataReductionProxyUsageStats::AUDIO_VIDEO, 216 DataReductionProxyUsageStats::AUDIO_VIDEO,
205 content_length); 217 content_length);
218 return;
206 } 219 }
220
221 RecordBypassedBytes(last_bypass_type_,
222 DataReductionProxyUsageStats::TRIGGERING_REQUEST,
223 content_length);
224 triggering_request_ = false;
225 return;
207 } 226 }
208 227
209 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { 228 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) {
210 RecordBypassedBytes(last_bypass_type_, 229 RecordBypassedBytes(last_bypass_type_,
211 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, 230 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX,
212 content_length); 231 content_length);
213 return; 232 return;
214 } 233 }
215 234
216 if (data_reduction_proxy_params_-> 235 if (data_reduction_proxy_params_->
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 break; 277 break;
259 case DataReductionProxyUsageStats::SSL: 278 case DataReductionProxyUsageStats::SSL:
260 UMA_HISTOGRAM_COUNTS( 279 UMA_HISTOGRAM_COUNTS(
261 "DataReductionProxy.BypassedBytes.SSL", content_length); 280 "DataReductionProxy.BypassedBytes.SSL", content_length);
262 break; 281 break;
263 case DataReductionProxyUsageStats::LOCAL_BYPASS_RULES: 282 case DataReductionProxyUsageStats::LOCAL_BYPASS_RULES:
264 UMA_HISTOGRAM_COUNTS( 283 UMA_HISTOGRAM_COUNTS(
265 "DataReductionProxy.BypassedBytes.LocalBypassRules", 284 "DataReductionProxy.BypassedBytes.LocalBypassRules",
266 content_length); 285 content_length);
267 break; 286 break;
287 case DataReductionProxyUsageStats::MANAGED_PROXY_CONFIG:
288 UMA_HISTOGRAM_COUNTS(
289 "DataReductionProxy.BypassedBytes.ManagedProxyConfig",
290 content_length);
291 break;
268 case DataReductionProxyUsageStats::AUDIO_VIDEO: 292 case DataReductionProxyUsageStats::AUDIO_VIDEO:
269 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) { 293 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) {
270 UMA_HISTOGRAM_COUNTS( 294 UMA_HISTOGRAM_COUNTS(
271 "DataReductionProxy.BypassedBytes.ShortAudioVideo", 295 "DataReductionProxy.BypassedBytes.ShortAudioVideo",
272 content_length); 296 content_length);
273 } 297 }
274 break; 298 break;
275 case DataReductionProxyUsageStats::TRIGGERING_REQUEST: 299 case DataReductionProxyUsageStats::TRIGGERING_REQUEST:
276 switch (bypass_type) { 300 switch (bypass_type) {
277 case BYPASS_EVENT_TYPE_SHORT: 301 case BYPASS_EVENT_TYPE_SHORT:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 default: 374 default:
351 break; 375 break;
352 } 376 }
353 break; 377 break;
354 } 378 }
355 } 379 }
356 380
357 } // namespace data_reduction_proxy 381 } // namespace data_reduction_proxy
358 382
359 383
OLDNEW
« no previous file with comments | « components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698