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

Side by Side Diff: chrome/browser/net/url_fetcher_protect.cc

Issue 126279: Consistently use int64 for integers holding number of milliseconds. (Closed)
Patch Set: Created 11 years, 6 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 | « chrome/browser/net/url_fetcher_protect.h ('k') | chrome/test/chrome_process_util.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/net/url_fetcher_protect.h" 5 #include "chrome/browser/net/url_fetcher_protect.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 // URLFetcherProtectEntry ---------------------------------------------------- 9 // URLFetcherProtectEntry ----------------------------------------------------
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 : sliding_window_period_(sliding_window_period), 45 : sliding_window_period_(sliding_window_period),
46 max_send_threshold_(max_send_threshold), 46 max_send_threshold_(max_send_threshold),
47 max_retries_(max_retries), 47 max_retries_(max_retries),
48 initial_timeout_(initial_timeout), 48 initial_timeout_(initial_timeout),
49 multiplier_(multiplier), 49 multiplier_(multiplier),
50 constant_factor_(constant_factor), 50 constant_factor_(constant_factor),
51 maximum_timeout_(maximum_timeout) { 51 maximum_timeout_(maximum_timeout) {
52 ResetBackoff(); 52 ResetBackoff();
53 } 53 }
54 54
55 int URLFetcherProtectEntry::UpdateBackoff(EventType event_type) { 55 int64 URLFetcherProtectEntry::UpdateBackoff(EventType event_type) {
56 // request may be sent in different threads 56 // request may be sent in different threads
57 AutoLock lock(lock_); 57 AutoLock lock(lock_);
58 58
59 TimeDelta t; 59 TimeDelta t;
60 switch (event_type) { 60 switch (event_type) {
61 case SEND: 61 case SEND:
62 t = AntiOverload(); 62 t = AntiOverload();
63 break; 63 break;
64 case SUCCESS: 64 case SUCCESS:
65 t = ResetBackoff(); 65 t = ResetBackoff();
66 break; 66 break;
67 case FAILURE: 67 case FAILURE:
68 t = IncreaseBackoff(); 68 t = IncreaseBackoff();
69 break; 69 break;
70 default: 70 default:
71 NOTREACHED(); 71 NOTREACHED();
72 } 72 }
73 73
74 int wait = static_cast<int>(t.InMilliseconds()); 74 int64 wait = t.InMilliseconds();
75 DCHECK(wait >= 0); 75 DCHECK(wait >= 0);
76 return wait; 76 return wait;
77 } 77 }
78 78
79 TimeDelta URLFetcherProtectEntry::AntiOverload() { 79 TimeDelta URLFetcherProtectEntry::AntiOverload() {
80 TimeDelta sw = TimeDelta::FromMilliseconds(sliding_window_period_); 80 TimeDelta sw = TimeDelta::FromMilliseconds(sliding_window_period_);
81 TimeTicks now = TimeTicks::Now(); 81 TimeTicks now = TimeTicks::Now();
82 // Estimate when the next request will be sent. 82 // Estimate when the next request will be sent.
83 release_time_ = now; 83 release_time_ = now;
84 if (send_log_.size() > 0) { 84 if (send_log_.size() > 0) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 ProtectService::iterator i = services_.find(id); 167 ProtectService::iterator i = services_.find(id);
168 if (i != services_.end()) { 168 if (i != services_.end()) {
169 // The entry exists. 169 // The entry exists.
170 delete i->second; 170 delete i->second;
171 } 171 }
172 172
173 services_[id] = entry; 173 services_[id] = entry;
174 return entry; 174 return entry;
175 } 175 }
OLDNEW
« no previous file with comments | « chrome/browser/net/url_fetcher_protect.h ('k') | chrome/test/chrome_process_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698