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 base::Value* NetLogRejectedRequestCallback(const std::string* url_id, | 55 base::Value* NetLogRejectedRequestCallback( |
56 int num_failures, | 56 const std::string* url_id, |
57 const base::TimeDelta& release_after, | 57 int num_failures, |
58 NetLog::LogLevel /* log_level */) { | 58 const base::TimeDelta& release_after, |
| 59 NetLogCaptureMode /* capture_mode */) { |
59 base::DictionaryValue* dict = new base::DictionaryValue(); | 60 base::DictionaryValue* dict = new base::DictionaryValue(); |
60 dict->SetString("url", *url_id); | 61 dict->SetString("url", *url_id); |
61 dict->SetInteger("num_failures", num_failures); | 62 dict->SetInteger("num_failures", num_failures); |
62 dict->SetInteger("release_after_ms", | 63 dict->SetInteger("release_after_ms", |
63 static_cast<int>(release_after.InMilliseconds())); | 64 static_cast<int>(release_after.InMilliseconds())); |
64 return dict; | 65 return dict; |
65 } | 66 } |
66 | 67 |
67 URLRequestThrottlerEntry::URLRequestThrottlerEntry( | 68 URLRequestThrottlerEntry::URLRequestThrottlerEntry( |
68 URLRequestThrottlerManager* manager, | 69 URLRequestThrottlerManager* manager, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 311 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
311 return &backoff_entry_; | 312 return &backoff_entry_; |
312 } | 313 } |
313 | 314 |
314 // static | 315 // static |
315 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 316 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
316 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 317 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
317 } | 318 } |
318 | 319 |
319 } // namespace net | 320 } // namespace net |
OLD | NEW |