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 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
16 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 scoped_ptr<base::Value> NetLogRejectedRequestCallback( | 51 scoped_ptr<base::Value> NetLogRejectedRequestCallback( |
51 const std::string* url_id, | 52 const std::string* url_id, |
52 int num_failures, | 53 int num_failures, |
53 const base::TimeDelta& release_after, | 54 const base::TimeDelta& release_after, |
54 NetLogCaptureMode /* capture_mode */) { | 55 NetLogCaptureMode /* capture_mode */) { |
55 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 56 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
56 dict->SetString("url", *url_id); | 57 dict->SetString("url", *url_id); |
57 dict->SetInteger("num_failures", num_failures); | 58 dict->SetInteger("num_failures", num_failures); |
58 dict->SetInteger("release_after_ms", | 59 dict->SetInteger("release_after_ms", |
59 static_cast<int>(release_after.InMilliseconds())); | 60 static_cast<int>(release_after.InMilliseconds())); |
60 return dict.Pass(); | 61 return std::move(dict); |
61 } | 62 } |
62 | 63 |
63 URLRequestThrottlerEntry::URLRequestThrottlerEntry( | 64 URLRequestThrottlerEntry::URLRequestThrottlerEntry( |
64 URLRequestThrottlerManager* manager, | 65 URLRequestThrottlerManager* manager, |
65 const std::string& url_id) | 66 const std::string& url_id) |
66 : sliding_window_period_( | 67 : sliding_window_period_( |
67 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), | 68 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), |
68 max_send_threshold_(kDefaultMaxSendThreshold), | 69 max_send_threshold_(kDefaultMaxSendThreshold), |
69 is_backoff_disabled_(false), | 70 is_backoff_disabled_(false), |
70 backoff_entry_(&backoff_policy_), | 71 backoff_entry_(&backoff_policy_), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 283 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
283 return &backoff_entry_; | 284 return &backoff_entry_; |
284 } | 285 } |
285 | 286 |
286 // static | 287 // static |
287 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 288 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
288 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 289 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
289 } | 290 } |
290 | 291 |
291 } // namespace net | 292 } // namespace net |
OLD | NEW |