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

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

Issue 2317253007: Remove calls to IsRunningSequenceOnCurrentThread() from dom_storage_task_runner.cc (Closed)
Patch Set: Created 4 years, 3 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 | « content/browser/dom_storage/dom_storage_task_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h"
10 #include "base/tracked_objects.h" 11 #include "base/tracked_objects.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 // DOMStorageTaskRunner
15
16 bool DOMStorageTaskRunner::RunsTasksOnCurrentThread() const {
17 return IsRunningOnSequence(PRIMARY_SEQUENCE);
18 }
19
20 // DOMStorageWorkerPoolTaskRunner 15 // DOMStorageWorkerPoolTaskRunner
21 16
22 DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner( 17 DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner(
23 base::SequencedWorkerPool* sequenced_worker_pool, 18 base::SequencedWorkerPool* sequenced_worker_pool,
24 base::SequencedWorkerPool::SequenceToken primary_sequence_token, 19 base::SequencedWorkerPool::SequenceToken primary_sequence_token,
25 base::SequencedWorkerPool::SequenceToken commit_sequence_token, 20 base::SequencedWorkerPool::SequenceToken commit_sequence_token,
26 base::SingleThreadTaskRunner* delayed_task_task_runner) 21 base::SingleThreadTaskRunner* delayed_task_task_runner)
27 : task_runner_(delayed_task_task_runner), 22 : task_runner_(delayed_task_task_runner),
28 sequenced_worker_pool_(sequenced_worker_pool), 23 sequenced_worker_pool_(sequenced_worker_pool),
29 primary_sequence_token_(primary_sequence_token), 24 primary_sequence_token_(primary_sequence_token),
30 commit_sequence_token_(commit_sequence_token) { 25 commit_sequence_token_(commit_sequence_token) {
26 primary_sequence_checker_.DetachFromSequence();
27 commit_sequence_checker_.DetachFromSequence();
31 } 28 }
32 29
33 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() { 30 DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() {
34 } 31 }
35 32
33 bool DOMStorageWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
34 return sequenced_worker_pool_->RunsTasksOnCurrentThread();
michaeln 2016/09/12 22:49:17 i think you've changed the semantics of this metho
fdoray 2016/09/13 14:24:13 This method is part of the TaskRunner interface ht
michaeln 2016/09/14 00:35:12 The base class is too abstract to provide a full d
fdoray 2016/09/14 13:23:53 Done
35 }
36
36 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask( 37 bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask(
37 const tracked_objects::Location& from_here, 38 const tracked_objects::Location& from_here,
38 const base::Closure& task, 39 const base::Closure& task,
39 base::TimeDelta delay) { 40 base::TimeDelta delay) {
40 // Note base::TaskRunner implements PostTask in terms of PostDelayedTask 41 // Note base::TaskRunner implements PostTask in terms of PostDelayedTask
41 // with a delay of zero, we detect that usage and avoid the unecessary 42 // with a delay of zero, we detect that usage and avoid the unecessary
42 // trip thru the message loop. 43 // trip thru the message loop.
43 if (delay.is_zero()) { 44 if (delay.is_zero()) {
44 return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior( 45 return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior(
45 primary_sequence_token_, from_here, task, 46 primary_sequence_token_, from_here, task,
46 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 47 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
47 } 48 }
48 // Post a task to call this->PostTask() after the delay. 49 // Post a task to call this->PostTask() after the delay.
49 return task_runner_->PostDelayedTask( 50 return task_runner_->PostDelayedTask(
50 FROM_HERE, 51 FROM_HERE,
51 base::Bind(base::IgnoreResult(&DOMStorageWorkerPoolTaskRunner::PostTask), 52 base::Bind(base::IgnoreResult(&DOMStorageWorkerPoolTaskRunner::PostTask),
52 this, from_here, task), 53 this, from_here, task),
53 delay); 54 delay);
54 } 55 }
55 56
56 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask( 57 bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask(
57 const tracked_objects::Location& from_here, 58 const tracked_objects::Location& from_here,
58 SequenceID sequence_id, 59 SequenceID sequence_id,
59 const base::Closure& task) { 60 const base::Closure& task) {
60 return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior( 61 return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior(
61 IDtoToken(sequence_id), from_here, task, 62 IDtoToken(sequence_id), from_here, task,
62 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 63 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
63 } 64 }
64 65
65 bool DOMStorageWorkerPoolTaskRunner::IsRunningOnSequence( 66 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const {
66 SequenceID sequence_id) const { 67 DCHECK(primary_sequence_checker_.CalledOnValidSequence());
67 return sequenced_worker_pool_->IsRunningSequenceOnCurrentThread( 68 }
michaeln 2016/09/12 22:49:17 wdyt about changing the impl w/o changing the publ
fdoray 2016/09/13 14:24:13 SequenceChecker::CalledOnValidThread() always retu
michaeln 2016/09/14 00:35:12 Surprising? Ok, I agree given the lack of the actu
fdoray 2016/09/14 13:23:53 Done. I rewrote the last paragraph of the CL descr
68 IDtoToken(sequence_id)); 69
70 void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const {
71 DCHECK(commit_sequence_checker_.CalledOnValidSequence());
69 } 72 }
70 73
71 scoped_refptr<base::SequencedTaskRunner> 74 scoped_refptr<base::SequencedTaskRunner>
72 DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { 75 DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) {
73 return sequenced_worker_pool_->GetSequencedTaskRunner(IDtoToken(sequence_id)); 76 return sequenced_worker_pool_->GetSequencedTaskRunner(IDtoToken(sequence_id));
74 } 77 }
75 78
76 base::SequencedWorkerPool::SequenceToken 79 base::SequencedWorkerPool::SequenceToken
77 DOMStorageWorkerPoolTaskRunner::IDtoToken(SequenceID id) const { 80 DOMStorageWorkerPoolTaskRunner::IDtoToken(SequenceID id) const {
78 if (id == PRIMARY_SEQUENCE) 81 if (id == PRIMARY_SEQUENCE)
79 return primary_sequence_token_; 82 return primary_sequence_token_;
80 DCHECK_EQ(COMMIT_SEQUENCE, id); 83 DCHECK_EQ(COMMIT_SEQUENCE, id);
81 return commit_sequence_token_; 84 return commit_sequence_token_;
82 } 85 }
83 86
84 // MockDOMStorageTaskRunner 87 // MockDOMStorageTaskRunner
85 88
86 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( 89 MockDOMStorageTaskRunner::MockDOMStorageTaskRunner(
87 base::SingleThreadTaskRunner* task_runner) 90 base::SingleThreadTaskRunner* task_runner)
88 : task_runner_(task_runner) { 91 : task_runner_(task_runner) {
89 } 92 }
90 93
91 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() { 94 MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() {
92 } 95 }
93 96
97 bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const {
98 return task_runner_->RunsTasksOnCurrentThread();
99 }
100
94 bool MockDOMStorageTaskRunner::PostDelayedTask( 101 bool MockDOMStorageTaskRunner::PostDelayedTask(
95 const tracked_objects::Location& from_here, 102 const tracked_objects::Location& from_here,
96 const base::Closure& task, 103 const base::Closure& task,
97 base::TimeDelta delay) { 104 base::TimeDelta delay) {
98 return task_runner_->PostTask(from_here, task); 105 return task_runner_->PostTask(from_here, task);
99 } 106 }
100 107
101 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( 108 bool MockDOMStorageTaskRunner::PostShutdownBlockingTask(
102 const tracked_objects::Location& from_here, 109 const tracked_objects::Location& from_here,
103 SequenceID sequence_id, 110 SequenceID sequence_id,
104 const base::Closure& task) { 111 const base::Closure& task) {
105 return task_runner_->PostTask(from_here, task); 112 return task_runner_->PostTask(from_here, task);
106 } 113 }
107 114
108 bool MockDOMStorageTaskRunner::IsRunningOnSequence(SequenceID) const { 115 void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const {
109 return task_runner_->RunsTasksOnCurrentThread(); 116 DCHECK(RunsTasksOnCurrentThread());
117 }
118
119 void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const {
120 DCHECK(RunsTasksOnCurrentThread());
110 } 121 }
111 122
112 scoped_refptr<base::SequencedTaskRunner> 123 scoped_refptr<base::SequencedTaskRunner>
113 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { 124 MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) {
114 return task_runner_; 125 return task_runner_;
115 } 126 }
116 127
117 } // namespace content 128 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698