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_metrics.h
" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 private: | 294 private: |
295 DailyContentLengthUpdate original_; | 295 DailyContentLengthUpdate original_; |
296 DailyContentLengthUpdate received_; | 296 DailyContentLengthUpdate received_; |
297 }; | 297 }; |
298 | 298 |
299 // Returns true if the request is bypassed by all configured data reduction | 299 // Returns true if the request is bypassed by all configured data reduction |
300 // proxies. It returns the bypass delay in delay_seconds (if not NULL). If | 300 // proxies. It returns the bypass delay in delay_seconds (if not NULL). If |
301 // the request is bypassed by more than one proxy, delay_seconds returns | 301 // the request is bypassed by more than one proxy, delay_seconds returns |
302 // shortest delay. | 302 // shortest delay. |
303 bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) { | 303 bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) { |
304 // TODO(bengr): Add support for other data reduction proxy configurations. | 304 DataReductionProxySettings::DataReductionProxyList proxies = |
305 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 305 DataReductionProxySettings::GetDataReductionProxies(); |
306 DataReductionProxyParams params( | |
307 DataReductionProxyParams::kAllowed | | |
308 DataReductionProxyParams::kFallbackAllowed | | |
309 DataReductionProxyParams::kPromoAllowed); | |
310 DataReductionProxyParams::DataReductionProxyList proxies = | |
311 params.GetAllowedProxies(); | |
312 if (proxies.size() == 0) | 306 if (proxies.size() == 0) |
313 return false; | 307 return false; |
314 | 308 |
315 if (request == NULL || request->context() == NULL || | 309 if (request == NULL || request->context() == NULL || |
316 request->context()->proxy_service() == NULL) { | 310 request->context()->proxy_service() == NULL) { |
317 return false; | 311 return false; |
318 } | 312 } |
319 | 313 |
320 const net::ProxyRetryInfoMap& retry_map = | 314 const net::ProxyRetryInfoMap& retry_map = |
321 request->context()->proxy_service()->proxy_retry_info(); | 315 request->context()->proxy_service()->proxy_retry_info(); |
(...skipping 12 matching lines...) Expand all Loading... |
334 if (found == retry_map.end()) | 328 if (found == retry_map.end()) |
335 return false; | 329 return false; |
336 if (shortest_delay == 0 || | 330 if (shortest_delay == 0 || |
337 shortest_delay > found->second.current_delay.InSeconds()) { | 331 shortest_delay > found->second.current_delay.InSeconds()) { |
338 shortest_delay = found->second.current_delay.InSeconds(); | 332 shortest_delay = found->second.current_delay.InSeconds(); |
339 } | 333 } |
340 } | 334 } |
341 if (delay_seconds != NULL) | 335 if (delay_seconds != NULL) |
342 *delay_seconds = shortest_delay; | 336 *delay_seconds = shortest_delay; |
343 return true; | 337 return true; |
344 #else | |
345 return false; | |
346 #endif | |
347 } | 338 } |
348 | 339 |
349 } // namespace | 340 } // namespace |
350 | 341 |
351 DataReductionProxyRequestType GetDataReductionProxyRequestType( | 342 DataReductionProxyRequestType GetDataReductionProxyRequestType( |
352 const net::URLRequest* request) { | 343 const net::URLRequest* request) { |
353 if (request->url().SchemeIs("https")) | 344 if (request->url().SchemeIs("https")) |
354 return HTTPS; | 345 return HTTPS; |
355 if (!request->url().SchemeIs("http")) { | 346 if (!request->url().SchemeIs("http")) { |
356 NOTREACHED(); | 347 NOTREACHED(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 UpdateContentLengthPrefsForDataReductionProxy( | 531 UpdateContentLengthPrefsForDataReductionProxy( |
541 received_content_length, | 532 received_content_length, |
542 original_content_length, | 533 original_content_length, |
543 with_data_reduction_proxy_enabled, | 534 with_data_reduction_proxy_enabled, |
544 request_type, | 535 request_type, |
545 base::Time::Now(), | 536 base::Time::Now(), |
546 prefs); | 537 prefs); |
547 } | 538 } |
548 | 539 |
549 } // namespace data_reduction_proxy | 540 } // namespace data_reduction_proxy |
OLD | NEW |