OLD | NEW |
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/core/browser/data_reduction_proxy_bypa
ss_stats.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } else { | 93 } else { |
94 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypeFallback", | 94 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypeFallback", |
95 bypass_type, BYPASS_EVENT_TYPE_MAX); | 95 bypass_type, BYPASS_EVENT_TYPE_MAX); |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 void DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode( | 101 void DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode( |
102 bool is_primary, | 102 bool is_primary, |
103 const net::HttpResponseHeaders* headers) { | 103 const net::HttpResponseHeaders& headers) { |
104 if (HasDataReductionProxyViaHeader(headers, NULL)) { | 104 if (HasDataReductionProxyViaHeader(headers, nullptr)) { |
105 // The data reduction proxy via header is present, so don't record anything. | 105 // The data reduction proxy via header is present, so don't record anything. |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 if (is_primary) { | 109 if (is_primary) { |
110 UMA_HISTOGRAM_SPARSE_SLOWLY( | 110 UMA_HISTOGRAM_SPARSE_SLOWLY( |
111 "DataReductionProxy.MissingViaHeader.ResponseCode.Primary", | 111 "DataReductionProxy.MissingViaHeader.ResponseCode.Primary", |
112 headers->response_code()); | 112 headers.response_code()); |
113 } else { | 113 } else { |
114 UMA_HISTOGRAM_SPARSE_SLOWLY( | 114 UMA_HISTOGRAM_SPARSE_SLOWLY( |
115 "DataReductionProxy.MissingViaHeader.ResponseCode.Fallback", | 115 "DataReductionProxy.MissingViaHeader.ResponseCode.Fallback", |
116 headers->response_code()); | 116 headers.response_code()); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 DataReductionProxyBypassStats::DataReductionProxyBypassStats( | 120 DataReductionProxyBypassStats::DataReductionProxyBypassStats( |
121 DataReductionProxyConfig* config, | 121 DataReductionProxyConfig* config, |
122 UnreachableCallback unreachable_callback) | 122 UnreachableCallback unreachable_callback) |
123 : data_reduction_proxy_config_(config), | 123 : data_reduction_proxy_config_(config), |
124 unreachable_callback_(unreachable_callback), | 124 unreachable_callback_(unreachable_callback), |
125 last_bypass_type_(BYPASS_EVENT_TYPE_MAX), | 125 last_bypass_type_(BYPASS_EVENT_TYPE_MAX), |
126 triggering_request_(true), | 126 triggering_request_(true), |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 void DataReductionProxyBypassStats::RecordMissingViaHeaderBytes( | 379 void DataReductionProxyBypassStats::RecordMissingViaHeaderBytes( |
380 const net::URLRequest& request) { | 380 const net::URLRequest& request) { |
381 DCHECK(thread_checker_.CalledOnValidThread()); | 381 DCHECK(thread_checker_.CalledOnValidThread()); |
382 // Responses that were served from cache should have been filtered out | 382 // Responses that were served from cache should have been filtered out |
383 // already. | 383 // already. |
384 DCHECK(!request.was_cached()); | 384 DCHECK(!request.was_cached()); |
385 | 385 |
386 if (!data_reduction_proxy_config_->WasDataReductionProxyUsed(&request, | 386 if (!data_reduction_proxy_config_->WasDataReductionProxyUsed(&request, |
387 NULL) || | 387 NULL) || |
388 HasDataReductionProxyViaHeader(request.response_headers(), NULL)) { | 388 HasDataReductionProxyViaHeader(*request.response_headers(), NULL)) { |
389 // Only track requests that used the data reduction proxy and had responses | 389 // Only track requests that used the data reduction proxy and had responses |
390 // that were missing the data reduction proxy via header. | 390 // that were missing the data reduction proxy via header. |
391 return; | 391 return; |
392 } | 392 } |
393 | 393 |
394 if (request.GetResponseCode() >= net::HTTP_BAD_REQUEST && | 394 if (request.GetResponseCode() >= net::HTTP_BAD_REQUEST && |
395 request.GetResponseCode() < net::HTTP_INTERNAL_SERVER_ERROR) { | 395 request.GetResponseCode() < net::HTTP_INTERNAL_SERVER_ERROR) { |
396 // Track 4xx responses that are missing via headers separately. | 396 // Track 4xx responses that are missing via headers separately. |
397 UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader.Bytes.4xx", | 397 UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader.Bytes.4xx", |
398 request.received_response_content_length()); | 398 request.received_response_content_length()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 UMA_HISTOGRAM_COUNTS( | 530 UMA_HISTOGRAM_COUNTS( |
531 "DataReductionProxy.BypassedBytes.Status502HttpBadGateway", | 531 "DataReductionProxy.BypassedBytes.Status502HttpBadGateway", |
532 content_length); | 532 content_length); |
533 break; | 533 break; |
534 case BYPASS_EVENT_TYPE_STATUS_503_HTTP_SERVICE_UNAVAILABLE: | 534 case BYPASS_EVENT_TYPE_STATUS_503_HTTP_SERVICE_UNAVAILABLE: |
535 UMA_HISTOGRAM_COUNTS( | 535 UMA_HISTOGRAM_COUNTS( |
536 "DataReductionProxy.BypassedBytes." | 536 "DataReductionProxy.BypassedBytes." |
537 "Status503HttpServiceUnavailable", | 537 "Status503HttpServiceUnavailable", |
538 content_length); | 538 content_length); |
539 break; | 539 break; |
| 540 case BYPASS_EVENT_TYPE_URL_REDIRECT_CYCLE: |
| 541 UMA_HISTOGRAM_COUNTS( |
| 542 "DataReductionProxy.BypassedBytes.URLRedirectCycle", |
| 543 content_length); |
| 544 break; |
540 default: | 545 default: |
541 break; | 546 break; |
542 } | 547 } |
543 break; | 548 break; |
544 } | 549 } |
545 } | 550 } |
546 | 551 |
547 } // namespace data_reduction_proxy | 552 } // namespace data_reduction_proxy |
OLD | NEW |