Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1761)

Side by Side Diff: components/sync/model_impl/attachments/task_queue.h

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
18 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
19 #include "base/threading/non_thread_safe.h" 20 #include "base/threading/non_thread_safe.h"
20 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "base/timer/timer.h" 23 #include "base/timer/timer.h"
23 #include "net/base/backoff_entry.h" 24 #include "net/base/backoff_entry.h"
24 25
25 namespace syncer { 26 namespace syncer {
26 27
27 // A queue that dispatches tasks, ignores duplicates, and provides backoff 28 // A queue that dispatches tasks, ignores duplicates, and provides backoff
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 num_in_progress_(0), 177 num_in_progress_(0),
177 weak_ptr_factory_(this) { 178 weak_ptr_factory_(this) {
178 DCHECK_LE(initial_backoff_delay.InMicroseconds(), 179 DCHECK_LE(initial_backoff_delay.InMicroseconds(),
179 max_backoff_delay.InMicroseconds()); 180 max_backoff_delay.InMicroseconds());
180 backoff_policy_.initial_delay_ms = initial_backoff_delay.InMilliseconds(); 181 backoff_policy_.initial_delay_ms = initial_backoff_delay.InMilliseconds();
181 backoff_policy_.multiply_factor = 2.0; 182 backoff_policy_.multiply_factor = 2.0;
182 backoff_policy_.jitter_factor = 0.1; 183 backoff_policy_.jitter_factor = 0.1;
183 backoff_policy_.maximum_backoff_ms = max_backoff_delay.InMilliseconds(); 184 backoff_policy_.maximum_backoff_ms = max_backoff_delay.InMilliseconds();
184 backoff_policy_.entry_lifetime_ms = -1; 185 backoff_policy_.entry_lifetime_ms = -1;
185 backoff_policy_.always_use_initial_delay = false; 186 backoff_policy_.always_use_initial_delay = false;
186 backoff_entry_.reset(new net::BackoffEntry(&backoff_policy_)); 187 backoff_entry_ = base::MakeUnique<net::BackoffEntry>(&backoff_policy_);
187 dispatch_closure_ = 188 dispatch_closure_ =
188 base::Bind(&TaskQueue::Dispatch, weak_ptr_factory_.GetWeakPtr()); 189 base::Bind(&TaskQueue::Dispatch, weak_ptr_factory_.GetWeakPtr());
189 backoff_timer_.reset(new base::Timer(false, false)); 190 backoff_timer_ = base::MakeUnique<base::Timer>(false, false);
190 } 191 }
191 192
192 template <typename T> 193 template <typename T>
193 void TaskQueue<T>::AddToQueue(const T& task) { 194 void TaskQueue<T>::AddToQueue(const T& task) {
194 DCHECK(CalledOnValidThread()); 195 DCHECK(CalledOnValidThread());
195 // Ignore duplicates. 196 // Ignore duplicates.
196 if (tasks_.find(task) == tasks_.end()) { 197 if (tasks_.find(task) == tasks_.end()) {
197 queue_.push_back(task); 198 queue_.push_back(task);
198 tasks_.insert(task); 199 tasks_.insert(task);
199 } 200 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 278 }
278 279
279 template <typename T> 280 template <typename T>
280 bool TaskQueue<T>::ShouldDispatch() { 281 bool TaskQueue<T>::ShouldDispatch() {
281 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty(); 282 return num_in_progress_ < kMaxConcurrentTasks && !queue_.empty();
282 } 283 }
283 284
284 } // namespace syncer 285 } // namespace syncer
285 286
286 #endif // COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_ 287 #endif // COMPONENTS_SYNC_MODEL_IMPL_ATTACHMENTS_TASK_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698