| 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 COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ | 5 #ifndef COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ |
| 6 #define COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ | 6 #define COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 max_backoff_delay.InMicroseconds()); | 180 max_backoff_delay.InMicroseconds()); |
| 181 backoff_policy_.initial_delay_ms = initial_backoff_delay.InMilliseconds(); | 181 backoff_policy_.initial_delay_ms = initial_backoff_delay.InMilliseconds(); |
| 182 backoff_policy_.multiply_factor = 2.0; | 182 backoff_policy_.multiply_factor = 2.0; |
| 183 backoff_policy_.jitter_factor = 0.1; | 183 backoff_policy_.jitter_factor = 0.1; |
| 184 backoff_policy_.maximum_backoff_ms = max_backoff_delay.InMilliseconds(); | 184 backoff_policy_.maximum_backoff_ms = max_backoff_delay.InMilliseconds(); |
| 185 backoff_policy_.entry_lifetime_ms = -1; | 185 backoff_policy_.entry_lifetime_ms = -1; |
| 186 backoff_policy_.always_use_initial_delay = false; | 186 backoff_policy_.always_use_initial_delay = false; |
| 187 backoff_entry_ = base::MakeUnique<net::BackoffEntry>(&backoff_policy_); | 187 backoff_entry_ = base::MakeUnique<net::BackoffEntry>(&backoff_policy_); |
| 188 dispatch_closure_ = | 188 dispatch_closure_ = |
| 189 base::Bind(&TaskQueue::Dispatch, weak_ptr_factory_.GetWeakPtr()); | 189 base::Bind(&TaskQueue::Dispatch, weak_ptr_factory_.GetWeakPtr()); |
| 190 backoff_timer_ = base::MakeUnique<base::Timer>(false, false); | 190 backoff_timer_ = base::MakeUnique<base::OneShotTimer>(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 template <typename T> | 193 template <typename T> |
| 194 void TaskQueue<T>::AddToQueue(const T& task) { | 194 void TaskQueue<T>::AddToQueue(const T& task) { |
| 195 DCHECK(CalledOnValidThread()); | 195 DCHECK(CalledOnValidThread()); |
| 196 // Ignore duplicates. | 196 // Ignore duplicates. |
| 197 if (tasks_.find(task) == tasks_.end()) { | 197 if (tasks_.find(task) == tasks_.end()) { |
| 198 queue_.push_back(task); | 198 queue_.push_back(task); |
| 199 tasks_.insert(task); | 199 tasks_.insert(task); |
| 200 } | 200 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 template <typename T> | 280 template <typename T> |
| 281 bool TaskQueue<T>::ShouldDispatch() { | 281 bool TaskQueue<T>::ShouldDispatch() { |
| 282 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty(); | 282 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace syncer | 285 } // namespace syncer |
| 286 | 286 |
| 287 #endif // COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ | 287 #endif // COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ |
| OLD | NEW |