| Index: webkit/appcache/mock_appcache_storage.h
|
| ===================================================================
|
| --- webkit/appcache/mock_appcache_storage.h (revision 29600)
|
| +++ webkit/appcache/mock_appcache_storage.h (working copy)
|
| @@ -5,6 +5,13 @@
|
| #ifndef WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_
|
| #define WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_
|
|
|
| +#include <map>
|
| +
|
| +#include "base/hash_tables.h"
|
| +#include "base/scoped_ptr.h"
|
| +#include "net/disk_cache/disk_cache.h"
|
| +#include "webkit/appcache/appcache.h"
|
| +#include "webkit/appcache/appcache_group.h"
|
| #include "webkit/appcache/appcache_storage.h"
|
|
|
| namespace appcache {
|
| @@ -18,12 +25,9 @@
|
| explicit MockAppCacheStorage(AppCacheService* service);
|
| virtual void LoadCache(int64 id, Delegate* delegate);
|
| virtual void LoadOrCreateGroup(const GURL& manifest_url, Delegate* delegate);
|
| - virtual void LoadResponseInfo(
|
| - const GURL& manifest_url, int64 response_id, Delegate* delegate);
|
| virtual void StoreGroupAndNewestCache(
|
| AppCacheGroup* group, Delegate* delegate);
|
| virtual void FindResponseForMainRequest(const GURL& url, Delegate* delegate);
|
| - virtual void CancelDelegateCallbacks(Delegate* delegate);
|
| virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id);
|
| virtual void MarkGroupAsObsolete(AppCacheGroup* group, Delegate* delegate);
|
| virtual AppCacheResponseReader* CreateResponseReader(
|
| @@ -31,6 +35,37 @@
|
| virtual AppCacheResponseWriter* CreateResponseWriter(const GURL& origin);
|
| virtual void DoomResponses(
|
| const GURL& manifest_url, const std::vector<int64>& response_ids);
|
| +
|
| + private:
|
| + typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap;
|
| + typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap;
|
| +
|
| + void AddStoredCache(AppCache* cache);
|
| + void RemoveStoredCache(AppCache* cache);
|
| + AppCache* GetStoredCache(int64 id) {
|
| + StoredCacheMap::iterator it = stored_caches_.find(id);
|
| + return (it != stored_caches_.end()) ? it->second : NULL;
|
| + }
|
| +
|
| + void AddStoredGroup(AppCacheGroup* group);
|
| + void RemoveStoredGroup(AppCacheGroup* group);
|
| + AppCacheGroup* GetStoredGroup(const GURL& manifest_url) {
|
| + StoredGroupMap::iterator it = stored_groups_.find(manifest_url);
|
| + return (it != stored_groups_.end()) ? it->second : NULL;
|
| + }
|
| +
|
| + // Lazily constructed in-memory disk cache.
|
| + disk_cache::Backend* disk_cache() {
|
| + if (!disk_cache_.get()) {
|
| + const int kMaxCacheSize = 10 * 1024 * 1024;
|
| + disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(kMaxCacheSize));
|
| + }
|
| + return disk_cache_.get();
|
| + }
|
| +
|
| + StoredCacheMap stored_caches_;
|
| + StoredGroupMap stored_groups_;
|
| + scoped_ptr<disk_cache::Backend> disk_cache_;
|
| };
|
|
|
| } // namespace appcache
|
|
|