| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_ | 6 #define CONTENT_BROWSER_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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 Delegate* delegate) override; | 60 Delegate* delegate) override; |
| 61 void FindResponseForSubRequest(AppCache* cache, | 61 void FindResponseForSubRequest(AppCache* cache, |
| 62 const GURL& url, | 62 const GURL& url, |
| 63 AppCacheEntry* found_entry, | 63 AppCacheEntry* found_entry, |
| 64 AppCacheEntry* found_fallback_entry, | 64 AppCacheEntry* found_fallback_entry, |
| 65 bool* found_network_namespace) override; | 65 bool* found_network_namespace) override; |
| 66 void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id) override; | 66 void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id) override; |
| 67 void MakeGroupObsolete(AppCacheGroup* group, | 67 void MakeGroupObsolete(AppCacheGroup* group, |
| 68 Delegate* delegate, | 68 Delegate* delegate, |
| 69 int response_code) override; | 69 int response_code) override; |
| 70 void StoreEvictionTimes(AppCacheGroup* group) override; |
| 70 AppCacheResponseReader* CreateResponseReader(const GURL& manifest_url, | 71 AppCacheResponseReader* CreateResponseReader(const GURL& manifest_url, |
| 71 int64 group_id, | 72 int64 group_id, |
| 72 int64 response_id) override; | 73 int64 response_id) override; |
| 73 AppCacheResponseWriter* CreateResponseWriter(const GURL& manifest_url, | 74 AppCacheResponseWriter* CreateResponseWriter(const GURL& manifest_url, |
| 74 int64 group_id) override; | 75 int64 group_id) override; |
| 75 AppCacheResponseMetadataWriter* CreateResponseMetadataWriter( | 76 AppCacheResponseMetadataWriter* CreateResponseMetadataWriter( |
| 76 int64 group_id, | 77 int64 group_id, |
| 77 int64 response_id) override; | 78 int64 response_id) override; |
| 78 void DoomResponses(const GURL& manifest_url, | 79 void DoomResponses(const GURL& manifest_url, |
| 79 const std::vector<int64>& response_ids) override; | 80 const std::vector<int64>& response_ids) override; |
| 80 void DeleteResponses(const GURL& manifest_url, | 81 void DeleteResponses(const GURL& manifest_url, |
| 81 const std::vector<int64>& response_ids) override; | 82 const std::vector<int64>& response_ids) override; |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 friend class AppCacheRequestHandlerTest; | 85 friend class AppCacheRequestHandlerTest; |
| 85 friend class AppCacheServiceImplTest; | 86 friend class AppCacheServiceImplTest; |
| 86 friend class AppCacheUpdateJobTest; | 87 friend class AppCacheUpdateJobTest; |
| 87 friend class MockAppCacheStorageTest; | 88 friend class MockAppCacheStorageTest; |
| 88 | 89 |
| 89 typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap; | 90 typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap; |
| 90 typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap; | 91 typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap; |
| 91 typedef std::set<int64> DoomedResponseIds; | 92 typedef std::set<int64> DoomedResponseIds; |
| 93 typedef std::map<int64, std::pair<base::Time, base::Time>> |
| 94 StoredEvictionTimesMap; |
| 92 | 95 |
| 93 void ProcessGetAllInfo(scoped_refptr<DelegateReference> delegate_ref); | 96 void ProcessGetAllInfo(scoped_refptr<DelegateReference> delegate_ref); |
| 94 void ProcessLoadCache( | 97 void ProcessLoadCache( |
| 95 int64 id, scoped_refptr<DelegateReference> delegate_ref); | 98 int64 id, scoped_refptr<DelegateReference> delegate_ref); |
| 96 void ProcessLoadOrCreateGroup( | 99 void ProcessLoadOrCreateGroup( |
| 97 const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref); | 100 const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref); |
| 98 void ProcessStoreGroupAndNewestCache( | 101 void ProcessStoreGroupAndNewestCache( |
| 99 scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> newest_cache, | 102 scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> newest_cache, |
| 100 scoped_refptr<DelegateReference> delegate_ref); | 103 scoped_refptr<DelegateReference> delegate_ref); |
| 101 void ProcessMakeGroupObsolete(scoped_refptr<AppCacheGroup> group, | 104 void ProcessMakeGroupObsolete(scoped_refptr<AppCacheGroup> group, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 void SimulateGetAllInfo(AppCacheInfoCollection* info) { | 190 void SimulateGetAllInfo(AppCacheInfoCollection* info) { |
| 188 simulated_appcache_info_ = info; | 191 simulated_appcache_info_ = info; |
| 189 } | 192 } |
| 190 | 193 |
| 191 void SimulateResponseReader(AppCacheResponseReader* reader) { | 194 void SimulateResponseReader(AppCacheResponseReader* reader) { |
| 192 simulated_reader_.reset(reader); | 195 simulated_reader_.reset(reader); |
| 193 } | 196 } |
| 194 | 197 |
| 195 StoredCacheMap stored_caches_; | 198 StoredCacheMap stored_caches_; |
| 196 StoredGroupMap stored_groups_; | 199 StoredGroupMap stored_groups_; |
| 200 StoredEvictionTimesMap stored_eviction_times_; |
| 197 DoomedResponseIds doomed_response_ids_; | 201 DoomedResponseIds doomed_response_ids_; |
| 198 scoped_ptr<AppCacheDiskCache> disk_cache_; | 202 scoped_ptr<AppCacheDiskCache> disk_cache_; |
| 199 std::deque<base::Closure> pending_tasks_; | 203 std::deque<base::Closure> pending_tasks_; |
| 200 | 204 |
| 201 bool simulate_make_group_obsolete_failure_; | 205 bool simulate_make_group_obsolete_failure_; |
| 202 bool simulate_store_group_and_newest_cache_failure_; | 206 bool simulate_store_group_and_newest_cache_failure_; |
| 203 | 207 |
| 204 bool simulate_find_main_resource_; | 208 bool simulate_find_main_resource_; |
| 205 bool simulate_find_sub_resource_; | 209 bool simulate_find_sub_resource_; |
| 206 AppCacheEntry simulated_found_entry_; | 210 AppCacheEntry simulated_found_entry_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 235 StoreExistingGroupExistingCache); | 239 StoreExistingGroupExistingCache); |
| 236 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceImplTest, | 240 FRIEND_TEST_ALL_PREFIXES(AppCacheServiceImplTest, |
| 237 DeleteAppCachesForOrigin); | 241 DeleteAppCachesForOrigin); |
| 238 | 242 |
| 239 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage); | 243 DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage); |
| 240 }; | 244 }; |
| 241 | 245 |
| 242 } // namespace content | 246 } // namespace content |
| 243 | 247 |
| 244 #endif // CONTENT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_ | 248 #endif // CONTENT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_ |
| OLD | NEW |