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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const double URLRequestThrottlerEntry::kDefaultMultiplyFactor = 1.4; | 45 const double URLRequestThrottlerEntry::kDefaultMultiplyFactor = 1.4; |
46 const double URLRequestThrottlerEntry::kDefaultJitterFactor = 0.4; | 46 const double URLRequestThrottlerEntry::kDefaultJitterFactor = 0.4; |
47 const int URLRequestThrottlerEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; | 47 const int URLRequestThrottlerEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; |
48 const int URLRequestThrottlerEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; | 48 const int URLRequestThrottlerEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; |
49 const char URLRequestThrottlerEntry::kExponentialThrottlingHeader[] = | 49 const char URLRequestThrottlerEntry::kExponentialThrottlingHeader[] = |
50 "X-Chrome-Exponential-Throttling"; | 50 "X-Chrome-Exponential-Throttling"; |
51 const char URLRequestThrottlerEntry::kExponentialThrottlingDisableValue[] = | 51 const char URLRequestThrottlerEntry::kExponentialThrottlingDisableValue[] = |
52 "disable"; | 52 "disable"; |
53 | 53 |
54 // Returns NetLog parameters when a request is rejected by throttling. | 54 // Returns NetLog parameters when a request is rejected by throttling. |
55 Value* NetLogRejectedRequestCallback(const std::string* url_id, | 55 base::Value* NetLogRejectedRequestCallback(const std::string* url_id, |
56 int num_failures, | 56 int num_failures, |
57 int release_after_ms, | 57 int release_after_ms, |
58 NetLog::LogLevel /* log_level */) { | 58 NetLog::LogLevel /* log_level */) { |
59 DictionaryValue* dict = new DictionaryValue(); | 59 base::DictionaryValue* dict = new base::DictionaryValue(); |
60 dict->SetString("url", *url_id); | 60 dict->SetString("url", *url_id); |
61 dict->SetInteger("num_failures", num_failures); | 61 dict->SetInteger("num_failures", num_failures); |
62 dict->SetInteger("release_after_ms", release_after_ms); | 62 dict->SetInteger("release_after_ms", release_after_ms); |
63 return dict; | 63 return dict; |
64 } | 64 } |
65 | 65 |
66 URLRequestThrottlerEntry::URLRequestThrottlerEntry( | 66 URLRequestThrottlerEntry::URLRequestThrottlerEntry( |
67 URLRequestThrottlerManager* manager, | 67 URLRequestThrottlerManager* manager, |
68 const std::string& url_id) | 68 const std::string& url_id) |
69 : sliding_window_period_( | 69 : sliding_window_period_( |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 312 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
313 return &backoff_entry_; | 313 return &backoff_entry_; |
314 } | 314 } |
315 | 315 |
316 // static | 316 // static |
317 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 317 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
318 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 318 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
319 } | 319 } |
320 | 320 |
321 } // namespace net | 321 } // namespace net |
OLD | NEW |