| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_throttler_entry.h" | 5 #include "net/url_request/url_request_throttler_entry.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 virtual Value* ToValue() const { | 64 virtual Value* ToValue() const { |
| 65 DictionaryValue* dict = new DictionaryValue(); | 65 DictionaryValue* dict = new DictionaryValue(); |
| 66 dict->SetString("url", url_id_); | 66 dict->SetString("url", url_id_); |
| 67 dict->SetInteger("num_failures", num_failures_); | 67 dict->SetInteger("num_failures", num_failures_); |
| 68 dict->SetInteger("release_after_ms", release_after_ms_); | 68 dict->SetInteger("release_after_ms", release_after_ms_); |
| 69 return dict; | 69 return dict; |
| 70 } | 70 } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 virtual ~RejectedRequestParameters() {} |
| 74 |
| 73 std::string url_id_; | 75 std::string url_id_; |
| 74 int num_failures_; | 76 int num_failures_; |
| 75 int release_after_ms_; | 77 int release_after_ms_; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 // NetLog parameters when a response contains an X-Retry-After header. | 80 // NetLog parameters when a response contains an X-Retry-After header. |
| 79 class RetryAfterParameters : public NetLog::EventParameters { | 81 class RetryAfterParameters : public NetLog::EventParameters { |
| 80 public: | 82 public: |
| 81 RetryAfterParameters(const std::string& url_id, | 83 RetryAfterParameters(const std::string& url_id, |
| 82 int retry_after_ms) | 84 int retry_after_ms) |
| 83 : url_id_(url_id), | 85 : url_id_(url_id), |
| 84 retry_after_ms_(retry_after_ms) { | 86 retry_after_ms_(retry_after_ms) { |
| 85 } | 87 } |
| 86 | 88 |
| 87 virtual Value* ToValue() const { | 89 virtual Value* ToValue() const { |
| 88 DictionaryValue* dict = new DictionaryValue(); | 90 DictionaryValue* dict = new DictionaryValue(); |
| 89 dict->SetString("url", url_id_); | 91 dict->SetString("url", url_id_); |
| 90 dict->SetInteger("retry_after_ms", retry_after_ms_); | 92 dict->SetInteger("retry_after_ms", retry_after_ms_); |
| 91 return dict; | 93 return dict; |
| 92 } | 94 } |
| 93 | 95 |
| 94 private: | 96 private: |
| 97 virtual ~RetryAfterParameters() {} |
| 98 |
| 95 std::string url_id_; | 99 std::string url_id_; |
| 96 int retry_after_ms_; | 100 int retry_after_ms_; |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 URLRequestThrottlerEntry::URLRequestThrottlerEntry( | 103 URLRequestThrottlerEntry::URLRequestThrottlerEntry( |
| 100 URLRequestThrottlerManager* manager, | 104 URLRequestThrottlerManager* manager, |
| 101 const std::string& url_id) | 105 const std::string& url_id) |
| 102 : sliding_window_period_( | 106 : sliding_window_period_( |
| 103 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), | 107 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), |
| 104 max_send_threshold_(kDefaultMaxSendThreshold), | 108 max_send_threshold_(kDefaultMaxSendThreshold), |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 416 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
| 413 return &backoff_entry_; | 417 return &backoff_entry_; |
| 414 } | 418 } |
| 415 | 419 |
| 416 // static | 420 // static |
| 417 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 421 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
| 418 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 422 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
| 419 } | 423 } |
| 420 | 424 |
| 421 } // namespace net | 425 } // namespace net |
| OLD | NEW |