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

Side by Side Diff: webkit/dom_storage/dom_storage_task_runner.h

Issue 9347056: Fix up SequencedWorkerPool in preparation for making it a TaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "base/time.h"
11 12
12 namespace base { 13 namespace base {
13 class MessageLoopProxy; 14 class MessageLoopProxy;
14 } 15 }
15 16
16 namespace dom_storage { 17 namespace dom_storage {
17 18
18 // Tasks must run serially with respect to one another, but may 19 // Tasks must run serially with respect to one another, but may
19 // execute on different OS threads. The base class is implemented 20 // execute on different OS threads. The base class is implemented
20 // in terms of a MessageLoopProxy for use in testing. 21 // in terms of a MessageLoopProxy for use in testing.
21 class DomStorageTaskRunner 22 class DomStorageTaskRunner
22 : public base::RefCountedThreadSafe<DomStorageTaskRunner> { 23 : public base::RefCountedThreadSafe<DomStorageTaskRunner> {
23 public: 24 public:
24 explicit DomStorageTaskRunner(base::MessageLoopProxy* message_loop); 25 explicit DomStorageTaskRunner(
26 const scoped_refptr<base::MessageLoopProxy>& message_loop);
25 virtual ~DomStorageTaskRunner(); 27 virtual ~DomStorageTaskRunner();
26 28
27 // Schedules a task to be run immediately. 29 // Schedules a task to be run immediately.
28 virtual void PostTask( 30 virtual void PostTask(
29 const tracked_objects::Location& from_here, 31 const tracked_objects::Location& from_here,
30 const base::Closure& task); 32 const base::Closure& task);
31 33
32 // Schedules a task to be run after a delay. 34 // Schedules a task to be run after a delay.
33 virtual void PostDelayedTask( 35 virtual void PostDelayedTask(
34 const tracked_objects::Location& from_here, 36 const tracked_objects::Location& from_here,
35 const base::Closure& task, 37 const base::Closure& task,
36 base::TimeDelta delay); 38 base::TimeDelta delay);
37 39
38 protected: 40 protected:
39 scoped_refptr<base::MessageLoopProxy> message_loop_; 41 const scoped_refptr<base::MessageLoopProxy> message_loop_;
40 }; 42 };
41 43
42 // A derived class that utlizes the SequenceWorkerPool under a 44 // A derived class that utlizes the SequenceWorkerPool under a
43 // dom_storage specific SequenceToken. The MessageLoopProxy 45 // dom_storage specific SequenceToken. The MessageLoopProxy
44 // is used to delay scheduling on the worker pool. 46 // is used to delay scheduling on the worker pool.
45 class DomStorageWorkerPoolTaskRunner : public DomStorageTaskRunner { 47 class DomStorageWorkerPoolTaskRunner : public DomStorageTaskRunner {
46 public: 48 public:
47 DomStorageWorkerPoolTaskRunner( 49 DomStorageWorkerPoolTaskRunner(
48 base::SequencedWorkerPool* sequenced_worker_pool, 50 const scoped_refptr<base::SequencedWorkerPool>& sequenced_worker_pool,
49 base::MessageLoopProxy* delayed_task_loop); 51 const scoped_refptr<base::MessageLoopProxy>& delayed_task_loop);
michaeln 2012/02/23 03:55:25 Has our style been changed to require this techniq
akalin 2012/02/23 22:22:30 Done.
50 virtual ~DomStorageWorkerPoolTaskRunner(); 52 virtual ~DomStorageWorkerPoolTaskRunner();
51 53
52 // Schedules a sequenced worker task to be run immediately. 54 // Schedules a sequenced worker task to be run immediately.
53 virtual void PostTask( 55 virtual void PostTask(
54 const tracked_objects::Location& from_here, 56 const tracked_objects::Location& from_here,
55 const base::Closure& task) OVERRIDE; 57 const base::Closure& task) OVERRIDE;
56 58
57 // Schedules a sequenced worker task to be run after a delay. 59 // Schedules a sequenced worker task to be run after a delay.
58 virtual void PostDelayedTask( 60 virtual void PostDelayedTask(
59 const tracked_objects::Location& from_here, 61 const tracked_objects::Location& from_here,
60 const base::Closure& task, 62 const base::Closure& task,
61 base::TimeDelta delay) OVERRIDE; 63 base::TimeDelta delay) OVERRIDE;
62 64
63 private: 65 private:
64 base::SequencedWorkerPool* sequenced_worker_pool_; // not owned 66 const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_;
65 base::SequencedWorkerPool::SequenceToken sequence_token_; 67 base::SequencedWorkerPool::SequenceToken sequence_token_;
66 }; 68 };
67 69
68 } // namespace dom_storage 70 } // namespace dom_storage
69 71
70 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_ 72 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_session.cc ('k') | webkit/dom_storage/dom_storage_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698