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

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

Issue 7029007: Implement EvictOriginData in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated. Created 9 years, 7 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 | « no previous file | webkit/quota/quota_manager.cc » ('j') | webkit/quota/quota_manager.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 #include "webkit/quota/quota_types.h" 22 #include "webkit/quota/quota_types.h"
23 23
24 namespace base { 24 namespace base {
25 class MessageLoopProxy; 25 class MessageLoopProxy;
26 } 26 }
27 class FilePath; 27 class FilePath;
28 28
29 namespace quota { 29 namespace quota {
30 30
31 class QuotaDatabase; 31 class QuotaDatabase;
32 class QuotaTemporaryStorageEvictor;
32 class UsageTracker; 33 class UsageTracker;
33 34
34 struct QuotaManagerDeleter; 35 struct QuotaManagerDeleter;
35 class QuotaManagerProxy; 36 class QuotaManagerProxy;
36 37
37 // An interface called by QuotaTemporaryStorageEvictor. 38 // An interface called by QuotaTemporaryStorageEvictor.
38 class QuotaEvictionHandler { 39 class QuotaEvictionHandler {
39 public: 40 public:
40 typedef Callback1<GURL>::Type GetLRUOriginCallback; 41 typedef Callback1<GURL>::Type GetLRUOriginCallback;
41 typedef Callback4<QuotaStatusCode, 42 typedef Callback4<QuotaStatusCode,
42 int64 /* usage */, 43 int64 /* usage */,
43 int64 /* quota */, 44 int64 /* quota */,
44 int64 /* physical_avail */ >::Type DeleteOriginDataCallback; 45 int64 /* physical_avail */ >::Type DeleteOriginDataCallback;
45 46
46 virtual void GetUsageAndQuotaForEviction( 47 virtual void GetUsageAndQuotaForEviction(
47 DeleteOriginDataCallback* callback) = 0; 48 DeleteOriginDataCallback* callback) = 0;
48 49
49 virtual void DeleteOriginData( 50 virtual void DeleteOriginData(
michaeln 2011/05/17 00:19:45 Delete sounds more generic than this really is giv
Dai Mikurube (NOT FULLTIME) 2011/05/17 09:18:40 Done.
50 const GURL& origin, 51 const GURL& origin,
51 StorageType type, 52 StorageType type,
52 DeleteOriginDataCallback* callback) = 0; 53 DeleteOriginDataCallback* callback) = 0;
53 54
54 virtual void GetLRUOrigin( 55 virtual void GetLRUOrigin(
55 StorageType type, 56 StorageType type,
56 GetLRUOriginCallback* callback) = 0; 57 GetLRUOriginCallback* callback) = 0;
57 }; 58 };
58 59
59 // The quota manager class. This class is instantiated per profile and 60 // The quota manager class. This class is instantiated per profile and
60 // held by the profile. With the exception of the constructor and the 61 // held by the profile. With the exception of the constructor and the
61 // proxy() method, all methods should only be called on the IO thread. 62 // proxy() method, all methods should only be called on the IO thread.
62 class QuotaManager : public QuotaTaskObserver, 63 class QuotaManager : public QuotaTaskObserver,
64 public QuotaEvictionHandler,
63 public base::RefCountedThreadSafe< 65 public base::RefCountedThreadSafe<
64 QuotaManager, QuotaManagerDeleter> { 66 QuotaManager, QuotaManagerDeleter> {
65 public: 67 public:
66 typedef Callback3<QuotaStatusCode, 68 typedef Callback3<QuotaStatusCode,
67 int64 /* usage */, 69 int64 /* usage */,
68 int64 /* quota */>::Type GetUsageAndQuotaCallback; 70 int64 /* quota */>::Type GetUsageAndQuotaCallback;
69 typedef Callback2<QuotaStatusCode, 71 typedef Callback2<QuotaStatusCode,
70 int64 /* granted_quota */>::Type RequestQuotaCallback; 72 int64 /* granted_quota */>::Type RequestQuotaCallback;
71 typedef Callback1<GURL>::Type GetLRUOriginCallback;
72 73
73 QuotaManager(bool is_incognito, 74 QuotaManager(bool is_incognito,
74 const FilePath& profile_path, 75 const FilePath& profile_path,
75 base::MessageLoopProxy* io_thread, 76 base::MessageLoopProxy* io_thread,
76 base::MessageLoopProxy* db_thread); 77 base::MessageLoopProxy* db_thread);
77 78
78 virtual ~QuotaManager(); 79 virtual ~QuotaManager();
79 80
80 // Returns a proxy object that can be used on any thread. 81 // Returns a proxy object that can be used on any thread.
81 QuotaManagerProxy* proxy() { return proxy_.get(); } 82 QuotaManagerProxy* proxy() { return proxy_.get(); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void GetPersistentHostQuota(const std::string& host, 123 void GetPersistentHostQuota(const std::string& host,
123 HostQuotaCallback* callback); 124 HostQuotaCallback* callback);
124 void SetPersistentHostQuota(const std::string& host, 125 void SetPersistentHostQuota(const std::string& host,
125 int64 new_quota, 126 int64 new_quota,
126 HostQuotaCallback* callback); 127 HostQuotaCallback* callback);
127 128
128 void GetGlobalUsage(StorageType type, UsageCallback* callback); 129 void GetGlobalUsage(StorageType type, UsageCallback* callback);
129 void GetHostUsage(const std::string& host, StorageType type, 130 void GetHostUsage(const std::string& host, StorageType type,
130 HostUsageCallback* callback); 131 HostUsageCallback* callback);
131 132
133 // TODO(dmikurube): Make it a friend?
134 void RegisterTemporaryStorageEvictor(
135 scoped_refptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor);
136
132 static const int64 kTemporaryStorageQuotaDefaultSize; 137 static const int64 kTemporaryStorageQuotaDefaultSize;
133 static const int64 kTemporaryStorageQuotaMaxSize; 138 static const int64 kTemporaryStorageQuotaMaxSize;
134 static const char kDatabaseName[]; 139 static const char kDatabaseName[];
135 140
136 static const int64 kIncognitoDefaultTemporaryQuota; 141 static const int64 kIncognitoDefaultTemporaryQuota;
137 142
138 private: 143 private:
139 class InitializeTask; 144 class InitializeTask;
140 class TemporaryGlobalQuotaUpdateTask; 145 class TemporaryGlobalQuotaUpdateTask;
141 class PersistentHostQuotaUpdateTask; 146 class PersistentHostQuotaUpdateTask;
142 class PersistentHostQuotaQueryTask; 147 class PersistentHostQuotaQueryTask;
143 class GetLRUOriginTask; 148 class GetLRUOriginTask;
144 149
145 class UsageAndQuotaDispatcherTask; 150 class UsageAndQuotaDispatcherTask;
146 class UsageAndQuotaDispatcherTaskForTemporary; 151 class UsageAndQuotaDispatcherTaskForTemporary;
147 class UsageAndQuotaDispatcherTaskForPersistent; 152 class UsageAndQuotaDispatcherTaskForPersistent;
148 153
149 typedef std::pair<std::string, StorageType> HostAndType; 154 typedef std::pair<std::string, StorageType> HostAndType;
150 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> 155 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*>
151 UsageAndQuotaDispatcherTaskMap; 156 UsageAndQuotaDispatcherTaskMap;
152 157
153 friend struct QuotaManagerDeleter; 158 friend struct QuotaManagerDeleter;
154 friend class QuotaManagerProxy; 159 friend class QuotaManagerProxy;
160 friend class QuotaTemporaryStorageEvictor;
155 161
156 // This initialization method is lazily called on the IO thread 162 // This initialization method is lazily called on the IO thread
157 // when the first quota manager API is called. 163 // when the first quota manager API is called.
158 // Initialize must be called after all quota clients are added to the 164 // Initialize must be called after all quota clients are added to the
159 // manager by RegisterStorage. 165 // manager by RegisterStorage.
160 void LazyInitialize(); 166 void LazyInitialize();
161 167
162 // Called by clients via proxy. 168 // Called by clients via proxy.
163 // Registers a quota client to the manager. 169 // Registers a quota client to the manager.
164 // The client must remain valid until OnQuotaManagerDestored is called. 170 // The client must remain valid until OnQuotaManagerDestored is called.
165 void RegisterClient(QuotaClient* client); 171 void RegisterClient(QuotaClient* client);
166 172
167 // TODO(dmikurube): Add a test for this method.
168 virtual void GetLRUOrigin( 173 virtual void GetLRUOrigin(
169 StorageType type, 174 StorageType type,
170 GetLRUOriginCallback* callback); 175 GetLRUOriginCallback* callback) OVERRIDE;
176
177 void StartEviction();
178
179 virtual void GetUsageAndQuotaForEviction(
180 DeleteOriginDataCallback* callback) OVERRIDE;
181
182 void OnOriginDataDeleted(
183 QuotaStatusCode status,
184 DeleteOriginDataCallback* callback);
185
186 virtual void DeleteOriginData(
187 const GURL& origin,
188 StorageType type,
189 DeleteOriginDataCallback* callback) OVERRIDE;
kinuko 2011/05/16 13:48:01 style-nit: Can you put derived methods together wi
Dai Mikurube (NOT FULLTIME) 2011/05/17 09:18:40 Done.
171 190
172 UsageTracker* GetUsageTracker(StorageType type) const; 191 UsageTracker* GetUsageTracker(StorageType type) const;
173 192
174 void DidGetTemporaryGlobalQuota(int64 quota); 193 void DidGetTemporaryGlobalQuota(int64 quota);
175 194
176 void DeleteOnCorrectThread() const; 195 void DeleteOnCorrectThread() const;
177 196
178 const bool is_incognito_; 197 const bool is_incognito_;
179 const FilePath profile_path_; 198 const FilePath profile_path_;
180 199
181 scoped_refptr<QuotaManagerProxy> proxy_; 200 scoped_refptr<QuotaManagerProxy> proxy_;
182 bool db_initialized_; 201 bool db_initialized_;
183 bool db_disabled_; 202 bool db_disabled_;
184 scoped_refptr<base::MessageLoopProxy> io_thread_; 203 scoped_refptr<base::MessageLoopProxy> io_thread_;
185 scoped_refptr<base::MessageLoopProxy> db_thread_; 204 scoped_refptr<base::MessageLoopProxy> db_thread_;
186 mutable scoped_ptr<QuotaDatabase> database_; 205 mutable scoped_ptr<QuotaDatabase> database_;
187 206
188 QuotaClientList clients_; 207 QuotaClientList clients_;
189 208
190 scoped_ptr<UsageTracker> temporary_usage_tracker_; 209 scoped_ptr<UsageTracker> temporary_usage_tracker_;
191 scoped_ptr<UsageTracker> persistent_usage_tracker_; 210 scoped_ptr<UsageTracker> persistent_usage_tracker_;
211 scoped_refptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_;
192 212
193 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; 213 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_;
194 214
215 int num_deletion_requested_clients_;
216 int num_deleted_clients_;
217
195 int64 temporary_global_quota_; 218 int64 temporary_global_quota_;
196 QuotaCallbackQueue temporary_global_quota_callbacks_; 219 QuotaCallbackQueue temporary_global_quota_callbacks_;
197 220
198 // Map from origin to count. 221 // Map from origin to count.
199 std::map<GURL, int> origins_in_use_; 222 std::map<GURL, int> origins_in_use_;
200 223
201 DISALLOW_COPY_AND_ASSIGN(QuotaManager); 224 DISALLOW_COPY_AND_ASSIGN(QuotaManager);
202 }; 225 };
203 226
204 struct QuotaManagerDeleter { 227 struct QuotaManagerDeleter {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 QuotaManager* manager_; // only accessed on the io thread 259 QuotaManager* manager_; // only accessed on the io thread
237 scoped_refptr<base::MessageLoopProxy> io_thread_; 260 scoped_refptr<base::MessageLoopProxy> io_thread_;
238 261
239 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); 262 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
240 }; 263 };
241 264
242 265
243 } // namespace quota 266 } // namespace quota
244 267
245 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ 268 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/quota/quota_manager.cc » ('j') | webkit/quota/quota_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698