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

Side by Side Diff: webkit/appcache/appcache_storage.h

Issue 7031065: AppCache + Quota integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
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_APPCACHE_APPCACHE_STORAGE_H_ 5 #ifndef WEBKIT_APPCACHE_APPCACHE_STORAGE_H_
6 #define WEBKIT_APPCACHE_APPCACHE_STORAGE_H_ 6 #define WEBKIT_APPCACHE_APPCACHE_STORAGE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 class AppCacheEntry; 24 class AppCacheEntry;
25 class AppCacheGroup; 25 class AppCacheGroup;
26 class AppCacheResponseReader; 26 class AppCacheResponseReader;
27 class AppCacheResponseWriter; 27 class AppCacheResponseWriter;
28 class AppCacheService; 28 class AppCacheService;
29 struct AppCacheInfoCollection; 29 struct AppCacheInfoCollection;
30 struct HttpResponseInfoIOBuffer; 30 struct HttpResponseInfoIOBuffer;
31 31
32 class AppCacheStorage { 32 class AppCacheStorage {
33 public: 33 public:
34 typedef std::map<GURL, int64> UsageMap;
34 35
35 class Delegate { 36 class Delegate {
36 public: 37 public:
37 virtual ~Delegate() {} 38 virtual ~Delegate() {}
38 39
39 // If retrieval fails, 'collection' will be NULL. 40 // If retrieval fails, 'collection' will be NULL.
40 virtual void OnAllInfo(AppCacheInfoCollection* collection) {} 41 virtual void OnAllInfo(AppCacheInfoCollection* collection) {}
41 42
42 // If a load fails the 'cache' will be NULL. 43 // If a load fails the 'cache' will be NULL.
43 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) {} 44 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) {}
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int64 NewCacheId() { 174 int64 NewCacheId() {
174 return ++last_cache_id_; 175 return ++last_cache_id_;
175 } 176 }
176 int64 NewGroupId() { 177 int64 NewGroupId() {
177 return ++last_group_id_; 178 return ++last_group_id_;
178 } 179 }
179 180
180 // The working set of object instances currently in memory. 181 // The working set of object instances currently in memory.
181 AppCacheWorkingSet* working_set() { return &working_set_; } 182 AppCacheWorkingSet* working_set() { return &working_set_; }
182 183
184 // A map of origins to usage.
185 const UsageMap* usage_map() { return &usage_map_; }
186
183 // Simple ptr back to the service object that owns us. 187 // Simple ptr back to the service object that owns us.
184 AppCacheService* service() { return service_; } 188 AppCacheService* service() { return service_; }
185 189
186 protected: 190 protected:
187 friend class AppCacheResponseTest; 191 friend class AppCacheResponseTest;
188 friend class AppCacheStorageTest; 192 friend class AppCacheStorageTest;
189 193
190 // Helper to call a collection of delegates. 194 // Helper to call a collection of delegates.
191 #define FOR_EACH_DELEGATE(delegates, func_and_args) \ 195 #define FOR_EACH_DELEGATE(delegates, func_and_args) \
192 do { \ 196 do { \
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (iter != pending_info_loads_.end()) 277 if (iter != pending_info_loads_.end())
274 return iter->second; 278 return iter->second;
275 return new ResponseInfoLoadTask(manifest_url, response_id, this); 279 return new ResponseInfoLoadTask(manifest_url, response_id, this);
276 } 280 }
277 281
278 // Should only be called when creating a new response writer. 282 // Should only be called when creating a new response writer.
279 int64 NewResponseId() { 283 int64 NewResponseId() {
280 return ++last_response_id_; 284 return ++last_response_id_;
281 } 285 }
282 286
287 // Helpers to query and notify the QuotaManager.
288 void UpdateUsageMapAndNotify(const GURL& origin, int64 new_usage);
289 void NotifyStorageAccessed(const GURL& origin);
290
283 // The last storage id used for different object types. 291 // The last storage id used for different object types.
284 int64 last_cache_id_; 292 int64 last_cache_id_;
285 int64 last_group_id_; 293 int64 last_group_id_;
286 int64 last_response_id_; 294 int64 last_response_id_;
287 295
296 UsageMap usage_map_; // maps origin to usage
288 AppCacheWorkingSet working_set_; 297 AppCacheWorkingSet working_set_;
289 AppCacheService* service_; 298 AppCacheService* service_;
290 DelegateReferenceMap delegate_references_; 299 DelegateReferenceMap delegate_references_;
291 PendingResponseInfoLoads pending_info_loads_; 300 PendingResponseInfoLoads pending_info_loads_;
292 301
293 // The set of last ids must be retrieved from storage prior to being used. 302 // The set of last ids must be retrieved from storage prior to being used.
294 static const int64 kUnitializedId; 303 static const int64 kUnitializedId;
295 304
296 FRIEND_TEST_ALL_PREFIXES(AppCacheStorageTest, DelegateReferences); 305 FRIEND_TEST_ALL_PREFIXES(AppCacheStorageTest, DelegateReferences);
297 306
298 DISALLOW_COPY_AND_ASSIGN(AppCacheStorage); 307 DISALLOW_COPY_AND_ASSIGN(AppCacheStorage);
299 }; 308 };
300 309
301 } // namespace appcache 310 } // namespace appcache
302 311
303 #endif // WEBKIT_APPCACHE_APPCACHE_STORAGE_H_ 312 #endif // WEBKIT_APPCACHE_APPCACHE_STORAGE_H_
304 313
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698