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

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

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
12 #include "base/time/time.h" 11 #include "base/time/time.h"
13 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
14 13
15 namespace base { 14 namespace base {
16 class SingleThreadTaskRunner; 15 class MessageLoopProxy;
17 } 16 }
18 17
19 namespace content { 18 namespace content {
20 19
21 // DOMStorage uses two task sequences (primary vs commit) to avoid 20 // DOMStorage uses two task sequences (primary vs commit) to avoid
22 // primary access from queuing up behind commits to disk. 21 // primary access from queuing up behind commits to disk.
23 // * Initialization, shutdown, and administrative tasks are performed as 22 // * Initialization, shutdown, and administrative tasks are performed as
24 // shutdown-blocking primary sequence tasks. 23 // shutdown-blocking primary sequence tasks.
25 // * Tasks directly related to the javascript'able interface are performed 24 // * Tasks directly related to the javascript'able interface are performed
26 // as shutdown-blocking primary sequence tasks. 25 // as shutdown-blocking primary sequence tasks.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // A derived class used in chromium that utilizes a SequenceWorkerPool 66 // A derived class used in chromium that utilizes a SequenceWorkerPool
68 // under dom_storage specific SequenceTokens. The |delayed_task_loop| 67 // under dom_storage specific SequenceTokens. The |delayed_task_loop|
69 // is used to delay scheduling on the worker pool. 68 // is used to delay scheduling on the worker pool.
70 class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : 69 class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner :
71 public DOMStorageTaskRunner { 70 public DOMStorageTaskRunner {
72 public: 71 public:
73 DOMStorageWorkerPoolTaskRunner( 72 DOMStorageWorkerPoolTaskRunner(
74 base::SequencedWorkerPool* sequenced_worker_pool, 73 base::SequencedWorkerPool* sequenced_worker_pool,
75 base::SequencedWorkerPool::SequenceToken primary_sequence_token, 74 base::SequencedWorkerPool::SequenceToken primary_sequence_token,
76 base::SequencedWorkerPool::SequenceToken commit_sequence_token, 75 base::SequencedWorkerPool::SequenceToken commit_sequence_token,
77 base::SingleThreadTaskRunner* delayed_task_task_runner); 76 base::MessageLoopProxy* delayed_task_loop);
78 77
79 bool PostDelayedTask(const tracked_objects::Location& from_here, 78 bool PostDelayedTask(const tracked_objects::Location& from_here,
80 const base::Closure& task, 79 const base::Closure& task,
81 base::TimeDelta delay) override; 80 base::TimeDelta delay) override;
82 81
83 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, 82 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here,
84 SequenceID sequence_id, 83 SequenceID sequence_id,
85 const base::Closure& task) override; 84 const base::Closure& task) override;
86 85
87 bool IsRunningOnSequence(SequenceID sequence_id) const override; 86 bool IsRunningOnSequence(SequenceID sequence_id) const override;
88 87
89 protected: 88 protected:
90 ~DOMStorageWorkerPoolTaskRunner() override; 89 ~DOMStorageWorkerPoolTaskRunner() override;
91 90
92 private: 91 private:
93 92
94 base::SequencedWorkerPool::SequenceToken IDtoToken(SequenceID id) const; 93 base::SequencedWorkerPool::SequenceToken IDtoToken(SequenceID id) const;
95 94
96 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 95 const scoped_refptr<base::MessageLoopProxy> message_loop_;
97 const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; 96 const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_;
98 base::SequencedWorkerPool::SequenceToken primary_sequence_token_; 97 base::SequencedWorkerPool::SequenceToken primary_sequence_token_;
99 base::SequencedWorkerPool::SequenceToken commit_sequence_token_; 98 base::SequencedWorkerPool::SequenceToken commit_sequence_token_;
100 }; 99 };
101 100
102 // A derived class used in unit tests that ignores all delays so 101 // A derived class used in unit tests that ignores all delays so
103 // we don't block in unit tests waiting for timeouts to expire. 102 // we don't block in unit tests waiting for timeouts to expire.
104 // There is no distinction between [non]-shutdown-blocking or 103 // There is no distinction between [non]-shutdown-blocking or
105 // the primary sequence vs the commit sequence in the mock, 104 // the primary sequence vs the commit sequence in the mock,
106 // all tasks are scheduled on |message_loop| with zero delay. 105 // all tasks are scheduled on |message_loop| with zero delay.
107 class CONTENT_EXPORT MockDOMStorageTaskRunner : 106 class CONTENT_EXPORT MockDOMStorageTaskRunner :
108 public DOMStorageTaskRunner { 107 public DOMStorageTaskRunner {
109 public: 108 public:
110 explicit MockDOMStorageTaskRunner(base::SingleThreadTaskRunner* task_runner); 109 explicit MockDOMStorageTaskRunner(base::MessageLoopProxy* message_loop);
111 110
112 bool PostDelayedTask(const tracked_objects::Location& from_here, 111 bool PostDelayedTask(const tracked_objects::Location& from_here,
113 const base::Closure& task, 112 const base::Closure& task,
114 base::TimeDelta delay) override; 113 base::TimeDelta delay) override;
115 114
116 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here, 115 bool PostShutdownBlockingTask(const tracked_objects::Location& from_here,
117 SequenceID sequence_id, 116 SequenceID sequence_id,
118 const base::Closure& task) override; 117 const base::Closure& task) override;
119 118
120 bool IsRunningOnSequence(SequenceID sequence_id) const override; 119 bool IsRunningOnSequence(SequenceID sequence_id) const override;
121 120
122 protected: 121 protected:
123 ~MockDOMStorageTaskRunner() override; 122 ~MockDOMStorageTaskRunner() override;
124 123
125 private: 124 private:
126 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 125 const scoped_refptr<base::MessageLoopProxy> message_loop_;
127 }; 126 };
128 127
129 } // namespace content 128 } // namespace content
130 129
131 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ 130 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | content/browser/dom_storage/dom_storage_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698