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

Side by Side Diff: webkit/appcache/mock_appcache_storage.cc

Issue 7720022: Third-party appcache blocking. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Keeping up to date with trunk. Created 9 years, 3 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
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 #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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } // namespace 241 } // namespace
242 242
243 void MockAppCacheStorage::ProcessFindResponseForMainRequest( 243 void MockAppCacheStorage::ProcessFindResponseForMainRequest(
244 const GURL& url, scoped_refptr<DelegateReference> delegate_ref) { 244 const GURL& url, scoped_refptr<DelegateReference> delegate_ref) {
245 if (simulate_find_main_resource_) { 245 if (simulate_find_main_resource_) {
246 simulate_find_main_resource_ = false; 246 simulate_find_main_resource_ = false;
247 if (delegate_ref->delegate) { 247 if (delegate_ref->delegate) {
248 delegate_ref->delegate->OnMainResponseFound( 248 delegate_ref->delegate->OnMainResponseFound(
249 url, simulated_found_entry_, 249 url, simulated_found_entry_,
250 simulated_found_fallback_url_, simulated_found_fallback_entry_, 250 simulated_found_fallback_url_, simulated_found_fallback_entry_,
251 simulated_found_cache_id_, simulated_found_manifest_url_, false); 251 simulated_found_cache_id_, simulated_found_manifest_url_);
252 } 252 }
253 return; 253 return;
254 } 254 }
255 255
256 // This call has no persistent side effects, if the delegate has gone 256 // This call has no persistent side effects, if the delegate has gone
257 // away, we can just bail out early. 257 // away, we can just bail out early.
258 if (!delegate_ref->delegate) 258 if (!delegate_ref->delegate)
259 return; 259 return;
260 260
261 // TODO(michaeln): The heuristics around choosing amoungst 261 // TODO(michaeln): The heuristics around choosing amoungst
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 found_fallback_candidate.is_cache_in_use = is_in_use; 341 found_fallback_candidate.is_cache_in_use = is_in_use;
342 found_fallback_candidate_namespace = found_fallback_namespace; 342 found_fallback_candidate_namespace = found_fallback_namespace;
343 } 343 }
344 } 344 }
345 } 345 }
346 346
347 // Found a direct hit. 347 // Found a direct hit.
348 if (found_candidate.entry.has_response_id()) { 348 if (found_candidate.entry.has_response_id()) {
349 delegate_ref->delegate->OnMainResponseFound( 349 delegate_ref->delegate->OnMainResponseFound(
350 url, found_candidate.entry, GURL(), AppCacheEntry(), 350 url, found_candidate.entry, GURL(), AppCacheEntry(),
351 found_candidate.cache_id, found_candidate.manifest_url, false); 351 found_candidate.cache_id, found_candidate.manifest_url);
352 return; 352 return;
353 } 353 }
354 354
355 // Found a fallback namespace. 355 // Found a fallback namespace.
356 if (found_fallback_candidate.entry.has_response_id()) { 356 if (found_fallback_candidate.entry.has_response_id()) {
357 delegate_ref->delegate->OnMainResponseFound( 357 delegate_ref->delegate->OnMainResponseFound(
358 url, AppCacheEntry(), 358 url, AppCacheEntry(),
359 found_fallback_candidate.url, 359 found_fallback_candidate.url,
360 found_fallback_candidate.entry, 360 found_fallback_candidate.entry,
361 found_fallback_candidate.cache_id, 361 found_fallback_candidate.cache_id,
362 found_fallback_candidate.manifest_url, false); 362 found_fallback_candidate.manifest_url);
363 return; 363 return;
364 } 364 }
365 365
366 // Didn't find anything. 366 // Didn't find anything.
367 delegate_ref->delegate->OnMainResponseFound( 367 delegate_ref->delegate->OnMainResponseFound(
368 url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, GURL(), false); 368 url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, GURL());
369 } 369 }
370 370
371 void MockAppCacheStorage::ProcessMakeGroupObsolete( 371 void MockAppCacheStorage::ProcessMakeGroupObsolete(
372 scoped_refptr<AppCacheGroup> group, 372 scoped_refptr<AppCacheGroup> group,
373 scoped_refptr<DelegateReference> delegate_ref) { 373 scoped_refptr<DelegateReference> delegate_ref) {
374 if (simulate_make_group_obsolete_failure_) { 374 if (simulate_make_group_obsolete_failure_) {
375 if (delegate_ref->delegate) 375 if (delegate_ref->delegate)
376 delegate_ref->delegate->OnGroupMadeObsolete(group, false); 376 delegate_ref->delegate->OnGroupMadeObsolete(group, false);
377 return; 377 return;
378 } 378 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { 483 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) {
484 if (!cache) 484 if (!cache)
485 return true; 485 return true;
486 486
487 // If the 'stored' ref is the only ref, real storage will have to load from 487 // If the 'stored' ref is the only ref, real storage will have to load from
488 // the database. 488 // the database.
489 return IsCacheStored(cache) && cache->HasOneRef(); 489 return IsCacheStored(cache) && cache->HasOneRef();
490 } 490 }
491 491
492 } // namespace appcache 492 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/mock_appcache_policy.cc ('k') | webkit/appcache/mock_appcache_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698