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( | 55 base::Value* NetLogRejectedRequestCallback( |
eroman
2015/05/08 18:59:47
Making this return a scoped_ptr<> is part of bug 4
payal.pandey
2015/05/11 12:24:23
Will Update this as new CL for the bug mentioned.
| |
56 const std::string* url_id, | 56 const std::string* url_id, |
57 int num_failures, | 57 int num_failures, |
58 const base::TimeDelta& release_after, | 58 const base::TimeDelta& release_after, |
59 NetLogCaptureMode /* capture_mode */) { | 59 NetLogCaptureMode /* capture_mode */) { |
60 base::DictionaryValue* dict = new base::DictionaryValue(); | 60 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
61 dict->SetString("url", *url_id); | 61 dict->SetString("url", *url_id); |
62 dict->SetInteger("num_failures", num_failures); | 62 dict->SetInteger("num_failures", num_failures); |
63 dict->SetInteger("release_after_ms", | 63 dict->SetInteger("release_after_ms", |
64 static_cast<int>(release_after.InMilliseconds())); | 64 static_cast<int>(release_after.InMilliseconds())); |
65 return dict; | 65 return dict.release(); |
66 } | 66 } |
67 | 67 |
68 URLRequestThrottlerEntry::URLRequestThrottlerEntry( | 68 URLRequestThrottlerEntry::URLRequestThrottlerEntry( |
69 URLRequestThrottlerManager* manager, | 69 URLRequestThrottlerManager* manager, |
70 const std::string& url_id) | 70 const std::string& url_id) |
71 : sliding_window_period_( | 71 : sliding_window_period_( |
72 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), | 72 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), |
73 max_send_threshold_(kDefaultMaxSendThreshold), | 73 max_send_threshold_(kDefaultMaxSendThreshold), |
74 is_backoff_disabled_(false), | 74 is_backoff_disabled_(false), |
75 backoff_entry_(&backoff_policy_), | 75 backoff_entry_(&backoff_policy_), |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 311 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
312 return &backoff_entry_; | 312 return &backoff_entry_; |
313 } | 313 } |
314 | 314 |
315 // static | 315 // static |
316 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 316 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
317 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 317 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
318 } | 318 } |
319 | 319 |
320 } // namespace net | 320 } // namespace net |
OLD | NEW |