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

Side by Side Diff: webkit/appcache/mock_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
« no previous file with comments | « webkit/appcache/mock_appcache_service.cc ('k') | webkit/appcache/mock_appcache_storage.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_APPCACHE_MOCK_APPCACHE_STORAGE_H_ 5 #ifndef WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_
6 #define WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_ 6 #define WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 22
23 // For use in unit tests. 23 // For use in unit tests.
24 // Note: This class is also being used to bootstrap our development efforts. 24 // Note: This class is also being used to bootstrap our development efforts.
25 // We can get layout tests up and running, and back fill with real storage 25 // We can get layout tests up and running, and back fill with real storage
26 // somewhat in parallel. 26 // somewhat in parallel.
27 class MockAppCacheStorage : public AppCacheStorage { 27 class MockAppCacheStorage : public AppCacheStorage {
28 public: 28 public:
29 explicit MockAppCacheStorage(AppCacheService* service); 29 explicit MockAppCacheStorage(AppCacheService* service);
30 virtual ~MockAppCacheStorage(); 30 virtual ~MockAppCacheStorage();
31 31
32 virtual void GetAllInfo(Delegate* delegate) {} // not implemented 32 virtual void GetAllInfo(Delegate* delegate);
33 virtual void LoadCache(int64 id, Delegate* delegate); 33 virtual void LoadCache(int64 id, Delegate* delegate);
34 virtual void LoadOrCreateGroup(const GURL& manifest_url, Delegate* delegate); 34 virtual void LoadOrCreateGroup(const GURL& manifest_url, Delegate* delegate);
35 virtual void StoreGroupAndNewestCache( 35 virtual void StoreGroupAndNewestCache(
36 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate); 36 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate);
37 virtual void FindResponseForMainRequest( 37 virtual void FindResponseForMainRequest(
38 const GURL& url, const GURL& preferred_manifest_url, Delegate* delegate); 38 const GURL& url, const GURL& preferred_manifest_url, Delegate* delegate);
39 virtual void FindResponseForSubRequest( 39 virtual void FindResponseForSubRequest(
40 AppCache* cache, const GURL& url, 40 AppCache* cache, const GURL& url,
41 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, 41 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
42 bool * found_network_namespace); 42 bool * found_network_namespace);
43 virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id); 43 virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id);
44 virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate); 44 virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate);
45 virtual AppCacheResponseReader* CreateResponseReader( 45 virtual AppCacheResponseReader* CreateResponseReader(
46 const GURL& manifest_url, int64 response_id); 46 const GURL& manifest_url, int64 response_id);
47 virtual AppCacheResponseWriter* CreateResponseWriter(const GURL& origin); 47 virtual AppCacheResponseWriter* CreateResponseWriter(const GURL& origin);
48 virtual void DoomResponses( 48 virtual void DoomResponses(
49 const GURL& manifest_url, const std::vector<int64>& response_ids); 49 const GURL& manifest_url, const std::vector<int64>& response_ids);
50 virtual void DeleteResponses( 50 virtual void DeleteResponses(
51 const GURL& manifest_url, const std::vector<int64>& response_ids); 51 const GURL& manifest_url, const std::vector<int64>& response_ids);
52 virtual void PurgeMemory() {} 52 virtual void PurgeMemory() {}
53 53
54 private: 54 private:
55 friend class AppCacheRequestHandlerTest; 55 friend class AppCacheRequestHandlerTest;
56 friend class AppCacheUpdateJobTest; 56 friend class AppCacheUpdateJobTest;
57 57
58 typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap; 58 typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap;
59 typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap; 59 typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap;
60 typedef std::set<int64> DoomedResponseIds; 60 typedef std::set<int64> DoomedResponseIds;
61 61
62 void ProcessGetAllInfo(scoped_refptr<DelegateReference> delegate_ref);
62 void ProcessLoadCache( 63 void ProcessLoadCache(
63 int64 id, scoped_refptr<DelegateReference> delegate_ref); 64 int64 id, scoped_refptr<DelegateReference> delegate_ref);
64 void ProcessLoadOrCreateGroup( 65 void ProcessLoadOrCreateGroup(
65 const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref); 66 const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref);
66 void ProcessStoreGroupAndNewestCache( 67 void ProcessStoreGroupAndNewestCache(
67 scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> newest_cache, 68 scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> newest_cache,
68 scoped_refptr<DelegateReference> delegate_ref); 69 scoped_refptr<DelegateReference> delegate_ref);
69 void ProcessMakeGroupObsolete( 70 void ProcessMakeGroupObsolete(
70 scoped_refptr<AppCacheGroup> group, 71 scoped_refptr<AppCacheGroup> group,
71 scoped_refptr<DelegateReference> delegate_ref); 72 scoped_refptr<DelegateReference> delegate_ref);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool network_namespace) { 139 bool network_namespace) {
139 simulate_find_main_resource_ = false; 140 simulate_find_main_resource_ = false;
140 simulate_find_sub_resource_ = true; 141 simulate_find_sub_resource_ = true;
141 simulated_found_entry_ = entry; 142 simulated_found_entry_ = entry;
142 simulated_found_fallback_entry_ = fallback_entry; 143 simulated_found_fallback_entry_ = fallback_entry;
143 simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads 144 simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads
144 simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads 145 simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads
145 simulated_found_network_namespace_ = network_namespace; 146 simulated_found_network_namespace_ = network_namespace;
146 } 147 }
147 148
149 void SimulateGetAllInfo(AppCacheInfoCollection* info) {
150 simulated_appcache_info_ = info;
151 }
152
148 StoredCacheMap stored_caches_; 153 StoredCacheMap stored_caches_;
149 StoredGroupMap stored_groups_; 154 StoredGroupMap stored_groups_;
150 DoomedResponseIds doomed_response_ids_; 155 DoomedResponseIds doomed_response_ids_;
151 scoped_ptr<AppCacheDiskCache> disk_cache_; 156 scoped_ptr<AppCacheDiskCache> disk_cache_;
152 std::deque<Task*> pending_tasks_; 157 std::deque<Task*> pending_tasks_;
153 ScopedRunnableMethodFactory<MockAppCacheStorage> method_factory_; 158 ScopedRunnableMethodFactory<MockAppCacheStorage> method_factory_;
154 159
155 bool simulate_make_group_obsolete_failure_; 160 bool simulate_make_group_obsolete_failure_;
156 bool simulate_store_group_and_newest_cache_failure_; 161 bool simulate_store_group_and_newest_cache_failure_;
157 162
158 bool simulate_find_main_resource_; 163 bool simulate_find_main_resource_;
159 bool simulate_find_sub_resource_; 164 bool simulate_find_sub_resource_;
160 AppCacheEntry simulated_found_entry_; 165 AppCacheEntry simulated_found_entry_;
161 AppCacheEntry simulated_found_fallback_entry_; 166 AppCacheEntry simulated_found_fallback_entry_;
162 int64 simulated_found_cache_id_; 167 int64 simulated_found_cache_id_;
163 GURL simulated_found_fallback_url_; 168 GURL simulated_found_fallback_url_;
164 GURL simulated_found_manifest_url_; 169 GURL simulated_found_manifest_url_;
165 bool simulated_found_network_namespace_; 170 bool simulated_found_network_namespace_;
171 scoped_refptr<AppCacheInfoCollection> simulated_appcache_info_;
166 172
167 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, BasicFindMainResponse); 173 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, BasicFindMainResponse);
168 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, 174 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
169 BasicFindMainFallbackResponse); 175 BasicFindMainFallbackResponse);
170 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, CreateGroup); 176 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, CreateGroup);
171 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, FindMainResponseExclusions); 177 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, FindMainResponseExclusions);
172 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, 178 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
173 FindMainResponseWithMultipleCandidates); 179 FindMainResponseWithMultipleCandidates);
174 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadCache_FarHit); 180 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadCache_FarHit);
175 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadGroupAndCache_FarHit); 181 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadGroupAndCache_FarHit);
176 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, MakeGroupObsolete); 182 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, MakeGroupObsolete);
177 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreNewGroup); 183 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreNewGroup);
178 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreExistingGroup); 184 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreExistingGroup);
179 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, 185 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
180 StoreExistingGroupExistingCache); 186 StoreExistingGroupExistingCache);
187 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, DeleteAppCachesForOrigin);
181 188
182 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage); 189 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage);
183 }; 190 };
184 191
185 } // namespace appcache 192 } // namespace appcache
186 193
187 #endif // WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_ 194 #endif // WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_
OLDNEW
« no previous file with comments | « webkit/appcache/mock_appcache_service.cc ('k') | webkit/appcache/mock_appcache_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698