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

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

Issue 7039006: Implement GetUsageAndQuotaForEviction in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added a TODO. 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 | « webkit/quota/quota_client.h ('k') | webkit/quota/quota_manager.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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 StorageType type, 49 StorageType type,
50 GetLRUOriginCallback* callback) = 0; 50 GetLRUOriginCallback* callback) = 0;
51 51
52 virtual void EvictOriginData( 52 virtual void EvictOriginData(
53 const GURL& origin, 53 const GURL& origin,
54 StorageType type, 54 StorageType type,
55 EvictOriginDataCallback* callback) = 0; 55 EvictOriginDataCallback* callback) = 0;
56 56
57 virtual void GetUsageAndQuotaForEviction( 57 virtual void GetUsageAndQuotaForEviction(
58 GetUsageAndQuotaForEvictionCallback* callback) = 0; 58 GetUsageAndQuotaForEvictionCallback* callback) = 0;
59
60 protected:
61 virtual ~QuotaEvictionHandler() {}
59 }; 62 };
60 63
61 // The quota manager class. This class is instantiated per profile and 64 // The quota manager class. This class is instantiated per profile and
62 // held by the profile. With the exception of the constructor and the 65 // held by the profile. With the exception of the constructor and the
63 // proxy() method, all methods should only be called on the IO thread. 66 // proxy() method, all methods should only be called on the IO thread.
64 class QuotaManager : public QuotaTaskObserver, 67 class QuotaManager : public QuotaTaskObserver,
65 public QuotaEvictionHandler, 68 public QuotaEvictionHandler,
66 public base::RefCountedThreadSafe< 69 public base::RefCountedThreadSafe<
67 QuotaManager, QuotaManagerDeleter> { 70 QuotaManager, QuotaManagerDeleter> {
68 public: 71 public:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 class PersistentHostQuotaQueryTask; 150 class PersistentHostQuotaQueryTask;
148 class GetLRUOriginTask; 151 class GetLRUOriginTask;
149 class OriginDeletionDatabaseTask; 152 class OriginDeletionDatabaseTask;
150 153
151 class UsageAndQuotaDispatcherTask; 154 class UsageAndQuotaDispatcherTask;
152 class UsageAndQuotaDispatcherTaskForTemporary; 155 class UsageAndQuotaDispatcherTaskForTemporary;
153 class UsageAndQuotaDispatcherTaskForPersistent; 156 class UsageAndQuotaDispatcherTaskForPersistent;
154 157
155 class AvailableSpaceQueryTask; 158 class AvailableSpaceQueryTask;
156 159
160 struct EvictionContext {
161 EvictionContext()
162 : num_eviction_requested_clients(0),
163 num_evicted_clients(0),
164 num_eviction_error(0),
165 usage(0),
166 quota(0) {}
167 virtual ~EvictionContext() {}
168
169 scoped_ptr<EvictOriginDataCallback> evict_origin_data_callback;
170 int num_eviction_requested_clients;
171 int num_evicted_clients;
172 int num_eviction_error;
173
174 scoped_ptr<GetUsageAndQuotaForEvictionCallback>
175 get_usage_and_quota_callback;
176 int64 usage;
177 int64 quota;
178 };
179
157 typedef std::pair<std::string, StorageType> HostAndType; 180 typedef std::pair<std::string, StorageType> HostAndType;
158 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> 181 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*>
159 UsageAndQuotaDispatcherTaskMap; 182 UsageAndQuotaDispatcherTaskMap;
160 183
161 friend struct QuotaManagerDeleter; 184 friend struct QuotaManagerDeleter;
162 friend class QuotaManagerProxy; 185 friend class QuotaManagerProxy;
163 friend class QuotaManagerTest; 186 friend class QuotaManagerTest;
164 187
165 // This initialization method is lazily called on the IO thread 188 // This initialization method is lazily called on the IO thread
166 // when the first quota manager API is called. 189 // when the first quota manager API is called.
167 // Initialize must be called after all quota clients are added to the 190 // Initialize must be called after all quota clients are added to the
168 // manager by RegisterStorage. 191 // manager by RegisterStorage.
169 void LazyInitialize(); 192 void LazyInitialize();
170 193
171 // Called by clients via proxy. 194 // Called by clients via proxy.
172 // Registers a quota client to the manager. 195 // Registers a quota client to the manager.
173 // The client must remain valid until OnQuotaManagerDestored is called. 196 // The client must remain valid until OnQuotaManagerDestored is called.
174 void RegisterClient(QuotaClient* client); 197 void RegisterClient(QuotaClient* client);
175 198
176 UsageTracker* GetUsageTracker(StorageType type) const; 199 UsageTracker* GetUsageTracker(StorageType type) const;
177 200
178 void DidGetTemporaryGlobalQuota(int64 quota); 201 void DidGetTemporaryGlobalQuota(int64 quota);
179 202
180 // Methods for eviction logic. 203 // Methods for eviction logic.
181 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); 204 void DeleteOriginFromDatabase(const GURL& origin, StorageType type);
182 205
183 void DidOriginDataEvicted(QuotaStatusCode status); 206 void DidOriginDataEvicted(QuotaStatusCode status);
207 void DidGetAvailableSpaceForEviction(
208 QuotaStatusCode status,
209 int64 available_space);
210 void DidGetGlobalQuotaForEviction(
211 QuotaStatusCode status,
212 int64 quota);
213 void DidGetGlobalUsageForEviction(int64 usage);
184 214
185 virtual void GetLRUOrigin( 215 virtual void GetLRUOrigin(
186 StorageType type, 216 StorageType type,
187 GetLRUOriginCallback* callback) OVERRIDE; 217 GetLRUOriginCallback* callback) OVERRIDE;
188 virtual void EvictOriginData( 218 virtual void EvictOriginData(
189 const GURL& origin, 219 const GURL& origin,
190 StorageType type, 220 StorageType type,
191 EvictOriginDataCallback* callback) OVERRIDE; 221 EvictOriginDataCallback* callback) OVERRIDE;
192 virtual void GetUsageAndQuotaForEviction( 222 virtual void GetUsageAndQuotaForEviction(
193 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; 223 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE;
194 224
195 void DeleteOnCorrectThread() const; 225 void DeleteOnCorrectThread() const;
196 226
197 const bool is_incognito_; 227 const bool is_incognito_;
198 const FilePath profile_path_; 228 const FilePath profile_path_;
199 229
200 scoped_refptr<QuotaManagerProxy> proxy_; 230 scoped_refptr<QuotaManagerProxy> proxy_;
201 bool db_disabled_; 231 bool db_disabled_;
202 scoped_refptr<base::MessageLoopProxy> io_thread_; 232 scoped_refptr<base::MessageLoopProxy> io_thread_;
203 scoped_refptr<base::MessageLoopProxy> db_thread_; 233 scoped_refptr<base::MessageLoopProxy> db_thread_;
204 mutable scoped_ptr<QuotaDatabase> database_; 234 mutable scoped_ptr<QuotaDatabase> database_;
205 235
206 QuotaClientList clients_; 236 QuotaClientList clients_;
207 237
208 scoped_ptr<UsageTracker> temporary_usage_tracker_; 238 scoped_ptr<UsageTracker> temporary_usage_tracker_;
209 scoped_ptr<UsageTracker> persistent_usage_tracker_; 239 scoped_ptr<UsageTracker> persistent_usage_tracker_;
210 240
241 EvictionContext eviction_context_;
242
211 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; 243 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_;
212 244
213 scoped_ptr<EvictOriginDataCallback> evict_origin_data_callback_;
214 int num_eviction_requested_clients_;
215 int num_evicted_clients_;
216
217 int64 temporary_global_quota_; 245 int64 temporary_global_quota_;
218 QuotaCallbackQueue temporary_global_quota_callbacks_; 246 QuotaCallbackQueue temporary_global_quota_callbacks_;
219 247
220 // Map from origin to count. 248 // Map from origin to count.
221 std::map<GURL, int> origins_in_use_; 249 std::map<GURL, int> origins_in_use_;
222 250
223 base::ScopedCallbackFactory<QuotaManager> callback_factory_; 251 base::ScopedCallbackFactory<QuotaManager> callback_factory_;
224 252
225 DISALLOW_COPY_AND_ASSIGN(QuotaManager); 253 DISALLOW_COPY_AND_ASSIGN(QuotaManager);
226 }; 254 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 QuotaManager* manager_; // only accessed on the io thread 288 QuotaManager* manager_; // only accessed on the io thread
261 scoped_refptr<base::MessageLoopProxy> io_thread_; 289 scoped_refptr<base::MessageLoopProxy> io_thread_;
262 290
263 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); 291 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
264 }; 292 };
265 293
266 294
267 } // namespace quota 295 } // namespace quota
268 296
269 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ 297 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_
OLDNEW
« no previous file with comments | « webkit/quota/quota_client.h ('k') | webkit/quota/quota_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698