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

Side by Side Diff: sync/sessions/nudge_tracker.cc

Issue 163413004: Add base::TimeDelta::Max(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "sync/sessions/nudge_tracker.h" 5 #include "sync/sessions/nudge_tracker.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "sync/internal_api/public/base/invalidation.h" 8 #include "sync/internal_api/public/base/invalidation.h"
9 #include "sync/notifier/invalidation_util.h" 9 #include "sync/notifier/invalidation_util.h"
10 #include "sync/notifier/object_id_invalidation_map.h" 10 #include "sync/notifier/object_id_invalidation_map.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 bool NudgeTracker::IsTypeThrottled(ModelType type) const { 187 bool NudgeTracker::IsTypeThrottled(ModelType type) const {
188 DCHECK(type_trackers_.find(type) != type_trackers_.end()); 188 DCHECK(type_trackers_.find(type) != type_trackers_.end());
189 return type_trackers_.find(type)->second.IsThrottled(); 189 return type_trackers_.find(type)->second.IsThrottled();
190 } 190 }
191 191
192 base::TimeDelta NudgeTracker::GetTimeUntilNextUnthrottle( 192 base::TimeDelta NudgeTracker::GetTimeUntilNextUnthrottle(
193 base::TimeTicks now) const { 193 base::TimeTicks now) const {
194 DCHECK(IsAnyTypeThrottled()) << "This function requires a pending unthrottle"; 194 DCHECK(IsAnyTypeThrottled()) << "This function requires a pending unthrottle";
195 const base::TimeDelta kMaxTimeDelta =
196 base::TimeDelta::FromInternalValue(kint64max);
197 195
198 // Return min of GetTimeUntilUnthrottle() values for all IsThrottled() types. 196 // Return min of GetTimeUntilUnthrottle() values for all IsThrottled() types.
199 base::TimeDelta time_until_next_unthrottle = kMaxTimeDelta; 197 base::TimeDelta time_until_next_unthrottle = base::TimeDelta::Max();
200 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 198 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
201 it != type_trackers_.end(); ++it) { 199 it != type_trackers_.end(); ++it) {
202 if (it->second.IsThrottled()) { 200 if (it->second.IsThrottled()) {
203 time_until_next_unthrottle = 201 time_until_next_unthrottle =
204 std::min(time_until_next_unthrottle, 202 std::min(time_until_next_unthrottle,
205 it->second.GetTimeUntilUnthrottle(now)); 203 it->second.GetTimeUntilUnthrottle(now));
206 } 204 }
207 } 205 }
208 DCHECK(kMaxTimeDelta != time_until_next_unthrottle); 206 DCHECK(!time_until_next_unthrottle.is_max());
209 207
210 return time_until_next_unthrottle; 208 return time_until_next_unthrottle;
211 } 209 }
212 210
213 ModelTypeSet NudgeTracker::GetThrottledTypes() const { 211 ModelTypeSet NudgeTracker::GetThrottledTypes() const {
214 ModelTypeSet result; 212 ModelTypeSet result;
215 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 213 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
216 it != type_trackers_.end(); ++it) { 214 it != type_trackers_.end(); ++it) {
217 if (it->second.IsThrottled()) { 215 if (it->second.IsThrottled()) {
218 result.Put(it->first); 216 result.Put(it->first);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 it->second.UpdatePayloadBufferSize(size); 272 it->second.UpdatePayloadBufferSize(size);
275 } 273 }
276 } 274 }
277 275
278 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) { 276 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) {
279 next_retry_time_ = retry_time; 277 next_retry_time_ = retry_time;
280 } 278 }
281 279
282 } // namespace sessions 280 } // namespace sessions
283 } // namespace syncer 281 } // namespace syncer
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698