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> |
(...skipping 16 matching lines...) Expand all Loading... | |
27 class FilePath; | 27 class FilePath; |
28 | 28 |
29 namespace quota { | 29 namespace quota { |
30 | 30 |
31 class QuotaDatabase; | 31 class QuotaDatabase; |
32 class UsageTracker; | 32 class UsageTracker; |
33 | 33 |
34 struct QuotaManagerDeleter; | 34 struct QuotaManagerDeleter; |
35 class QuotaManagerProxy; | 35 class QuotaManagerProxy; |
36 | 36 |
37 // An interface called by QuotaTemporaryStorageEvictor. | |
38 class QuotaEvictionHandler { | |
39 public: | |
40 typedef Callback1<GURL>::Type GetLRUOriginCallback; | |
41 typedef Callback1<QuotaStatusCode>::Type EvictOriginDataCallback; | |
42 typedef Callback4<QuotaStatusCode, | |
43 int64 /* usage */, | |
44 int64 /* quota */, | |
45 int64 /* physical_available */ >::Type | |
46 GetUsageAndQuotaForEvictionCallback; | |
47 | |
48 virtual void GetLRUOrigin( | |
49 StorageType type, | |
50 GetLRUOriginCallback* callback) = 0; | |
51 | |
52 virtual void EvictOriginData( | |
53 const GURL& origin, | |
54 StorageType type, | |
kinuko
2011/05/17 05:05:59
Not very sure we want type parameter here (since n
| |
55 EvictOriginDataCallback* callback) = 0; | |
56 | |
57 virtual void GetUsageAndQuotaForEviction( | |
58 GetUsageAndQuotaForEvictionCallback* callback) = 0; | |
59 }; | |
60 | |
37 // The quota manager class. This class is instantiated per profile and | 61 // The quota manager class. This class is instantiated per profile and |
38 // held by the profile. With the exception of the constructor and the | 62 // held by the profile. With the exception of the constructor and the |
39 // proxy() method, all methods should only be called on the IO thread. | 63 // proxy() method, all methods should only be called on the IO thread. |
40 class QuotaManager : public QuotaTaskObserver, | 64 class QuotaManager : public QuotaTaskObserver, |
65 public QuotaEvictionHandler, | |
41 public base::RefCountedThreadSafe< | 66 public base::RefCountedThreadSafe< |
42 QuotaManager, QuotaManagerDeleter> { | 67 QuotaManager, QuotaManagerDeleter> { |
43 public: | 68 public: |
44 typedef Callback3<QuotaStatusCode, | 69 typedef Callback3<QuotaStatusCode, |
45 int64 /* usage */, | 70 int64 /* usage */, |
46 int64 /* quota */>::Type GetUsageAndQuotaCallback; | 71 int64 /* quota */>::Type GetUsageAndQuotaCallback; |
47 typedef Callback2<QuotaStatusCode, | 72 typedef Callback2<QuotaStatusCode, |
48 int64 /* granted_quota */>::Type RequestQuotaCallback; | 73 int64 /* granted_quota */>::Type RequestQuotaCallback; |
49 typedef Callback1<GURL>::Type GetLRUOriginCallback; | |
50 | 74 |
51 QuotaManager(bool is_incognito, | 75 QuotaManager(bool is_incognito, |
52 const FilePath& profile_path, | 76 const FilePath& profile_path, |
53 base::MessageLoopProxy* io_thread, | 77 base::MessageLoopProxy* io_thread, |
54 base::MessageLoopProxy* db_thread); | 78 base::MessageLoopProxy* db_thread); |
55 | 79 |
56 virtual ~QuotaManager(); | 80 virtual ~QuotaManager(); |
57 | 81 |
58 // Returns a proxy object that can be used on any thread. | 82 // Returns a proxy object that can be used on any thread. |
59 QuotaManagerProxy* proxy() { return proxy_.get(); } | 83 QuotaManagerProxy* proxy() { return proxy_.get(); } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // Registers a quota client to the manager. | 167 // Registers a quota client to the manager. |
144 // The client must remain valid until OnQuotaManagerDestored is called. | 168 // The client must remain valid until OnQuotaManagerDestored is called. |
145 void RegisterClient(QuotaClient* client); | 169 void RegisterClient(QuotaClient* client); |
146 | 170 |
147 UsageTracker* GetUsageTracker(StorageType type) const; | 171 UsageTracker* GetUsageTracker(StorageType type) const; |
148 | 172 |
149 void DidGetTemporaryGlobalQuota(int64 quota); | 173 void DidGetTemporaryGlobalQuota(int64 quota); |
150 | 174 |
151 // Methods for eviction logic. | 175 // Methods for eviction logic. |
152 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 176 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
153 void GetLRUOrigin(StorageType type, GetLRUOriginCallback* callback); | 177 |
178 virtual void GetLRUOrigin( | |
179 StorageType type, | |
180 GetLRUOriginCallback* callback) OVERRIDE; | |
181 virtual void EvictOriginData( | |
182 const GURL& origin, | |
183 StorageType type, | |
184 EvictOriginDataCallback* callback) OVERRIDE; | |
185 virtual void GetUsageAndQuotaForEviction( | |
186 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; | |
154 | 187 |
155 void DeleteOnCorrectThread() const; | 188 void DeleteOnCorrectThread() const; |
156 | 189 |
157 const bool is_incognito_; | 190 const bool is_incognito_; |
158 const FilePath profile_path_; | 191 const FilePath profile_path_; |
159 | 192 |
160 scoped_refptr<QuotaManagerProxy> proxy_; | 193 scoped_refptr<QuotaManagerProxy> proxy_; |
161 bool db_disabled_; | 194 bool db_disabled_; |
162 scoped_refptr<base::MessageLoopProxy> io_thread_; | 195 scoped_refptr<base::MessageLoopProxy> io_thread_; |
163 scoped_refptr<base::MessageLoopProxy> db_thread_; | 196 scoped_refptr<base::MessageLoopProxy> db_thread_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 QuotaManager* manager_; // only accessed on the io thread | 247 QuotaManager* manager_; // only accessed on the io thread |
215 scoped_refptr<base::MessageLoopProxy> io_thread_; | 248 scoped_refptr<base::MessageLoopProxy> io_thread_; |
216 | 249 |
217 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 250 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
218 }; | 251 }; |
219 | 252 |
220 | 253 |
221 } // namespace quota | 254 } // namespace quota |
222 | 255 |
223 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 256 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |