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

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: Implemented it and added a test. 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 class UsageAndQuotaDispatcherTaskForPersistent; 153 class UsageAndQuotaDispatcherTaskForPersistent;
154 154
155 class AvailableSpaceQueryTask; 155 class AvailableSpaceQueryTask;
156 156
157 typedef std::pair<std::string, StorageType> HostAndType; 157 typedef std::pair<std::string, StorageType> HostAndType;
158 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> 158 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*>
159 UsageAndQuotaDispatcherTaskMap; 159 UsageAndQuotaDispatcherTaskMap;
160 160
161 friend struct QuotaManagerDeleter; 161 friend struct QuotaManagerDeleter;
162 friend class QuotaManagerProxy; 162 friend class QuotaManagerProxy;
163 friend class QuotaManagerTest;
163 164
164 // This initialization method is lazily called on the IO thread 165 // This initialization method is lazily called on the IO thread
165 // when the first quota manager API is called. 166 // when the first quota manager API is called.
166 // Initialize must be called after all quota clients are added to the 167 // Initialize must be called after all quota clients are added to the
167 // manager by RegisterStorage. 168 // manager by RegisterStorage.
168 void LazyInitialize(); 169 void LazyInitialize();
169 170
170 // Called by clients via proxy. 171 // Called by clients via proxy.
171 // Registers a quota client to the manager. 172 // Registers a quota client to the manager.
172 // The client must remain valid until OnQuotaManagerDestored is called. 173 // The client must remain valid until OnQuotaManagerDestored is called.
173 void RegisterClient(QuotaClient* client); 174 void RegisterClient(QuotaClient* client);
174 175
175 UsageTracker* GetUsageTracker(StorageType type) const; 176 UsageTracker* GetUsageTracker(StorageType type) const;
176 177
177 void DidGetTemporaryGlobalQuota(int64 quota); 178 void DidGetTemporaryGlobalQuota(int64 quota);
178 179
179 // Methods for eviction logic. 180 // Methods for eviction logic.
180 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); 181 void DeleteOriginFromDatabase(const GURL& origin, StorageType type);
181 182
183 void OnGetAvailableSpaceForEviction(
184 QuotaStatusCode status,
185 int64 available_space);
186 void OnGetGlobalQuotaForEviction(
187 QuotaStatusCode status,
188 int64 quota);
189 void OnGetGlobalUsageForEviction(int64 usage);
190
182 virtual void GetLRUOrigin( 191 virtual void GetLRUOrigin(
183 StorageType type, 192 StorageType type,
184 GetLRUOriginCallback* callback) OVERRIDE; 193 GetLRUOriginCallback* callback) OVERRIDE;
185 virtual void EvictOriginData( 194 virtual void EvictOriginData(
186 const GURL& origin, 195 const GURL& origin,
187 StorageType type, 196 StorageType type,
188 EvictOriginDataCallback* callback) OVERRIDE; 197 EvictOriginDataCallback* callback) OVERRIDE;
189 virtual void GetUsageAndQuotaForEviction( 198 virtual void GetUsageAndQuotaForEviction(
190 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; 199 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE;
191 200
192 void DeleteOnCorrectThread() const; 201 void DeleteOnCorrectThread() const;
193 202
194 const bool is_incognito_; 203 const bool is_incognito_;
195 const FilePath profile_path_; 204 const FilePath profile_path_;
196 205
197 scoped_refptr<QuotaManagerProxy> proxy_; 206 scoped_refptr<QuotaManagerProxy> proxy_;
198 bool db_disabled_; 207 bool db_disabled_;
199 scoped_refptr<base::MessageLoopProxy> io_thread_; 208 scoped_refptr<base::MessageLoopProxy> io_thread_;
200 scoped_refptr<base::MessageLoopProxy> db_thread_; 209 scoped_refptr<base::MessageLoopProxy> db_thread_;
201 mutable scoped_ptr<QuotaDatabase> database_; 210 mutable scoped_ptr<QuotaDatabase> database_;
202 211
203 QuotaClientList clients_; 212 QuotaClientList clients_;
204 213
205 scoped_ptr<UsageTracker> temporary_usage_tracker_; 214 scoped_ptr<UsageTracker> temporary_usage_tracker_;
206 scoped_ptr<UsageTracker> persistent_usage_tracker_; 215 scoped_ptr<UsageTracker> persistent_usage_tracker_;
207 216
217 scoped_ptr<GetUsageAndQuotaForEvictionCallback>
218 get_usage_and_quota_for_eviction_callback_;
219 int64 usage_for_eviction_;
220 int64 quota_for_eviction_;
221
208 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; 222 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_;
209 223
210 int64 temporary_global_quota_; 224 int64 temporary_global_quota_;
211 QuotaCallbackQueue temporary_global_quota_callbacks_; 225 QuotaCallbackQueue temporary_global_quota_callbacks_;
212 226
213 // Map from origin to count. 227 // Map from origin to count.
214 std::map<GURL, int> origins_in_use_; 228 std::map<GURL, int> origins_in_use_;
215 229
230 base::ScopedCallbackFactory<QuotaManager> callback_factory_;
231
216 DISALLOW_COPY_AND_ASSIGN(QuotaManager); 232 DISALLOW_COPY_AND_ASSIGN(QuotaManager);
217 }; 233 };
218 234
219 struct QuotaManagerDeleter { 235 struct QuotaManagerDeleter {
220 static void Destruct(const QuotaManager* manager) { 236 static void Destruct(const QuotaManager* manager) {
221 manager->DeleteOnCorrectThread(); 237 manager->DeleteOnCorrectThread();
222 } 238 }
223 }; 239 };
224 240
225 // The proxy may be called and finally released on any thread. 241 // The proxy may be called and finally released on any thread.
(...skipping 25 matching lines...) Expand all
251 QuotaManager* manager_; // only accessed on the io thread 267 QuotaManager* manager_; // only accessed on the io thread
252 scoped_refptr<base::MessageLoopProxy> io_thread_; 268 scoped_refptr<base::MessageLoopProxy> io_thread_;
253 269
254 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); 270 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
255 }; 271 };
256 272
257 273
258 } // namespace quota 274 } // namespace quota
259 275
260 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ 276 #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