| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate); | 37 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate); |
| 38 virtual void FindResponseForMainRequest( | 38 virtual void FindResponseForMainRequest( |
| 39 const GURL& url, const GURL& preferred_manifest_url, Delegate* delegate); | 39 const GURL& url, const GURL& preferred_manifest_url, Delegate* delegate); |
| 40 virtual void FindResponseForSubRequest( | 40 virtual void FindResponseForSubRequest( |
| 41 AppCache* cache, const GURL& url, | 41 AppCache* cache, const GURL& url, |
| 42 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, | 42 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, |
| 43 bool * found_network_namespace); | 43 bool * found_network_namespace); |
| 44 virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id); | 44 virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id); |
| 45 virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate); | 45 virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate); |
| 46 virtual AppCacheResponseReader* CreateResponseReader( | 46 virtual AppCacheResponseReader* CreateResponseReader( |
| 47 const GURL& manifest_url, int64 response_id); | 47 const GURL& manifest_url, int64 group_id, int64 response_id); |
| 48 virtual AppCacheResponseWriter* CreateResponseWriter(const GURL& origin); | 48 virtual AppCacheResponseWriter* CreateResponseWriter( |
| 49 const GURL& manifest_url, int64 group_id); |
| 49 virtual void DoomResponses( | 50 virtual void DoomResponses( |
| 50 const GURL& manifest_url, const std::vector<int64>& response_ids); | 51 const GURL& manifest_url, const std::vector<int64>& response_ids); |
| 51 virtual void DeleteResponses( | 52 virtual void DeleteResponses( |
| 52 const GURL& manifest_url, const std::vector<int64>& response_ids); | 53 const GURL& manifest_url, const std::vector<int64>& response_ids); |
| 53 virtual void PurgeMemory() {} | 54 virtual void PurgeMemory() {} |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 friend class AppCacheRequestHandlerTest; | 57 friend class AppCacheRequestHandlerTest; |
| 57 friend class AppCacheServiceTest; | 58 friend class AppCacheServiceTest; |
| 58 friend class AppCacheUpdateJobTest; | 59 friend class AppCacheUpdateJobTest; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 122 } |
| 122 | 123 |
| 123 // Simulate FindResponseFor results for testing. These | 124 // Simulate FindResponseFor results for testing. These |
| 124 // provided values will be return on the next call to | 125 // provided values will be return on the next call to |
| 125 // the corresponding Find method, subsequent calls are | 126 // the corresponding Find method, subsequent calls are |
| 126 // unaffected. | 127 // unaffected. |
| 127 void SimulateFindMainResource( | 128 void SimulateFindMainResource( |
| 128 const AppCacheEntry& entry, | 129 const AppCacheEntry& entry, |
| 129 const GURL& fallback_url, | 130 const GURL& fallback_url, |
| 130 const AppCacheEntry& fallback_entry, | 131 const AppCacheEntry& fallback_entry, |
| 131 int64 cache_id, const GURL& manifest_url) { | 132 int64 cache_id, |
| 133 int64 group_id, |
| 134 const GURL& manifest_url) { |
| 132 simulate_find_main_resource_ = true; | 135 simulate_find_main_resource_ = true; |
| 133 simulate_find_sub_resource_ = false; | 136 simulate_find_sub_resource_ = false; |
| 134 simulated_found_entry_ = entry; | 137 simulated_found_entry_ = entry; |
| 135 simulated_found_fallback_url_ = fallback_url; | 138 simulated_found_fallback_url_ = fallback_url; |
| 136 simulated_found_fallback_entry_ = fallback_entry; | 139 simulated_found_fallback_entry_ = fallback_entry; |
| 137 simulated_found_cache_id_ = cache_id; | 140 simulated_found_cache_id_ = cache_id; |
| 141 simulated_found_group_id_ = group_id; |
| 138 simulated_found_manifest_url_ = manifest_url, | 142 simulated_found_manifest_url_ = manifest_url, |
| 139 simulated_found_network_namespace_ = false; // N/A to main resource loads | 143 simulated_found_network_namespace_ = false; // N/A to main resource loads |
| 140 } | 144 } |
| 141 void SimulateFindSubResource( | 145 void SimulateFindSubResource( |
| 142 const AppCacheEntry& entry, | 146 const AppCacheEntry& entry, |
| 143 const AppCacheEntry& fallback_entry, | 147 const AppCacheEntry& fallback_entry, |
| 144 bool network_namespace) { | 148 bool network_namespace) { |
| 145 simulate_find_main_resource_ = false; | 149 simulate_find_main_resource_ = false; |
| 146 simulate_find_sub_resource_ = true; | 150 simulate_find_sub_resource_ = true; |
| 147 simulated_found_entry_ = entry; | 151 simulated_found_entry_ = entry; |
| 148 simulated_found_fallback_entry_ = fallback_entry; | 152 simulated_found_fallback_entry_ = fallback_entry; |
| 149 simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads | 153 simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads |
| 150 simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads | 154 simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads |
| 155 simulated_found_group_id_ = 0; // N/A to sub resource loads |
| 151 simulated_found_network_namespace_ = network_namespace; | 156 simulated_found_network_namespace_ = network_namespace; |
| 152 } | 157 } |
| 153 | 158 |
| 154 void SimulateGetAllInfo(AppCacheInfoCollection* info) { | 159 void SimulateGetAllInfo(AppCacheInfoCollection* info) { |
| 155 simulated_appcache_info_ = info; | 160 simulated_appcache_info_ = info; |
| 156 } | 161 } |
| 157 | 162 |
| 158 void SimulateResponseReader(AppCacheResponseReader* reader) { | 163 void SimulateResponseReader(AppCacheResponseReader* reader) { |
| 159 simulated_reader_.reset(reader); | 164 simulated_reader_.reset(reader); |
| 160 } | 165 } |
| 161 | 166 |
| 162 StoredCacheMap stored_caches_; | 167 StoredCacheMap stored_caches_; |
| 163 StoredGroupMap stored_groups_; | 168 StoredGroupMap stored_groups_; |
| 164 DoomedResponseIds doomed_response_ids_; | 169 DoomedResponseIds doomed_response_ids_; |
| 165 scoped_ptr<AppCacheDiskCache> disk_cache_; | 170 scoped_ptr<AppCacheDiskCache> disk_cache_; |
| 166 std::deque<Task*> pending_tasks_; | 171 std::deque<Task*> pending_tasks_; |
| 167 ScopedRunnableMethodFactory<MockAppCacheStorage> method_factory_; | 172 ScopedRunnableMethodFactory<MockAppCacheStorage> method_factory_; |
| 168 | 173 |
| 169 bool simulate_make_group_obsolete_failure_; | 174 bool simulate_make_group_obsolete_failure_; |
| 170 bool simulate_store_group_and_newest_cache_failure_; | 175 bool simulate_store_group_and_newest_cache_failure_; |
| 171 | 176 |
| 172 bool simulate_find_main_resource_; | 177 bool simulate_find_main_resource_; |
| 173 bool simulate_find_sub_resource_; | 178 bool simulate_find_sub_resource_; |
| 174 AppCacheEntry simulated_found_entry_; | 179 AppCacheEntry simulated_found_entry_; |
| 175 AppCacheEntry simulated_found_fallback_entry_; | 180 AppCacheEntry simulated_found_fallback_entry_; |
| 176 int64 simulated_found_cache_id_; | 181 int64 simulated_found_cache_id_; |
| 182 int64 simulated_found_group_id_; |
| 177 GURL simulated_found_fallback_url_; | 183 GURL simulated_found_fallback_url_; |
| 178 GURL simulated_found_manifest_url_; | 184 GURL simulated_found_manifest_url_; |
| 179 bool simulated_found_network_namespace_; | 185 bool simulated_found_network_namespace_; |
| 180 scoped_refptr<AppCacheInfoCollection> simulated_appcache_info_; | 186 scoped_refptr<AppCacheInfoCollection> simulated_appcache_info_; |
| 181 scoped_ptr<AppCacheResponseReader> simulated_reader_; | 187 scoped_ptr<AppCacheResponseReader> simulated_reader_; |
| 182 | 188 |
| 183 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, BasicFindMainResponse); | 189 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, BasicFindMainResponse); |
| 184 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, | 190 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, |
| 185 BasicFindMainFallbackResponse); | 191 BasicFindMainFallbackResponse); |
| 186 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, CreateGroup); | 192 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, CreateGroup); |
| 187 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, FindMainResponseExclusions); | 193 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, FindMainResponseExclusions); |
| 188 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, | 194 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, |
| 189 FindMainResponseWithMultipleCandidates); | 195 FindMainResponseWithMultipleCandidates); |
| 190 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadCache_FarHit); | 196 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadCache_FarHit); |
| 191 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadGroupAndCache_FarHit); | 197 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadGroupAndCache_FarHit); |
| 192 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, MakeGroupObsolete); | 198 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, MakeGroupObsolete); |
| 193 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreNewGroup); | 199 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreNewGroup); |
| 194 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreExistingGroup); | 200 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreExistingGroup); |
| 195 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, | 201 FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, |
| 196 StoreExistingGroupExistingCache); | 202 StoreExistingGroupExistingCache); |
| 197 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, DeleteAppCachesForOrigin); | 203 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, DeleteAppCachesForOrigin); |
| 198 | 204 |
| 199 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage); | 205 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage); |
| 200 }; | 206 }; |
| 201 | 207 |
| 202 } // namespace appcache | 208 } // namespace appcache |
| 203 | 209 |
| 204 #endif // WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_ | 210 #endif // WEBKIT_APPCACHE_MOCK_APPCACHE_STORAGE_H_ |
| OLD | NEW |