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

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

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments 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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/tracked_objects.h" 13 #include "base/tracked_objects.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 // DOMStorageWorkerPoolTaskRunner 17 // DOMStorageWorkerPoolTaskRunner
18 18
19 DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner( 19 DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner(
20 scoped_refptr<base::SequencedTaskRunner> primary_sequence, 20 scoped_refptr<base::SequencedTaskRunner> primary_sequence,
21 scoped_refptr<base::SequencedTaskRunner> commit_sequence) 21 scoped_refptr<base::SequencedTaskRunner> commit_sequence)
22 : primary_sequence_(std::move(primary_sequence)), 22 : primary_sequence_(std::move(primary_sequence)),
23 commit_sequence_(std::move(commit_sequence)) {} 23 commit_sequence_(std::move(commit_sequence)) {}
24 24
25 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default; 25 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default;
26 26
27 bool DOMStorageWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const { 27 bool DOMStorageWorkerPoolTaskRunner::RunsTasksInCurrentSequence() const {
28 // It is valid for an implementation to always return true. 28 //return true;
gab 2017/04/19 18:37:56 nit: remove this leftover
29 return true; 29 return primary_sequence_->RunsTasksOnCurrentThread() ||
30 commit_sequence_->RunsTasksOnCurrentThread();
gab 2017/04/19 18:37:56 nit: git cl format? I'd expect this to be indented
30 } 31 }
31 32
32 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask( 33 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask(
33 const tracked_objects::Location& from_here, 34 const tracked_objects::Location& from_here,
34 base::OnceClosure task, 35 base::OnceClosure task,
35 base::TimeDelta delay) { 36 base::TimeDelta delay) {
36 return primary_sequence_->PostDelayedTask(from_here, std::move(task), delay); 37 return primary_sequence_->PostDelayedTask(from_here, std::move(task), delay);
37 } 38 }
38 39
39 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask( 40 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask(
(...skipping 21 matching lines...) Expand all
61 } 62 }
62 63
63 // MockDOMStorageTaskRunner 64 // MockDOMStorageTaskRunner
64 65
65 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( 66 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner(
66 scoped_refptr<base::SequencedTaskRunner> task_runner) 67 scoped_refptr<base::SequencedTaskRunner> task_runner)
67 : task_runner_(std::move(task_runner)) {} 68 : task_runner_(std::move(task_runner)) {}
68 69
69 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default; 70 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default;
70 71
71 bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const { 72 bool MockDOMStorageTaskRunner::RunsTasksInCurrentSequence() const {
72 return task_runner_->RunsTasksOnCurrentThread(); 73 return task_runner_->RunsTasksInCurrentSequence();
73 } 74 }
74 75
75 bool MockDOMStorageTaskRunner::PostDelayedTask( 76 bool MockDOMStorageTaskRunner::PostDelayedTask(
76 const tracked_objects::Location& from_here, 77 const tracked_objects::Location& from_here,
77 base::OnceClosure task, 78 base::OnceClosure task,
78 base::TimeDelta delay) { 79 base::TimeDelta delay) {
79 return task_runner_->PostTask(from_here, std::move(task)); 80 return task_runner_->PostTask(from_here, std::move(task));
80 } 81 }
81 82
82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( 83 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask(
(...skipping 10 matching lines...) Expand all
93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { 94 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const {
94 DCHECK(RunsTasksOnCurrentThread()); 95 DCHECK(RunsTasksOnCurrentThread());
95 } 96 }
96 97
97 scoped_refptr<base::SequencedTaskRunner> 98 scoped_refptr<base::SequencedTaskRunner>
98 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { 99 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) {
99 return task_runner_; 100 return task_runner_;
100 } 101 }
101 102
102 } // namespace content 103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698