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

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

Issue 179763006: Revert 253502 "Add base::TimeDelta::Max()." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | « trunk/src/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);
195 197
196 // Return min of GetTimeUntilUnthrottle() values for all IsThrottled() types. 198 // Return min of GetTimeUntilUnthrottle() values for all IsThrottled() types.
197 base::TimeDelta time_until_next_unthrottle = base::TimeDelta::Max(); 199 base::TimeDelta time_until_next_unthrottle = kMaxTimeDelta;
198 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 200 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
199 it != type_trackers_.end(); ++it) { 201 it != type_trackers_.end(); ++it) {
200 if (it->second.IsThrottled()) { 202 if (it->second.IsThrottled()) {
201 time_until_next_unthrottle = 203 time_until_next_unthrottle =
202 std::min(time_until_next_unthrottle, 204 std::min(time_until_next_unthrottle,
203 it->second.GetTimeUntilUnthrottle(now)); 205 it->second.GetTimeUntilUnthrottle(now));
204 } 206 }
205 } 207 }
206 DCHECK(!time_until_next_unthrottle.is_max()); 208 DCHECK(kMaxTimeDelta != time_until_next_unthrottle);
207 209
208 return time_until_next_unthrottle; 210 return time_until_next_unthrottle;
209 } 211 }
210 212
211 ModelTypeSet NudgeTracker::GetThrottledTypes() const { 213 ModelTypeSet NudgeTracker::GetThrottledTypes() const {
212 ModelTypeSet result; 214 ModelTypeSet result;
213 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 215 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
214 it != type_trackers_.end(); ++it) { 216 it != type_trackers_.end(); ++it) {
215 if (it->second.IsThrottled()) { 217 if (it->second.IsThrottled()) {
216 result.Put(it->first); 218 result.Put(it->first);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 it->second.UpdatePayloadBufferSize(size); 274 it->second.UpdatePayloadBufferSize(size);
273 } 275 }
274 } 276 }
275 277
276 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) { 278 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) {
277 next_retry_time_ = retry_time; 279 next_retry_time_ = retry_time;
278 } 280 }
279 281
280 } // namespace sessions 282 } // namespace sessions
281 } // namespace syncer 283 } // namespace syncer
OLDNEW
« no previous file with comments | « trunk/src/net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698