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

Side by Side Diff: base/deferred_sequenced_task_runner.cc

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 years, 8 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
« no previous file with comments | « base/deferred_sequenced_task_runner.h ('k') | base/message_loop/incoming_task_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/deferred_sequenced_task_runner.h" 5 #include "base/deferred_sequenced_task_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 27
28 DeferredSequencedTaskRunner::DeferredSequencedTaskRunner( 28 DeferredSequencedTaskRunner::DeferredSequencedTaskRunner(
29 scoped_refptr<SequencedTaskRunner> target_task_runner) 29 scoped_refptr<SequencedTaskRunner> target_task_runner)
30 : started_(false), target_task_runner_(std::move(target_task_runner)) {} 30 : started_(false), target_task_runner_(std::move(target_task_runner)) {}
31 31
32 DeferredSequencedTaskRunner::~DeferredSequencedTaskRunner() { 32 DeferredSequencedTaskRunner::~DeferredSequencedTaskRunner() {
33 } 33 }
34 34
35 bool DeferredSequencedTaskRunner::PostDelayedTask( 35 bool DeferredSequencedTaskRunner::PostDelayedTask(
36 const tracked_objects::Location& from_here, 36 const tracked_objects::Location& from_here,
37 Closure task, 37 OnceClosure task,
38 TimeDelta delay) { 38 TimeDelta delay) {
39 AutoLock lock(lock_); 39 AutoLock lock(lock_);
40 if (started_) { 40 if (started_) {
41 DCHECK(deferred_tasks_queue_.empty()); 41 DCHECK(deferred_tasks_queue_.empty());
42 return target_task_runner_->PostDelayedTask(from_here, std::move(task), 42 return target_task_runner_->PostDelayedTask(from_here, std::move(task),
43 delay); 43 delay);
44 } 44 }
45 45
46 QueueDeferredTask(from_here, std::move(task), delay, 46 QueueDeferredTask(from_here, std::move(task), delay,
47 false /* is_non_nestable */); 47 false /* is_non_nestable */);
48 return true; 48 return true;
49 } 49 }
50 50
51 bool DeferredSequencedTaskRunner::RunsTasksOnCurrentThread() const { 51 bool DeferredSequencedTaskRunner::RunsTasksOnCurrentThread() const {
52 return target_task_runner_->RunsTasksOnCurrentThread(); 52 return target_task_runner_->RunsTasksOnCurrentThread();
53 } 53 }
54 54
55 bool DeferredSequencedTaskRunner::PostNonNestableDelayedTask( 55 bool DeferredSequencedTaskRunner::PostNonNestableDelayedTask(
56 const tracked_objects::Location& from_here, 56 const tracked_objects::Location& from_here,
57 Closure task, 57 OnceClosure task,
58 TimeDelta delay) { 58 TimeDelta delay) {
59 AutoLock lock(lock_); 59 AutoLock lock(lock_);
60 if (started_) { 60 if (started_) {
61 DCHECK(deferred_tasks_queue_.empty()); 61 DCHECK(deferred_tasks_queue_.empty());
62 return target_task_runner_->PostNonNestableDelayedTask( 62 return target_task_runner_->PostNonNestableDelayedTask(
63 from_here, std::move(task), delay); 63 from_here, std::move(task), delay);
64 } 64 }
65 QueueDeferredTask(from_here, std::move(task), delay, 65 QueueDeferredTask(from_here, std::move(task), delay,
66 true /* is_non_nestable */); 66 true /* is_non_nestable */);
67 return true; 67 return true;
68 } 68 }
69 69
70 void DeferredSequencedTaskRunner::QueueDeferredTask( 70 void DeferredSequencedTaskRunner::QueueDeferredTask(
71 const tracked_objects::Location& from_here, 71 const tracked_objects::Location& from_here,
72 Closure task, 72 OnceClosure task,
73 TimeDelta delay, 73 TimeDelta delay,
74 bool is_non_nestable) { 74 bool is_non_nestable) {
75 DCHECK(task); 75 DCHECK(task);
76 76
77 DeferredTask deferred_task; 77 DeferredTask deferred_task;
78 deferred_task.posted_from = from_here; 78 deferred_task.posted_from = from_here;
79 deferred_task.task = std::move(task); 79 deferred_task.task = std::move(task);
80 deferred_task.delay = delay; 80 deferred_task.delay = delay;
81 deferred_task.is_non_nestable = is_non_nestable; 81 deferred_task.is_non_nestable = is_non_nestable;
82 deferred_tasks_queue_.push_back(std::move(deferred_task)); 82 deferred_tasks_queue_.push_back(std::move(deferred_task));
(...skipping 12 matching lines...) Expand all
95 task.posted_from, std::move(task.task), task.delay); 95 task.posted_from, std::move(task.task), task.delay);
96 } else { 96 } else {
97 target_task_runner_->PostDelayedTask(task.posted_from, 97 target_task_runner_->PostDelayedTask(task.posted_from,
98 std::move(task.task), task.delay); 98 std::move(task.task), task.delay);
99 } 99 }
100 } 100 }
101 deferred_tasks_queue_.clear(); 101 deferred_tasks_queue_.clear();
102 } 102 }
103 103
104 } // namespace base 104 } // namespace base
OLDNEW
« no previous file with comments | « base/deferred_sequenced_task_runner.h ('k') | base/message_loop/incoming_task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698