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 "sync/notifier/ack_tracker.h" | 5 #include "sync/notifier/ack_tracker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 void AckTracker::Clear() { | 91 void AckTracker::Clear() { |
92 DCHECK(thread_checker_.CalledOnValidThread()); | 92 DCHECK(thread_checker_.CalledOnValidThread()); |
93 | 93 |
94 timer_.Stop(); | 94 timer_.Stop(); |
95 STLDeleteValues(&queue_); | 95 STLDeleteValues(&queue_); |
96 } | 96 } |
97 | 97 |
98 void AckTracker::Track(const ObjectIdSet& ids) { | 98 void AckTracker::Track(const ObjectIdSet& ids) { |
99 DCHECK(thread_checker_.CalledOnValidThread()); | 99 DCHECK(thread_checker_.CalledOnValidThread()); |
| 100 DCHECK(!ids.empty()); |
100 | 101 |
101 scoped_ptr<Entry> entry(new Entry( | 102 scoped_ptr<Entry> entry(new Entry( |
102 create_backoff_entry_callback_.Run(&kDefaultBackoffPolicy), ids)); | 103 create_backoff_entry_callback_.Run(&kDefaultBackoffPolicy), ids)); |
103 // This is a small hack. When net::BackoffRequest is first created, | 104 // This is a small hack. When net::BackoffRequest is first created, |
104 // GetReleaseTime() always returns the default base::TimeTicks value: 0. | 105 // GetReleaseTime() always returns the default base::TimeTicks value: 0. |
105 // In order to work around that, we mark it as failed right away. | 106 // In order to work around that, we mark it as failed right away. |
106 entry->backoff->InformOfRequest(false /* succeeded */); | 107 entry->backoff->InformOfRequest(false /* succeeded */); |
107 const base::TimeTicks release_time = entry->backoff->GetReleaseTime(); | 108 const base::TimeTicks release_time = entry->backoff->GetReleaseTime(); |
108 queue_.insert(std::make_pair(release_time, entry.release())); | 109 queue_.insert(std::make_pair(release_time, entry.release())); |
109 NudgeTimer(); | 110 NudgeTimer(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return queue_.empty(); | 212 return queue_.empty(); |
212 } | 213 } |
213 | 214 |
214 const base::Timer& AckTracker::GetTimerForTest() const { | 215 const base::Timer& AckTracker::GetTimerForTest() const { |
215 DCHECK(thread_checker_.CalledOnValidThread()); | 216 DCHECK(thread_checker_.CalledOnValidThread()); |
216 | 217 |
217 return timer_; | 218 return timer_; |
218 } | 219 } |
219 | 220 |
220 } // namespace syncer | 221 } // namespace syncer |
OLD | NEW |