OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/appcache/mock_appcache_storage.h" | 5 #include "webkit/appcache/mock_appcache_storage.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 } // namespace | 223 } // namespace |
224 | 224 |
225 void MockAppCacheStorage::ProcessFindResponseForMainRequest( | 225 void MockAppCacheStorage::ProcessFindResponseForMainRequest( |
226 const GURL& url, scoped_refptr<DelegateReference> delegate_ref) { | 226 const GURL& url, scoped_refptr<DelegateReference> delegate_ref) { |
227 if (simulate_find_main_resource_) { | 227 if (simulate_find_main_resource_) { |
228 simulate_find_main_resource_ = false; | 228 simulate_find_main_resource_ = false; |
229 if (delegate_ref->delegate) { | 229 if (delegate_ref->delegate) { |
230 delegate_ref->delegate->OnMainResponseFound( | 230 delegate_ref->delegate->OnMainResponseFound( |
231 url, simulated_found_entry_, simulated_found_fallback_entry_, | 231 url, simulated_found_entry_, simulated_found_fallback_entry_, |
232 simulated_found_cache_id_, simulated_found_manifest_url_); | 232 simulated_found_cache_id_, simulated_found_manifest_url_, false); |
233 } | 233 } |
234 return; | 234 return; |
235 } | 235 } |
236 | 236 |
237 // This call has no persistent side effects, if the delegate has gone | 237 // This call has no persistent side effects, if the delegate has gone |
238 // away, we can just bail out early. | 238 // away, we can just bail out early. |
239 if (!delegate_ref->delegate) | 239 if (!delegate_ref->delegate) |
240 return; | 240 return; |
241 | 241 |
242 // TODO(michaeln): The heuristics around choosing amoungst | 242 // TODO(michaeln): The heuristics around choosing amoungst |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 found_fallback_candidate.is_cache_in_use = is_in_use; | 319 found_fallback_candidate.is_cache_in_use = is_in_use; |
320 found_fallback_candidate_namespace = found_fallback_namespace; | 320 found_fallback_candidate_namespace = found_fallback_namespace; |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 // Found a direct hit. | 325 // Found a direct hit. |
326 if (found_candidate.entry.has_response_id()) { | 326 if (found_candidate.entry.has_response_id()) { |
327 delegate_ref->delegate->OnMainResponseFound( | 327 delegate_ref->delegate->OnMainResponseFound( |
328 url, found_candidate.entry, AppCacheEntry(), | 328 url, found_candidate.entry, AppCacheEntry(), |
329 found_candidate.cache_id, found_candidate.manifest_url); | 329 found_candidate.cache_id, found_candidate.manifest_url, false); |
330 return; | 330 return; |
331 } | 331 } |
332 | 332 |
333 // Found a fallback namespace. | 333 // Found a fallback namespace. |
334 if (found_fallback_candidate.entry.has_response_id()) { | 334 if (found_fallback_candidate.entry.has_response_id()) { |
335 delegate_ref->delegate->OnMainResponseFound( | 335 delegate_ref->delegate->OnMainResponseFound( |
336 url, AppCacheEntry(), found_fallback_candidate.entry, | 336 url, AppCacheEntry(), found_fallback_candidate.entry, |
337 found_fallback_candidate.cache_id, | 337 found_fallback_candidate.cache_id, |
338 found_fallback_candidate.manifest_url); | 338 found_fallback_candidate.manifest_url, false); |
339 return; | 339 return; |
340 } | 340 } |
341 | 341 |
342 // Didn't find anything. | 342 // Didn't find anything. |
343 delegate_ref->delegate->OnMainResponseFound( | 343 delegate_ref->delegate->OnMainResponseFound( |
344 url, AppCacheEntry(), AppCacheEntry(), kNoCacheId, GURL()); | 344 url, AppCacheEntry(), AppCacheEntry(), kNoCacheId, GURL(), false); |
345 } | 345 } |
346 | 346 |
347 void MockAppCacheStorage::ProcessMakeGroupObsolete( | 347 void MockAppCacheStorage::ProcessMakeGroupObsolete( |
348 scoped_refptr<AppCacheGroup> group, | 348 scoped_refptr<AppCacheGroup> group, |
349 scoped_refptr<DelegateReference> delegate_ref) { | 349 scoped_refptr<DelegateReference> delegate_ref) { |
350 if (simulate_make_group_obsolete_failure_) { | 350 if (simulate_make_group_obsolete_failure_) { |
351 if (delegate_ref->delegate) | 351 if (delegate_ref->delegate) |
352 delegate_ref->delegate->OnGroupMadeObsolete(group, false); | 352 delegate_ref->delegate->OnGroupMadeObsolete(group, false); |
353 return; | 353 return; |
354 } | 354 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { | 455 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { |
456 if (!cache) | 456 if (!cache) |
457 return true; | 457 return true; |
458 | 458 |
459 // If the 'stored' ref is the only ref, real storage will have to load from | 459 // If the 'stored' ref is the only ref, real storage will have to load from |
460 // the database. | 460 // the database. |
461 return IsCacheStored(cache) && cache->HasOneRef(); | 461 return IsCacheStored(cache) && cache->HasOneRef(); |
462 } | 462 } |
463 | 463 |
464 } // namespace appcache | 464 } // namespace appcache |
OLD | NEW |