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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_config.Equals( | |
|
bengr
2014/09/02 05:11:38
Does this "Equals" do the right thing? E.g., what
megjablon
2014/09/02 21:00:16
Yes. This equals compares ignoring the differences
| |
| 169 request.context()->proxy_service()->config())) { | |
| 170 RecordBypassedBytes(last_bypass_type_, | |
| 171 DataReductionProxyUsageStats::MANAGED_PROXY_CONFIG, | |
| 172 content_length); | |
| 173 return; | |
| 174 } | |
| 175 | |
| 166 if (data_reduction_proxy_params_->WasDataReductionProxyUsed(&request, NULL)) { | 176 if (data_reduction_proxy_params_->WasDataReductionProxyUsed(&request, NULL)) { |
| 167 RecordBypassedBytes(last_bypass_type_, | 177 RecordBypassedBytes(last_bypass_type_, |
| 168 DataReductionProxyUsageStats::NOT_BYPASSED, | 178 DataReductionProxyUsageStats::NOT_BYPASSED, |
| 169 content_length); | 179 content_length); |
| 170 return; | 180 return; |
| 171 } | 181 } |
| 172 | 182 |
| 173 if (data_reduction_proxy_enabled.GetValue() && | 183 if (data_reduction_proxy_enabled.GetValue() && |
| 174 request.url().SchemeIs(url::kHttpsScheme)) { | 184 request.url().SchemeIs(url::kHttpsScheme)) { |
| 175 RecordBypassedBytes(last_bypass_type_, | 185 RecordBypassedBytes(last_bypass_type_, |
| 176 DataReductionProxyUsageStats::SSL, | 186 DataReductionProxyUsageStats::SSL, |
| 177 content_length); | 187 content_length); |
| 178 return; | 188 return; |
| 179 } | 189 } |
| 180 | 190 |
| 181 if (data_reduction_proxy_enabled.GetValue() && | 191 if (data_reduction_proxy_enabled.GetValue() && |
| 182 !data_reduction_proxy_params_->IsDataReductionProxyEligible(&request)) { | 192 data_reduction_proxy_params_->IsBypassedByDataReductionProxyLocalRules( |
| 193 request, data_reduction_proxy_config)) { | |
| 183 RecordBypassedBytes(last_bypass_type_, | 194 RecordBypassedBytes(last_bypass_type_, |
| 184 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, | 195 DataReductionProxyUsageStats::LOCAL_BYPASS_RULES, |
| 185 content_length); | 196 content_length); |
| 186 return; | 197 return; |
| 187 } | 198 } |
| 188 | 199 |
| 189 if (triggering_request_) { | 200 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 | 201 // We only record when audio or video triggers a bypass. We don't care |
| 196 // about audio and video bypassed as collateral damage. | 202 // about audio and video bypassed as collateral damage. |
| 197 std::string mime_type; | 203 std::string mime_type; |
| 198 request.GetMimeType(&mime_type); | 204 request.GetMimeType(&mime_type); |
| 199 // MIME types are named by <media-type>/<subtype>. We check to see if the | 205 // MIME types are named by <media-type>/<subtype>. We check to see if the |
| 200 // media type is audio or video. | 206 // media type is audio or video. |
| 201 if (mime_type.compare(0, 6, "audio/") == 0 || | 207 if (mime_type.compare(0, 6, "audio/") == 0 || |
| 202 mime_type.compare(0, 6, "video/") == 0) { | 208 mime_type.compare(0, 6, "video/") == 0) { |
| 203 RecordBypassedBytes(last_bypass_type_, | 209 RecordBypassedBytes(last_bypass_type_, |
| 204 DataReductionProxyUsageStats::AUDIO_VIDEO, | 210 DataReductionProxyUsageStats::AUDIO_VIDEO, |
| 205 content_length); | 211 content_length); |
| 212 return; | |
| 206 } | 213 } |
| 214 | |
| 215 RecordBypassedBytes(last_bypass_type_, | |
| 216 DataReductionProxyUsageStats::TRIGGERING_REQUEST, | |
| 217 content_length); | |
| 218 triggering_request_ = false; | |
| 219 return; | |
| 207 } | 220 } |
| 208 | 221 |
| 209 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { | 222 if (last_bypass_type_ != BYPASS_EVENT_TYPE_MAX) { |
| 210 RecordBypassedBytes(last_bypass_type_, | 223 RecordBypassedBytes(last_bypass_type_, |
| 211 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, | 224 DataReductionProxyUsageStats::BYPASSED_BYTES_TYPE_MAX, |
| 212 content_length); | 225 content_length); |
| 213 return; | 226 return; |
| 214 } | 227 } |
| 215 | 228 |
| 216 if (data_reduction_proxy_params_-> | 229 if (data_reduction_proxy_params_-> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 break; | 271 break; |
| 259 case DataReductionProxyUsageStats::SSL: | 272 case DataReductionProxyUsageStats::SSL: |
| 260 UMA_HISTOGRAM_COUNTS( | 273 UMA_HISTOGRAM_COUNTS( |
| 261 "DataReductionProxy.BypassedBytes.SSL", content_length); | 274 "DataReductionProxy.BypassedBytes.SSL", content_length); |
| 262 break; | 275 break; |
| 263 case DataReductionProxyUsageStats::LOCAL_BYPASS_RULES: | 276 case DataReductionProxyUsageStats::LOCAL_BYPASS_RULES: |
| 264 UMA_HISTOGRAM_COUNTS( | 277 UMA_HISTOGRAM_COUNTS( |
| 265 "DataReductionProxy.BypassedBytes.LocalBypassRules", | 278 "DataReductionProxy.BypassedBytes.LocalBypassRules", |
| 266 content_length); | 279 content_length); |
| 267 break; | 280 break; |
| 281 case DataReductionProxyUsageStats::MANAGED_PROXY_CONFIG: | |
| 282 UMA_HISTOGRAM_COUNTS( | |
| 283 "DataReductionProxy.BypassedBytes.ManagedProxyConfig", | |
| 284 content_length); | |
| 285 break; | |
| 268 case DataReductionProxyUsageStats::AUDIO_VIDEO: | 286 case DataReductionProxyUsageStats::AUDIO_VIDEO: |
| 269 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) { | 287 if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) { |
| 270 UMA_HISTOGRAM_COUNTS( | 288 UMA_HISTOGRAM_COUNTS( |
| 271 "DataReductionProxy.BypassedBytes.ShortAudioVideo", | 289 "DataReductionProxy.BypassedBytes.ShortAudioVideo", |
| 272 content_length); | 290 content_length); |
| 273 } | 291 } |
| 274 break; | 292 break; |
| 275 case DataReductionProxyUsageStats::TRIGGERING_REQUEST: | 293 case DataReductionProxyUsageStats::TRIGGERING_REQUEST: |
| 276 switch (bypass_type) { | 294 switch (bypass_type) { |
| 277 case BYPASS_EVENT_TYPE_SHORT: | 295 case BYPASS_EVENT_TYPE_SHORT: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 default: | 368 default: |
| 351 break; | 369 break; |
| 352 } | 370 } |
| 353 break; | 371 break; |
| 354 } | 372 } |
| 355 } | 373 } |
| 356 | 374 |
| 357 } // namespace data_reduction_proxy | 375 } // namespace data_reduction_proxy |
| 358 | 376 |
| 359 | 377 |
| OLD | NEW |