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

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

Issue 10416004: RefCounted types should not have public destructors, webkit/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r140259 Created 8 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 | Annotate | Revision Log
« no previous file with comments | « webkit/quota/quota_manager.h ('k') | webkit/quota/quota_temporary_storage_evictor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner_helpers.h"
14 15
15 namespace base { 16 namespace base {
16 class SingleThreadTaskRunner; 17 class SingleThreadTaskRunner;
17 class TaskRunner; 18 class TaskRunner;
18 } 19 }
19 20
20 namespace quota { 21 namespace quota {
21 22
22 class QuotaTaskObserver; 23 class QuotaTaskObserver;
23 class QuotaThreadTask; 24 class QuotaThreadTask;
24 25
25 // A base class for quota tasks. 26 // A base class for quota tasks.
26 // TODO(kinuko): Revise this using base::Callback. 27 // TODO(kinuko): Revise this using base::Callback.
27 class QuotaTask { 28 class QuotaTask {
28 public: 29 public:
29 virtual ~QuotaTask();
30 void Start(); 30 void Start();
31 31
32 protected: 32 protected:
33 explicit QuotaTask(QuotaTaskObserver* observer); 33 explicit QuotaTask(QuotaTaskObserver* observer);
34 virtual ~QuotaTask();
34 35
35 // The task body. 36 // The task body.
36 virtual void Run() = 0; 37 virtual void Run() = 0;
37 38
38 // Called upon completion, on the original message loop. 39 // Called upon completion, on the original message loop.
39 virtual void Completed() = 0; 40 virtual void Completed() = 0;
40 41
41 // Called when the task is aborted. 42 // Called when the task is aborted.
42 virtual void Aborted() {} 43 virtual void Aborted() {}
43 44
44 void CallCompleted(); 45 void CallCompleted();
45 46
46 // Call this to delete itself. 47 // Call this to delete itself.
47 void DeleteSoon(); 48 void DeleteSoon();
48 49
49 QuotaTaskObserver* observer() const { return observer_; } 50 QuotaTaskObserver* observer() const { return observer_; }
50 base::SingleThreadTaskRunner* original_task_runner() const { 51 base::SingleThreadTaskRunner* original_task_runner() const {
51 return original_task_runner_; 52 return original_task_runner_;
52 } 53 }
53 54
54 private: 55 private:
56 friend class base::DeleteHelper<QuotaTask>;
55 friend class QuotaTaskObserver; 57 friend class QuotaTaskObserver;
56 friend class QuotaThreadTask; 58 friend class QuotaThreadTask;
59
57 void Abort(); 60 void Abort();
58 QuotaTaskObserver* observer_; 61 QuotaTaskObserver* observer_;
59 scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_; 62 scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_;
60 }; 63 };
61 64
62 // For tasks that post tasks to the other thread. 65 // For tasks that post tasks to the other thread.
63 class QuotaThreadTask : public QuotaTask, 66 class QuotaThreadTask : public QuotaTask,
64 public base::RefCountedThreadSafe<QuotaThreadTask> { 67 public base::RefCountedThreadSafe<QuotaThreadTask> {
65 public: 68 public:
66 QuotaThreadTask(QuotaTaskObserver* observer, 69 QuotaThreadTask(QuotaTaskObserver* observer,
(...skipping 22 matching lines...) Expand all
89 92
90 private: 93 private:
91 friend class base::RefCountedThreadSafe<QuotaThreadTask>; 94 friend class base::RefCountedThreadSafe<QuotaThreadTask>;
92 friend class QuotaTaskObserver; 95 friend class QuotaTaskObserver;
93 void CallRunOnTargetThread(); 96 void CallRunOnTargetThread();
94 97
95 scoped_refptr<base::TaskRunner> target_task_runner_; 98 scoped_refptr<base::TaskRunner> target_task_runner_;
96 }; 99 };
97 100
98 class QuotaTaskObserver { 101 class QuotaTaskObserver {
99 public:
100 virtual ~QuotaTaskObserver();
101
102 protected: 102 protected:
103 friend class QuotaTask; 103 friend class QuotaTask;
104 friend class QuotaThreadTask; 104 friend class QuotaThreadTask;
105 105
106 QuotaTaskObserver(); 106 QuotaTaskObserver();
107 virtual ~QuotaTaskObserver();
108
107 void RegisterTask(QuotaTask* task); 109 void RegisterTask(QuotaTask* task);
108 void UnregisterTask(QuotaTask* task); 110 void UnregisterTask(QuotaTask* task);
109 111
110 typedef std::set<QuotaTask*> TaskSet; 112 typedef std::set<QuotaTask*> TaskSet;
111 TaskSet running_quota_tasks_; 113 TaskSet running_quota_tasks_;
112 }; 114 };
113 } 115 }
114 116
115 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_ 117 #endif // WEBKIT_QUOTA_QUOTA_TASK_H_
OLDNEW
« no previous file with comments | « webkit/quota/quota_manager.h ('k') | webkit/quota/quota_temporary_storage_evictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698