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 // We only record separate triggering request UMA for short, medium, and long |
bengr
2014/09/19 17:23:33
Don't use "We" in comments. Change to:
Triggering
megjablon
2014/09/19 17:58:02
Done.
| |
202 // bypass events. | |
203 if (triggering_request_ && | |
204 (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT || | |
205 last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM || | |
206 last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) { | |
202 // 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 |
bengr
2014/09/19 17:23:33
Remove the "We"s in this comment too.
megjablon
2014/09/19 17:58:03
Done.
| |
203 // about audio and video bypassed as collateral damage. | 208 // about audio and video bypassed as collateral damage. |
204 std::string mime_type; | 209 std::string mime_type; |
205 request.GetMimeType(&mime_type); | 210 request.GetMimeType(&mime_type); |
206 // 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 |
207 // media type is audio or video. | 212 // media type is audio or video. |
bengr
2014/09/19 17:23:33
Add a comment that states that we only have a buck
megjablon
2014/09/19 17:58:02
Done.
| |
208 if (mime_type.compare(0, 6, "audio/") == 0 || | 213 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT && |
209 mime_type.compare(0, 6, "video/") == 0) { | 214 (mime_type.compare(0, 6, "audio/") == 0 || |
215 mime_type.compare(0, 6, "video/") == 0)) { | |
210 RecordBypassedBytes(last_bypass_type_, | 216 RecordBypassedBytes(last_bypass_type_, |
bengr
2014/09/19 17:23:33
This UMA is complicated enough that we should have
megjablon
2014/09/19 17:58:02
Done.
| |
211 DataReductionProxyUsageStats::AUDIO_VIDEO, | 217 DataReductionProxyUsageStats::AUDIO_VIDEO, |
212 content_length); | 218 content_length); |
213 return; | 219 return; |
214 } | 220 } |
215 | 221 |
216 RecordBypassedBytes(last_bypass_type_, | 222 RecordBypassedBytes(last_bypass_type_, |
217 DataReductionProxyUsageStats::TRIGGERING_REQUEST, | 223 DataReductionProxyUsageStats::TRIGGERING_REQUEST, |
218 content_length); | 224 content_length); |
219 triggering_request_ = false; | 225 triggering_request_ = false; |
220 return; | 226 return; |
221 } | 227 } |
222 | 228 |
223 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { | 229 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { |
224 RecordBypassedBytes(last_bypass_type_, | 230 RecordBypassedBytes(last_bypass_type_, |
225 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, | 231 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, |
226 content_length); | 232 content_length); |
227 return; | 233 return; |
228 } | 234 } |
229 | 235 |
230 if (data_reduction_proxy_params_-> | 236 if (data_reduction_proxy_params_-> |
231 AreDataReductionProxiesBypassed(request, NULL)) { | 237 AreDataReductionProxiesBypassed(request, NULL)) { |
bengr
2014/09/19 17:23:33
Can the line break be before "request" instead of
megjablon
2014/09/19 17:58:03
Done.
| |
232 RecordBypassedBytes(last_bypass_type_, | 238 RecordBypassedBytes(last_bypass_type_, |
233 DataReductionProxyUsageStats::NETWORK_ERROR, | 239 DataReductionProxyUsageStats::NETWORK_ERROR, |
234 content_length); | 240 content_length); |
235 } | 241 } |
236 } | 242 } |
237 | 243 |
238 void DataReductionProxyUsageStats::RecordBypassEventHistograms( | 244 void DataReductionProxyUsageStats::RecordBypassEventHistograms( |
239 const net::ProxyServer& bypassed_proxy, | 245 const net::ProxyServer& bypassed_proxy, |
240 int net_error) const { | 246 int net_error) const { |
241 DataReductionProxyTypeInfo data_reduction_proxy_info; | 247 DataReductionProxyTypeInfo data_reduction_proxy_info; |
242 if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() && | 248 if (bypassed_proxy.is_valid() && !bypassed_proxy.is_direct() && |
243 data_reduction_proxy_params_->IsDataReductionProxy( | 249 data_reduction_proxy_params_->IsDataReductionProxy( |
244 bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { | 250 bypassed_proxy.host_port_pair(), &data_reduction_proxy_info)) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 default: | 375 default: |
370 break; | 376 break; |
371 } | 377 } |
372 break; | 378 break; |
373 } | 379 } |
374 } | 380 } |
375 | 381 |
376 } // namespace data_reduction_proxy | 382 } // namespace data_reduction_proxy |
377 | 383 |
378 | 384 |
OLD | NEW |