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::RunsTasksInCurrentSequence() const { | 27 bool DOMStorageWorkerPoolTaskRunner::RunsTasksInCurrentSequence() const { |
28 return primary_sequence_->RunsTasksOnCurrentThread() || | 28 return primary_sequence_->RunsTasksInCurrentSequence() || |
29 commit_sequence_->RunsTasksOnCurrentThread(); | 29 commit_sequence_->RunsTasksInCurrentSequence(); |
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( |
40 const tracked_objects::Location& from_here, | 40 const tracked_objects::Location& from_here, |
41 SequenceID sequence_id, | 41 SequenceID sequence_id, |
42 base::OnceClosure task) { | 42 base::OnceClosure task) { |
43 return GetSequencedTaskRunner(sequence_id) | 43 return GetSequencedTaskRunner(sequence_id) |
44 ->PostTask(from_here, std::move(task)); | 44 ->PostTask(from_here, std::move(task)); |
45 } | 45 } |
46 | 46 |
47 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const { | 47 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const { |
48 DCHECK(primary_sequence_->RunsTasksOnCurrentThread()); | 48 DCHECK(primary_sequence_->RunsTasksInCurrentSequence()); |
49 } | 49 } |
50 | 50 |
51 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const { | 51 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const { |
52 DCHECK(commit_sequence_->RunsTasksOnCurrentThread()); | 52 DCHECK(commit_sequence_->RunsTasksInCurrentSequence()); |
53 } | 53 } |
54 | 54 |
55 scoped_refptr<base::SequencedTaskRunner> | 55 scoped_refptr<base::SequencedTaskRunner> |
56 DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { | 56 DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { |
57 if (sequence_id == PRIMARY_SEQUENCE) | 57 if (sequence_id == PRIMARY_SEQUENCE) |
58 return primary_sequence_; | 58 return primary_sequence_; |
59 DCHECK_EQ(COMMIT_SEQUENCE, sequence_id); | 59 DCHECK_EQ(COMMIT_SEQUENCE, sequence_id); |
60 return commit_sequence_; | 60 return commit_sequence_; |
61 } | 61 } |
62 | 62 |
(...skipping 17 matching lines...) Expand all Loading... |
80 } | 80 } |
81 | 81 |
82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( | 82 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( |
83 const tracked_objects::Location& from_here, | 83 const tracked_objects::Location& from_here, |
84 SequenceID sequence_id, | 84 SequenceID sequence_id, |
85 base::OnceClosure task) { | 85 base::OnceClosure task) { |
86 return task_runner_->PostTask(from_here, std::move(task)); | 86 return task_runner_->PostTask(from_here, std::move(task)); |
87 } | 87 } |
88 | 88 |
89 void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const { | 89 void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const { |
90 DCHECK(RunsTasksOnCurrentThread()); | 90 DCHECK(RunsTasksInCurrentSequence()); |
91 } | 91 } |
92 | 92 |
93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { | 93 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { |
94 DCHECK(RunsTasksOnCurrentThread()); | 94 DCHECK(RunsTasksInCurrentSequence()); |
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 |