OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // For tasks that post tasks to the other thread. | 59 // For tasks that post tasks to the other thread. |
60 class QuotaThreadTask : public QuotaTask, | 60 class QuotaThreadTask : public QuotaTask, |
61 public base::RefCountedThreadSafe<QuotaThreadTask> { | 61 public base::RefCountedThreadSafe<QuotaThreadTask> { |
62 public: | 62 public: |
63 QuotaThreadTask(QuotaTaskObserver* observer, | 63 QuotaThreadTask(QuotaTaskObserver* observer, |
64 scoped_refptr<base::MessageLoopProxy> target_message_loop); | 64 scoped_refptr<base::MessageLoopProxy> target_message_loop); |
65 | 65 |
66 protected: | 66 protected: |
67 virtual ~QuotaThreadTask(); | 67 virtual ~QuotaThreadTask(); |
68 | 68 |
69 // Called on the target message loop. | 69 // One of the following Run methods should be overriden for execution |
70 virtual void RunOnTargetThread() = 0; | 70 // on the target thread. |
| 71 |
| 72 // A task to invoke the CallCompleted() method on the original thread will |
| 73 // be scheduled immediately upon return from RunOnTargetThread(). |
| 74 virtual void RunOnTargetThread(); |
| 75 |
| 76 // A task to invoke the CallCompleted() method on the original thread will |
| 77 // only be scheduled if RunOnTargetThreadAsync returns true. If false is |
| 78 // returned, the derived class should schedule a task to do so upon actual |
| 79 // completion. |
| 80 virtual bool RunOnTargetThreadAsync(); |
71 | 81 |
72 virtual void Run() OVERRIDE; | 82 virtual void Run() OVERRIDE; |
73 scoped_refptr<base::MessageLoopProxy> target_message_loop() const { | 83 scoped_refptr<base::MessageLoopProxy> target_message_loop() const { |
74 return target_message_loop_; | 84 return target_message_loop_; |
75 } | 85 } |
76 | 86 |
77 private: | 87 private: |
78 friend class base::RefCountedThreadSafe<QuotaThreadTask>; | 88 friend class base::RefCountedThreadSafe<QuotaThreadTask>; |
79 friend class QuotaTaskObserver; | 89 friend class QuotaTaskObserver; |
80 void CallRunOnTargetThread(); | 90 void CallRunOnTargetThread(); |
(...skipping 12 matching lines...) Expand all Loading... |
93 QuotaTaskObserver(); | 103 QuotaTaskObserver(); |
94 void RegisterTask(QuotaTask* task); | 104 void RegisterTask(QuotaTask* task); |
95 void UnregisterTask(QuotaTask* task); | 105 void UnregisterTask(QuotaTask* task); |
96 | 106 |
97 typedef std::set<QuotaTask*> TaskSet; | 107 typedef std::set<QuotaTask*> TaskSet; |
98 TaskSet running_quota_tasks_; | 108 TaskSet running_quota_tasks_; |
99 }; | 109 }; |
100 } | 110 } |
101 | 111 |
102 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_ | 112 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_ |
OLD | NEW |