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_MANAGER_H_ | 5 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/memory/scoped_callback_factory.h" | 16 #include "base/memory/scoped_callback_factory.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "webkit/quota/quota_client.h" | 19 #include "webkit/quota/quota_client.h" |
20 #include "webkit/quota/quota_task.h" | 20 #include "webkit/quota/quota_task.h" |
21 #include "webkit/quota/quota_types.h" | 21 #include "webkit/quota/quota_types.h" |
22 | 22 |
23 class FilePath; | 23 class FilePath; |
24 | 24 |
25 namespace quota { | 25 namespace quota { |
26 | 26 |
27 class QuotaDatabase; | 27 class QuotaDatabase; |
28 class QuotaTemporaryStorageEvictor; | |
28 class UsageTracker; | 29 class UsageTracker; |
29 | 30 |
30 struct QuotaManagerDeleter; | 31 struct QuotaManagerDeleter; |
31 class QuotaManagerProxy; | 32 class QuotaManagerProxy; |
32 | 33 |
33 // The quota manager class. This class is instantiated per profile and | 34 // The quota manager class. This class is instantiated per profile and |
34 // held by the profile. With the exception of the constructor and the | 35 // held by the profile. With the exception of the constructor and the |
35 // proxy() method, all methods should only be called on the IO thread. | 36 // proxy() method, all methods should only be called on the IO thread. |
36 class QuotaManager : public QuotaTaskObserver, | 37 class QuotaManager : public QuotaTaskObserver, |
37 public base::RefCountedThreadSafe< | 38 public base::RefCountedThreadSafe< |
38 QuotaManager, QuotaManagerDeleter> { | 39 QuotaManager, QuotaManagerDeleter> { |
39 public: | 40 public: |
40 typedef Callback3<QuotaStatusCode, | 41 typedef Callback3<QuotaStatusCode, |
41 int64 /* usage */, | 42 int64 /* usage */, |
42 int64 /* quota */>::Type GetUsageAndQuotaCallback; | 43 int64 /* quota */>::Type GetUsageAndQuotaCallback; |
43 typedef Callback2<QuotaStatusCode, | 44 typedef Callback2<QuotaStatusCode, |
44 int64 /* granted_quota */>::Type RequestQuotaCallback; | 45 int64 /* granted_quota */>::Type RequestQuotaCallback; |
46 typedef Callback1<QuotaStatusCode>::Type DeleteOriginDataCallback; | |
45 | 47 |
46 QuotaManager(bool is_incognito, | 48 QuotaManager(bool is_incognito, |
47 const FilePath& profile_path, | 49 const FilePath& profile_path, |
48 scoped_refptr<base::MessageLoopProxy> io_thread, | 50 scoped_refptr<base::MessageLoopProxy> io_thread, |
49 scoped_refptr<base::MessageLoopProxy> db_thread); | 51 scoped_refptr<base::MessageLoopProxy> db_thread); |
50 | 52 |
51 virtual ~QuotaManager(); | 53 virtual ~QuotaManager(); |
52 | 54 |
53 // Returns a proxy object that can be used on any thread. | 55 // Returns a proxy object that can be used on any thread. |
54 QuotaManagerProxy* proxy() { return proxy_.get(); } | 56 QuotaManagerProxy* proxy() { return proxy_.get(); } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 98 |
97 class GlobalUsageQueryTask; | 99 class GlobalUsageQueryTask; |
98 class HostUsageQueryTask; | 100 class HostUsageQueryTask; |
99 | 101 |
100 typedef std::pair<std::string, StorageType> HostAndType; | 102 typedef std::pair<std::string, StorageType> HostAndType; |
101 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 103 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
102 UsageAndQuotaDispatcherTaskMap; | 104 UsageAndQuotaDispatcherTaskMap; |
103 | 105 |
104 friend struct QuotaManagerDeleter; | 106 friend struct QuotaManagerDeleter; |
105 friend class QuotaManagerProxy; | 107 friend class QuotaManagerProxy; |
108 friend class QuotaTemporaryStorageEvictor; | |
106 | 109 |
107 // This initialization method is lazily called on the IO thread | 110 // This initialization method is lazily called on the IO thread |
108 // when the first quota manager API is called. | 111 // when the first quota manager API is called. |
109 // Initialize must be called after all quota clients are added to the | 112 // Initialize must be called after all quota clients are added to the |
110 // manager by RegisterStorage. | 113 // manager by RegisterStorage. |
111 void LazyInitialize(); | 114 void LazyInitialize(); |
112 | 115 |
113 // Called by clients via proxy. | 116 // Called by clients via proxy. |
114 // Registers a quota client to the manager. | 117 // Registers a quota client to the manager. |
115 // The client must remain valid until OnQuotaManagerDestored is called. | 118 // The client must remain valid until OnQuotaManagerDestored is called. |
116 void RegisterClient(QuotaClient* client); | 119 void RegisterClient(QuotaClient* client); |
117 | 120 |
118 // Called by clients via proxy. | 121 // Called by clients via proxy. |
119 // QuotaClients must call this method whenever they have made any | 122 // QuotaClients must call this method whenever they have made any |
120 // modifications that change the amount of data stored in their storage. | 123 // modifications that change the amount of data stored in their storage. |
121 void NotifyStorageModified(QuotaClient::ID client_id, | 124 void NotifyStorageModified(QuotaClient::ID client_id, |
122 const GURL& origin, | 125 const GURL& origin, |
123 StorageType type, | 126 StorageType type, |
124 int64 delta); | 127 int64 delta); |
125 | 128 |
129 // It must be called on the io_thread. | |
130 // It is called from QuotaTemporaryStorageEvictor. | |
131 virtual void DeleteOriginDataOnIOThread( | |
kinuko
2011/05/13 05:49:04
nit: for now all the methods of QuotaManager need
Dai Mikurube (NOT FULLTIME)
2011/05/13 07:52:40
Done.
| |
132 const GURL& origin, | |
133 StorageType type, | |
134 DeleteOriginDataCallback* callback); | |
135 | |
126 UsageTracker* GetUsageTracker(StorageType type) const; | 136 UsageTracker* GetUsageTracker(StorageType type) const; |
127 | 137 |
128 void DidGetTemporaryGlobalQuota(int64 quota); | 138 void DidGetTemporaryGlobalQuota(int64 quota); |
129 | 139 |
130 void DeleteOnCorrectThread() const; | 140 void DeleteOnCorrectThread() const; |
131 | 141 |
132 const bool is_incognito_; | 142 const bool is_incognito_; |
133 const FilePath profile_path_; | 143 const FilePath profile_path_; |
134 | 144 |
135 scoped_refptr<QuotaManagerProxy> proxy_; | 145 scoped_refptr<QuotaManagerProxy> proxy_; |
136 bool db_initialized_; | 146 bool db_initialized_; |
137 bool db_disabled_; | 147 bool db_disabled_; |
138 scoped_refptr<base::MessageLoopProxy> io_thread_; | 148 scoped_refptr<base::MessageLoopProxy> io_thread_; |
139 scoped_refptr<base::MessageLoopProxy> db_thread_; | 149 scoped_refptr<base::MessageLoopProxy> db_thread_; |
140 mutable scoped_ptr<QuotaDatabase> database_; | 150 mutable scoped_ptr<QuotaDatabase> database_; |
141 | 151 |
142 QuotaClientList clients_; | 152 QuotaClientList clients_; |
143 | 153 |
144 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 154 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
145 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 155 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
156 scoped_refptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; | |
146 | 157 |
147 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; | 158 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; |
148 | 159 |
149 int64 temporary_global_quota_; | 160 int64 temporary_global_quota_; |
150 QuotaCallbackQueue temporary_global_quota_callbacks_; | 161 QuotaCallbackQueue temporary_global_quota_callbacks_; |
151 | 162 |
152 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 163 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
153 }; | 164 }; |
154 | 165 |
155 struct QuotaManagerDeleter { | 166 struct QuotaManagerDeleter { |
(...skipping 23 matching lines...) Expand all Loading... | |
179 QuotaManager* manager_; // only accessed on the io thread | 190 QuotaManager* manager_; // only accessed on the io thread |
180 scoped_refptr<base::MessageLoopProxy> io_thread_; | 191 scoped_refptr<base::MessageLoopProxy> io_thread_; |
181 | 192 |
182 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 193 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
183 }; | 194 }; |
184 | 195 |
185 | 196 |
186 } // namespace quota | 197 } // namespace quota |
187 | 198 |
188 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 199 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |