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

Side by Side Diff: webkit/quota/quota_task.h

Issue 11091042: Converted GetOriginsForHostTask to use base::PostTaskAndReply(). Deleted superclasses GetOriginsTas… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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_QUOTA_QUOTA_TASK_H_ 5 #ifndef WEBKIT_QUOTA_QUOTA_TASK_H_
6 #define WEBKIT_QUOTA_QUOTA_TASK_H_ 6 #define WEBKIT_QUOTA_QUOTA_TASK_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/sequenced_task_runner_helpers.h" 13 #include "base/sequenced_task_runner_helpers.h"
14 14
15 namespace base { 15 namespace base {
16 class SingleThreadTaskRunner; 16 class SingleThreadTaskRunner;
17 class TaskRunner; 17 class TaskRunner;
18 } 18 }
19 19
20 namespace quota { 20 namespace quota {
21 21
22 class QuotaTaskObserver; 22 class QuotaTaskObserver;
23 class QuotaThreadTask;
24 23
25 // A base class for quota tasks. 24 // A base class for quota tasks.
26 // TODO(kinuko): Revise this using base::Callback. 25 // TODO(kinuko): Revise this using base::Callback.
27 class QuotaTask { 26 class QuotaTask {
28 public: 27 public:
29 void Start(); 28 void Start();
30 29
31 protected: 30 protected:
32 explicit QuotaTask(QuotaTaskObserver* observer); 31 explicit QuotaTask(QuotaTaskObserver* observer);
33 virtual ~QuotaTask(); 32 virtual ~QuotaTask();
(...skipping 13 matching lines...) Expand all
47 void DeleteSoon(); 46 void DeleteSoon();
48 47
49 QuotaTaskObserver* observer() const { return observer_; } 48 QuotaTaskObserver* observer() const { return observer_; }
50 base::SingleThreadTaskRunner* original_task_runner() const { 49 base::SingleThreadTaskRunner* original_task_runner() const {
51 return original_task_runner_; 50 return original_task_runner_;
52 } 51 }
53 52
54 private: 53 private:
55 friend class base::DeleteHelper<QuotaTask>; 54 friend class base::DeleteHelper<QuotaTask>;
56 friend class QuotaTaskObserver; 55 friend class QuotaTaskObserver;
57 friend class QuotaThreadTask;
58 56
59 void Abort(); 57 void Abort();
60 QuotaTaskObserver* observer_; 58 QuotaTaskObserver* observer_;
61 scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_;
62 bool delete_scheduled_; 60 bool delete_scheduled_;
63 }; 61 };
64 62
65 // For tasks that post tasks to the other thread.
66 class QuotaThreadTask : public QuotaTask,
67 public base::RefCountedThreadSafe<QuotaThreadTask> {
68 public:
69 QuotaThreadTask(QuotaTaskObserver* observer,
70 base::TaskRunner* target_task_runner);
71
72 protected:
73 virtual ~QuotaThreadTask();
74
75 // One of the following Run methods should be overridden for execution
76 // on the target thread.
77
78 // A task to invoke the CallCompleted() method on the original thread will
79 // be scheduled immediately upon return from RunOnTargetThread().
80 virtual void RunOnTargetThread();
81
82 // A task to invoke the CallCompleted() method on the original thread will
83 // only be scheduled if RunOnTargetThreadAsync returns true. If false is
84 // returned, the derived class should schedule a task to do so upon actual
85 // completion.
86 virtual bool RunOnTargetThreadAsync();
87
88 virtual void Run() OVERRIDE;
89 base::TaskRunner* target_task_runner() const {
90 return target_task_runner_;
91 }
92
93 private:
94 friend class base::RefCountedThreadSafe<QuotaThreadTask>;
95 friend class QuotaTaskObserver;
96 void CallRunOnTargetThread();
97
98 scoped_refptr<base::TaskRunner> target_task_runner_;
99 };
100
101 class QuotaTaskObserver { 63 class QuotaTaskObserver {
102 protected: 64 protected:
103 friend class QuotaTask; 65 friend class QuotaTask;
104 friend class QuotaThreadTask;
105 66
106 QuotaTaskObserver(); 67 QuotaTaskObserver();
107 virtual ~QuotaTaskObserver(); 68 virtual ~QuotaTaskObserver();
108 69
109 void RegisterTask(QuotaTask* task); 70 void RegisterTask(QuotaTask* task);
110 void UnregisterTask(QuotaTask* task); 71 void UnregisterTask(QuotaTask* task);
111 72
112 typedef std::set<QuotaTask*> TaskSet; 73 typedef std::set<QuotaTask*> TaskSet;
113 TaskSet running_quota_tasks_; 74 TaskSet running_quota_tasks_;
114 }; 75 };
115 } 76 }
116 77
117 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_ 78 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_quota_client.cc ('k') | webkit/quota/quota_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698