OLD | NEW |
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 primary_sequence_->RunsTasksOnCurrentThread() || |
29 return true; | 29 commit_sequence_->RunsTasksOnCurrentThread(); |
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 base::OnceClosure task, | 34 base::OnceClosure task, |
35 base::TimeDelta delay) { | 35 base::TimeDelta delay) { |
36 return primary_sequence_->PostDelayedTask(from_here, std::move(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( |
(...skipping 21 matching lines...) Expand all Loading... |
61 } | 61 } |
62 | 62 |
63 // MockDOMStorageTaskRunner | 63 // MockDOMStorageTaskRunner |
64 | 64 |
65 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( | 65 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( |
66 scoped_refptr<base::SequencedTaskRunner> task_runner) | 66 scoped_refptr<base::SequencedTaskRunner> task_runner) |
67 : task_runner_(std::move(task_runner)) {} | 67 : task_runner_(std::move(task_runner)) {} |
68 | 68 |
69 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default; | 69 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default; |
70 | 70 |
71 bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const { | 71 bool MockDOMStorageTaskRunner::RunsTasksInCurrentSequence() const { |
72 return task_runner_->RunsTasksOnCurrentThread(); | 72 return task_runner_->RunsTasksInCurrentSequence(); |
73 } | 73 } |
74 | 74 |
75 bool MockDOMStorageTaskRunner::PostDelayedTask( | 75 bool MockDOMStorageTaskRunner::PostDelayedTask( |
76 const tracked_objects::Location& from_here, | 76 const tracked_objects::Location& from_here, |
77 base::OnceClosure task, | 77 base::OnceClosure task, |
78 base::TimeDelta delay) { | 78 base::TimeDelta delay) { |
79 return task_runner_->PostTask(from_here, std::move(task)); | 79 return task_runner_->PostTask(from_here, std::move(task)); |
80 } | 80 } |
81 | 81 |
82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( | 82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( |
(...skipping 10 matching lines...) Expand all Loading... |
93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { | 93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { |
94 DCHECK(RunsTasksOnCurrentThread()); | 94 DCHECK(RunsTasksOnCurrentThread()); |
95 } | 95 } |
96 | 96 |
97 scoped_refptr<base::SequencedTaskRunner> | 97 scoped_refptr<base::SequencedTaskRunner> |
98 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { | 98 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { |
99 return task_runner_; | 99 return task_runner_; |
100 } | 100 } |
101 | 101 |
102 } // namespace content | 102 } // namespace content |
OLD | NEW |