| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | |
| 10 #include <deque> | 9 #include <deque> |
| 11 #include <set> | 10 #include <set> |
| 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 21 #include "net/base/backoff_entry.h" | 21 #include "net/base/backoff_entry.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void TaskQueue<T>::ResetBackoff() { | 228 void TaskQueue<T>::ResetBackoff() { |
| 229 backoff_timer_->Stop(); | 229 backoff_timer_->Stop(); |
| 230 backoff_entry_->Reset(); | 230 backoff_entry_->Reset(); |
| 231 ScheduleDispatch(); | 231 ScheduleDispatch(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 template <typename T> | 234 template <typename T> |
| 235 void TaskQueue<T>::SetTimerForTest(scoped_ptr<base::Timer> timer) { | 235 void TaskQueue<T>::SetTimerForTest(scoped_ptr<base::Timer> timer) { |
| 236 DCHECK(CalledOnValidThread()); | 236 DCHECK(CalledOnValidThread()); |
| 237 DCHECK(timer.get()); | 237 DCHECK(timer.get()); |
| 238 backoff_timer_ = timer.Pass(); | 238 backoff_timer_ = std::move(timer); |
| 239 } | 239 } |
| 240 | 240 |
| 241 template <typename T> | 241 template <typename T> |
| 242 void TaskQueue<T>::FinishTask(const T& task) { | 242 void TaskQueue<T>::FinishTask(const T& task) { |
| 243 DCHECK(CalledOnValidThread()); | 243 DCHECK(CalledOnValidThread()); |
| 244 DCHECK_GE(num_in_progress_, 1); | 244 DCHECK_GE(num_in_progress_, 1); |
| 245 --num_in_progress_; | 245 --num_in_progress_; |
| 246 const size_t num_erased = tasks_.erase(task); | 246 const size_t num_erased = tasks_.erase(task); |
| 247 DCHECK_EQ(1U, num_erased); | 247 DCHECK_EQ(1U, num_erased); |
| 248 } | 248 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 template <typename T> | 277 template <typename T> |
| 278 bool TaskQueue<T>::ShouldDispatch() { | 278 bool TaskQueue<T>::ShouldDispatch() { |
| 279 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty(); | 279 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace syncer | 282 } // namespace syncer |
| 283 | 283 |
| 284 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ | 284 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ |
| OLD | NEW |