Chromium Code Reviews| 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/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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 191 |
| 192 if (data_reduction_proxy_enabled.GetValue() && | 192 if (data_reduction_proxy_enabled.GetValue() && |
| 193 data_reduction_proxy_params_->IsBypassedByDataReductionProxyLocalRules( | 193 data_reduction_proxy_params_->IsBypassedByDataReductionProxyLocalRules( |
| 194 request, data_reduction_proxy_config)) { | 194 request, data_reduction_proxy_config)) { |
| 195 RecordBypassedBytes(last_bypass_type_, | 195 RecordBypassedBytes(last_bypass_type_, |
| 196 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, | 196 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, |
| 197 content_length); | 197 content_length); |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 | 200 |
| 201 if (triggering_request_) { | 201 if (triggering_request_ && |
|
bengr
2014/09/16 01:55:05
Please add a comment here that explains why we onl
megjablon
2014/09/16 17:22:40
Done.
| |
| 202 (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT || | |
| 203 last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM || | |
| 204 last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) { | |
| 202 // We only record when audio or video triggers a bypass. We don't care | 205 // We only record when audio or video triggers a bypass. We don't care |
| 203 // about audio and video bypassed as collateral damage. | 206 // about audio and video bypassed as collateral damage. |
| 204 std::string mime_type; | 207 std::string mime_type; |
| 205 request.GetMimeType(&mime_type); | 208 request.GetMimeType(&mime_type); |
| 206 // MIME types are named by <media-type>/<subtype>. We check to see if the | 209 // MIME types are named by <media-type>/<subtype>. We check to see if the |
| 207 // media type is audio or video. | 210 // media type is audio or video. |
| 208 if (mime_type.compare(0, 6, "audio/") == 0 || | 211 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT && |
| 209 mime_type.compare(0, 6, "video/") == 0) { | 212 (mime_type.compare(0, 6, "audio/") == 0 || |
| 213 mime_type.compare(0, 6, "video/") == 0)) { | |
| 210 RecordBypassedBytes(last_bypass_type_, | 214 RecordBypassedBytes(last_bypass_type_, |
| 211 DataReductionProxyUsageStats::AUDIO_VIDEO, | 215 DataReductionProxyUsageStats::AUDIO_VIDEO, |
| 212 content_length); | 216 content_length); |
| 213 return; | 217 return; |
| 214 } | 218 } |
| 215 | 219 |
| 216 RecordBypassedBytes(last_bypass_type_, | 220 RecordBypassedBytes(last_bypass_type_, |
| 217 DataReductionProxyUsageStats::TRIGGERING_REQUEST, | 221 DataReductionProxyUsageStats::TRIGGERING_REQUEST, |
| 218 content_length); | 222 content_length); |
| 219 triggering_request_ = false; | 223 triggering_request_ = false; |
| 220 return; | 224 return; |
| 221 } | 225 } |
| 222 | 226 |
| 223 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { | 227 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { |
| 224 RecordBypassedBytes(last_bypass_type_, | 228 RecordBypassedBytes(last_bypass_type_, |
| 225 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, | 229 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, |
| 226 content_length); | 230 content_length); |
| 227 return; | 231 return; |
| 228 } | 232 } |
| 229 | 233 |
| 230 if (data_reduction_proxy_params_-> | 234 if (data_reduction_proxy_params_-> |
| 231 AreDataReductionProxiesBypassed(request, NULL)) { | 235 AreDataReductionProxiesBypassed(request, NULL)) { |
| 232 RecordBypassedBytes(last_bypass_type_, | 236 RecordBypassedBytes(last_bypass_type_, |
| 233 DataReductionProxyUsageStats::NETWORK_ERROR, | 237 DataReductionProxyUsageStats::NETWORK_ERROR, |
| 234 content_length); | 238 content_length); |
| 235 } | 239 } |
| 236 } | 240 } |
| 237 | 241 |
| 238 void DataReductionProxyUsageStats::RecordBypassEventHistograms( | 242 void DataReductionProxyUsageStats::RecordBypassEventHistograms( |
| 239 const net::ProxyServer& bypassed_proxy, | 243 const net::ProxyServer& bypassed_proxy, |
| 240 int net_error) const { | 244 int net_error) const { |
| 241 DataReductionProxyTypeInfo data_reduction_proxy_info; | 245 DataReductionProxyTypeInfo data_reduction_proxy_info; |
| 242 if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() && | 246 if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() && |
| 243 data_reduction_proxy_params_->IsDataReductionProxy( | 247 data_reduction_proxy_params_->IsDataReductionProxy( |
| 244 bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { | 248 bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 default: | 373 default: |
| 370 break; | 374 break; |
| 371 } | 375 } |
| 372 break; | 376 break; |
| 373 } | 377 } |
| 374 } | 378 } |
| 375 | 379 |
| 376 } // namespace data_reduction_proxy | 380 } // namespace data_reduction_proxy |
| 377 | 381 |
| 378 | 382 |
| OLD | NEW |