| 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 "extensions/browser/extension_throttle_entry.h" | 5 #include "extensions/browser/extension_throttle_entry.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // avoid false positives. It should help avoid back-off from kicking in e.g. | 39 // avoid false positives. It should help avoid back-off from kicking in e.g. |
| 40 // on flaky connections. | 40 // on flaky connections. |
| 41 const int ExtensionThrottleEntry::kDefaultNumErrorsToIgnore = 2; | 41 const int ExtensionThrottleEntry::kDefaultNumErrorsToIgnore = 2; |
| 42 const int ExtensionThrottleEntry::kDefaultInitialDelayMs = 700; | 42 const int ExtensionThrottleEntry::kDefaultInitialDelayMs = 700; |
| 43 const double ExtensionThrottleEntry::kDefaultMultiplyFactor = 1.4; | 43 const double ExtensionThrottleEntry::kDefaultMultiplyFactor = 1.4; |
| 44 const double ExtensionThrottleEntry::kDefaultJitterFactor = 0.4; | 44 const double ExtensionThrottleEntry::kDefaultJitterFactor = 0.4; |
| 45 const int ExtensionThrottleEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; | 45 const int ExtensionThrottleEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; |
| 46 const int ExtensionThrottleEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; | 46 const int ExtensionThrottleEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; |
| 47 | 47 |
| 48 // Returns NetLog parameters when a request is rejected by throttling. | 48 // Returns NetLog parameters when a request is rejected by throttling. |
| 49 scoped_ptr<base::Value> NetLogRejectedRequestCallback( | 49 std::unique_ptr<base::Value> NetLogRejectedRequestCallback( |
| 50 const std::string* url_id, | 50 const std::string* url_id, |
| 51 int num_failures, | 51 int num_failures, |
| 52 const base::TimeDelta& release_after, | 52 const base::TimeDelta& release_after, |
| 53 net::NetLogCaptureMode /* capture_mode */) { | 53 net::NetLogCaptureMode /* capture_mode */) { |
| 54 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 54 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 55 dict->SetString("url", *url_id); | 55 dict->SetString("url", *url_id); |
| 56 dict->SetInteger("num_failures", num_failures); | 56 dict->SetInteger("num_failures", num_failures); |
| 57 dict->SetInteger("release_after_ms", | 57 dict->SetInteger("release_after_ms", |
| 58 static_cast<int>(release_after.InMilliseconds())); | 58 static_cast<int>(release_after.InMilliseconds())); |
| 59 return std::move(dict); | 59 return std::move(dict); |
| 60 } | 60 } |
| 61 | 61 |
| 62 ExtensionThrottleEntry::ExtensionThrottleEntry( | 62 ExtensionThrottleEntry::ExtensionThrottleEntry( |
| 63 ExtensionThrottleManager* manager, | 63 ExtensionThrottleManager* manager, |
| 64 const std::string& url_id) | 64 const std::string& url_id) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 net::BackoffEntry* ExtensionThrottleEntry::GetBackoffEntry() { | 278 net::BackoffEntry* ExtensionThrottleEntry::GetBackoffEntry() { |
| 279 return &backoff_entry_; | 279 return &backoff_entry_; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // static | 282 // static |
| 283 bool ExtensionThrottleEntry::ExplicitUserRequest(const int load_flags) { | 283 bool ExtensionThrottleEntry::ExplicitUserRequest(const int load_flags) { |
| 284 return (load_flags & net::LOAD_MAYBE_USER_GESTURE) != 0; | 284 return (load_flags & net::LOAD_MAYBE_USER_GESTURE) != 0; |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace extensions | 287 } // namespace extensions |
| OLD | NEW |