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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // } | 69 // } |
70 // | 70 // |
71 template <typename T> | 71 template <typename T> |
72 class TaskQueue : base::NonThreadSafe { | 72 class TaskQueue : base::NonThreadSafe { |
73 public: | 73 public: |
74 // A callback provided by users of the TaskQueue to handle tasks. | 74 // A callback provided by users of the TaskQueue to handle tasks. |
75 // | 75 // |
76 // This callback is invoked by the queue with a task to be handled. The | 76 // This callback is invoked by the queue with a task to be handled. The |
77 // callee is expected to (eventually) call |MarkAsSucceeded|, |MarkAsFailed|, | 77 // callee is expected to (eventually) call |MarkAsSucceeded|, |MarkAsFailed|, |
78 // or |Cancel| to signify completion of the task. | 78 // or |Cancel| to signify completion of the task. |
79 typedef base::Callback<void(const T&)> HandleTaskCallback; | 79 using HandleTaskCallback = base::Callback<void(const T&)>; |
80 | 80 |
81 // Construct a TaskQueue. | 81 // Construct a TaskQueue. |
82 // | 82 // |
83 // |callback| the callback to be invoked for handling tasks. | 83 // |callback| the callback to be invoked for handling tasks. |
84 // | 84 // |
85 // |initial_backoff_delay| the initial amount of time the queue will wait | 85 // |initial_backoff_delay| the initial amount of time the queue will wait |
86 // before dispatching tasks after a failed task (see |MarkAsFailed|). May be | 86 // before dispatching tasks after a failed task (see |MarkAsFailed|). May be |
87 // zero. Subsequent failures will increase the delay up to | 87 // zero. Subsequent failures will increase the delay up to |
88 // |max_backoff_delay|. | 88 // |max_backoff_delay|. |
89 // | 89 // |
(...skipping 188 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 |