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 #include "content/browser/appcache/mock_appcache_storage.h" | 5 #include "content/browser/appcache/mock_appcache_storage.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Responses are never really removed from the in-memory disk cache. | 23 // Responses are never really removed from the in-memory disk cache. |
24 // Delegate callbacks are made asyncly to appropiately mimic what will | 24 // Delegate callbacks are made asyncly to appropiately mimic what will |
25 // happen with a real disk-backed storage impl that involves IO on a | 25 // happen with a real disk-backed storage impl that involves IO on a |
26 // background thread. | 26 // background thread. |
27 | 27 |
28 using appcache::AppCacheResponseWriter; | 28 using appcache::AppCacheResponseWriter; |
29 using appcache::AppCacheServiceImpl; | 29 using appcache::AppCacheServiceImpl; |
30 using appcache::FALLBACK_NAMESPACE; | 30 using appcache::FALLBACK_NAMESPACE; |
31 using appcache::INTERCEPT_NAMESPACE; | 31 using appcache::INTERCEPT_NAMESPACE; |
32 using appcache::kNoCacheId; | 32 using appcache::kNoCacheId; |
33 using appcache::NamespaceType; | 33 using appcache::AppCacheNamespaceType; |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 | 36 |
37 MockAppCacheStorage::MockAppCacheStorage(AppCacheServiceImpl* service) | 37 MockAppCacheStorage::MockAppCacheStorage(AppCacheServiceImpl* service) |
38 : AppCacheStorage(service), | 38 : AppCacheStorage(service), |
39 simulate_make_group_obsolete_failure_(false), | 39 simulate_make_group_obsolete_failure_(false), |
40 simulate_store_group_and_newest_cache_failure_(false), | 40 simulate_store_group_and_newest_cache_failure_(false), |
41 simulate_find_main_resource_(false), | 41 simulate_find_main_resource_(false), |
42 simulate_find_sub_resource_(false), | 42 simulate_find_sub_resource_(false), |
43 simulated_found_cache_id_(kNoCacheId), | 43 simulated_found_cache_id_(kNoCacheId), |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 int64 cache_id; | 251 int64 cache_id; |
252 int64 group_id; | 252 int64 group_id; |
253 GURL manifest_url; | 253 GURL manifest_url; |
254 bool is_cache_in_use; | 254 bool is_cache_in_use; |
255 | 255 |
256 FoundCandidate() | 256 FoundCandidate() |
257 : cache_id(kNoCacheId), group_id(0), is_cache_in_use(false) {} | 257 : cache_id(kNoCacheId), group_id(0), is_cache_in_use(false) {} |
258 }; | 258 }; |
259 | 259 |
260 void MaybeTakeNewNamespaceEntry( | 260 void MaybeTakeNewNamespaceEntry( |
261 NamespaceType namespace_type, | 261 AppCacheNamespaceType namespace_type, |
262 const AppCacheEntry &entry, | 262 const AppCacheEntry &entry, |
263 const GURL& namespace_url, | 263 const GURL& namespace_url, |
264 bool cache_is_in_use, | 264 bool cache_is_in_use, |
265 FoundCandidate* best_candidate, | 265 FoundCandidate* best_candidate, |
266 GURL* best_candidate_namespace, | 266 GURL* best_candidate_namespace, |
267 AppCache* cache, | 267 AppCache* cache, |
268 AppCacheGroup* group) { | 268 AppCacheGroup* group) { |
269 DCHECK(entry.has_response_id()); | 269 DCHECK(entry.has_response_id()); |
270 | 270 |
271 bool take_new_entry = true; | 271 bool take_new_entry = true; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { | 541 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { |
542 if (!cache) | 542 if (!cache) |
543 return true; | 543 return true; |
544 | 544 |
545 // If the 'stored' ref is the only ref, real storage will have to load from | 545 // If the 'stored' ref is the only ref, real storage will have to load from |
546 // the database. | 546 // the database. |
547 return IsCacheStored(cache) && cache->HasOneRef(); | 547 return IsCacheStored(cache) && cache->HasOneRef(); |
548 } | 548 } |
549 | 549 |
550 } // namespace content | 550 } // namespace content |
OLD | NEW |