Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: net/url_request/url_request_throttler_entry.cc

Issue 1149763005: Change NetLog::ParametersCallback to return a scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments on ownership removed Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/url_request_redirect_job.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 // avoid false positives. It should help avoid back-off from kicking in e.g. 40 // avoid false positives. It should help avoid back-off from kicking in e.g.
41 // on flaky connections. 41 // on flaky connections.
42 const int URLRequestThrottlerEntry::kDefaultNumErrorsToIgnore = 2; 42 const int URLRequestThrottlerEntry::kDefaultNumErrorsToIgnore = 2;
43 const int URLRequestThrottlerEntry::kDefaultInitialDelayMs = 700; 43 const int URLRequestThrottlerEntry::kDefaultInitialDelayMs = 700;
44 const double URLRequestThrottlerEntry::kDefaultMultiplyFactor = 1.4; 44 const double URLRequestThrottlerEntry::kDefaultMultiplyFactor = 1.4;
45 const double URLRequestThrottlerEntry::kDefaultJitterFactor = 0.4; 45 const double URLRequestThrottlerEntry::kDefaultJitterFactor = 0.4;
46 const int URLRequestThrottlerEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; 46 const int URLRequestThrottlerEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000;
47 const int URLRequestThrottlerEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; 47 const int URLRequestThrottlerEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000;
48 48
49 // Returns NetLog parameters when a request is rejected by throttling. 49 // Returns NetLog parameters when a request is rejected by throttling.
50 base::Value* NetLogRejectedRequestCallback( 50 scoped_ptr<base::Value> NetLogRejectedRequestCallback(
51 const std::string* url_id, 51 const std::string* url_id,
52 int num_failures, 52 int num_failures,
53 const base::TimeDelta& release_after, 53 const base::TimeDelta& release_after,
54 NetLogCaptureMode /* capture_mode */) { 54 NetLogCaptureMode /* capture_mode */) {
55 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 55 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
56 dict->SetString("url", *url_id); 56 dict->SetString("url", *url_id);
57 dict->SetInteger("num_failures", num_failures); 57 dict->SetInteger("num_failures", num_failures);
58 dict->SetInteger("release_after_ms", 58 dict->SetInteger("release_after_ms",
59 static_cast<int>(release_after.InMilliseconds())); 59 static_cast<int>(release_after.InMilliseconds()));
60 return dict.release(); 60 return dict.Pass();
61 } 61 }
62 62
63 URLRequestThrottlerEntry::URLRequestThrottlerEntry( 63 URLRequestThrottlerEntry::URLRequestThrottlerEntry(
64 URLRequestThrottlerManager* manager, 64 URLRequestThrottlerManager* manager,
65 const std::string& url_id) 65 const std::string& url_id)
66 : sliding_window_period_( 66 : sliding_window_period_(
67 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)), 67 base::TimeDelta::FromMilliseconds(kDefaultSlidingWindowPeriodMs)),
68 max_send_threshold_(kDefaultMaxSendThreshold), 68 max_send_threshold_(kDefaultMaxSendThreshold),
69 is_backoff_disabled_(false), 69 is_backoff_disabled_(false),
70 backoff_entry_(&backoff_policy_), 70 backoff_entry_(&backoff_policy_),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { 284 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() {
285 return &backoff_entry_; 285 return &backoff_entry_;
286 } 286 }
287 287
288 // static 288 // static
289 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { 289 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) {
290 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; 290 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0;
291 } 291 }
292 292
293 } // namespace net 293 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_redirect_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698