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