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

Side by Side Diff: content/browser/dom_storage/dom_storage_task_runner.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/dom_storage/dom_storage_task_runner.h" 5 #include "content/browser/dom_storage/dom_storage_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/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 13 matching lines...) Expand all
24 24
25 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default; 25 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default;
26 26
27 bool DOMStorageWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const { 27 bool DOMStorageWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
28 // It is valid for an implementation to always return true. 28 // It is valid for an implementation to always return true.
29 return true; 29 return true;
30 } 30 }
31 31
32 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask( 32 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask(
33 const tracked_objects::Location& from_here, 33 const tracked_objects::Location& from_here,
34 const base::Closure& task, 34 base::Closure task,
35 base::TimeDelta delay) { 35 base::TimeDelta delay) {
36 return primary_sequence_->PostDelayedTask(from_here, task, delay); 36 return primary_sequence_->PostDelayedTask(from_here, std::move(task), delay);
37 } 37 }
38 38
39 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask( 39 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask(
40 const tracked_objects::Location& from_here, 40 const tracked_objects::Location& from_here,
41 SequenceID sequence_id, 41 SequenceID sequence_id,
42 const base::Closure& task) { 42 base::Closure task) {
43 return GetSequencedTaskRunner(sequence_id)->PostTask(from_here, task); 43 return GetSequencedTaskRunner(sequence_id)
44 ->PostTask(from_here, std::move(task));
44 } 45 }
45 46
46 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const { 47 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const {
47 DCHECK(primary_sequence_->RunsTasksOnCurrentThread()); 48 DCHECK(primary_sequence_->RunsTasksOnCurrentThread());
48 } 49 }
49 50
50 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const { 51 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const {
51 DCHECK(commit_sequence_->RunsTasksOnCurrentThread()); 52 DCHECK(commit_sequence_->RunsTasksOnCurrentThread());
52 } 53 }
53 54
(...skipping 12 matching lines...) Expand all
66 : task_runner_(std::move(task_runner)) {} 67 : task_runner_(std::move(task_runner)) {}
67 68
68 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default; 69 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default;
69 70
70 bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const { 71 bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const {
71 return task_runner_->RunsTasksOnCurrentThread(); 72 return task_runner_->RunsTasksOnCurrentThread();
72 } 73 }
73 74
74 bool MockDOMStorageTaskRunner::PostDelayedTask( 75 bool MockDOMStorageTaskRunner::PostDelayedTask(
75 const tracked_objects::Location& from_here, 76 const tracked_objects::Location& from_here,
76 const base::Closure& task, 77 base::Closure task,
77 base::TimeDelta delay) { 78 base::TimeDelta delay) {
78 return task_runner_->PostTask(from_here, task); 79 return task_runner_->PostTask(from_here, std::move(task));
79 } 80 }
80 81
81 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( 82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask(
82 const tracked_objects::Location& from_here, 83 const tracked_objects::Location& from_here,
83 SequenceID sequence_id, 84 SequenceID sequence_id,
84 const base::Closure& task) { 85 base::Closure task) {
85 return task_runner_->PostTask(from_here, task); 86 return task_runner_->PostTask(from_here, std::move(task));
86 } 87 }
87 88
88 void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const { 89 void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const {
89 DCHECK(RunsTasksOnCurrentThread()); 90 DCHECK(RunsTasksOnCurrentThread());
90 } 91 }
91 92
92 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { 93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const {
93 DCHECK(RunsTasksOnCurrentThread()); 94 DCHECK(RunsTasksOnCurrentThread());
94 } 95 }
95 96
96 scoped_refptr<base::SequencedTaskRunner> 97 scoped_refptr<base::SequencedTaskRunner>
97 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { 98 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) {
98 return task_runner_; 99 return task_runner_;
99 } 100 }
100 101
101 } // namespace content 102 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_task_runner.h ('k') | content/browser/startup_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698