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

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

Issue 164933002: Expose details for appcache error events [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge glitch, complete a rename Created 6 years, 8 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/browser/appcache/mock_appcache_storage.h" 5 #include "webkit/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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const GURL& entry_url, int64 cache_id) { 132 const GURL& entry_url, int64 cache_id) {
133 AppCache* cache = working_set_.GetCache(cache_id); 133 AppCache* cache = working_set_.GetCache(cache_id);
134 if (cache) { 134 if (cache) {
135 AppCacheEntry* entry = cache->GetEntry(entry_url); 135 AppCacheEntry* entry = cache->GetEntry(entry_url);
136 DCHECK(entry); 136 DCHECK(entry);
137 if (entry) 137 if (entry)
138 entry->add_types(AppCacheEntry::FOREIGN); 138 entry->add_types(AppCacheEntry::FOREIGN);
139 } 139 }
140 } 140 }
141 141
142 void MockAppCacheStorage::MakeGroupObsolete( 142 void MockAppCacheStorage::MakeGroupObsolete(AppCacheGroup* group,
143 AppCacheGroup* group, Delegate* delegate) { 143 Delegate* delegate,
144 int response_code) {
144 DCHECK(group && delegate); 145 DCHECK(group && delegate);
145 146
146 // Always make this method look async. 147 // Always make this method look async.
147 ScheduleTask( 148 ScheduleTask(
148 base::Bind(&MockAppCacheStorage::ProcessMakeGroupObsolete, 149 base::Bind(&MockAppCacheStorage::ProcessMakeGroupObsolete,
149 weak_factory_.GetWeakPtr(), make_scoped_refptr(group), 150 weak_factory_.GetWeakPtr(),
150 make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 151 make_scoped_refptr(group),
152 make_scoped_refptr(GetOrCreateDelegateReference(delegate)),
153 response_code));
151 } 154 }
152 155
153 AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader( 156 AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader(
154 const GURL& manifest_url, int64 group_id, int64 response_id) { 157 const GURL& manifest_url, int64 group_id, int64 response_id) {
155 if (simulated_reader_) 158 if (simulated_reader_)
156 return simulated_reader_.release(); 159 return simulated_reader_.release();
157 return new AppCacheResponseReader(response_id, group_id, disk_cache()); 160 return new AppCacheResponseReader(response_id, group_id, disk_cache());
158 } 161 }
159 162
160 AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter( 163 AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return; 411 return;
409 } 412 }
410 413
411 // Didn't find anything. 414 // Didn't find anything.
412 delegate_ref->delegate->OnMainResponseFound( 415 delegate_ref->delegate->OnMainResponseFound(
413 url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, 0, GURL()); 416 url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, 0, GURL());
414 } 417 }
415 418
416 void MockAppCacheStorage::ProcessMakeGroupObsolete( 419 void MockAppCacheStorage::ProcessMakeGroupObsolete(
417 scoped_refptr<AppCacheGroup> group, 420 scoped_refptr<AppCacheGroup> group,
418 scoped_refptr<DelegateReference> delegate_ref) { 421 scoped_refptr<DelegateReference> delegate_ref,
422 int response_code) {
419 if (simulate_make_group_obsolete_failure_) { 423 if (simulate_make_group_obsolete_failure_) {
420 if (delegate_ref->delegate) 424 if (delegate_ref->delegate)
421 delegate_ref->delegate->OnGroupMadeObsolete(group.get(), false); 425 delegate_ref->delegate->OnGroupMadeObsolete(
426 group.get(), false, response_code);
422 return; 427 return;
423 } 428 }
424 429
425 RemoveStoredGroup(group.get()); 430 RemoveStoredGroup(group.get());
426 if (group->newest_complete_cache()) 431 if (group->newest_complete_cache())
427 RemoveStoredCache(group->newest_complete_cache()); 432 RemoveStoredCache(group->newest_complete_cache());
428 433
429 // Copy the collection prior to removal, on final release 434 // Copy the collection prior to removal, on final release
430 // of a cache the group's collection will change. 435 // of a cache the group's collection will change.
431 AppCacheGroup::Caches copy = group->old_caches(); 436 AppCacheGroup::Caches copy = group->old_caches();
432 RemoveStoredCaches(copy); 437 RemoveStoredCaches(copy);
433 438
434 group->set_obsolete(true); 439 group->set_obsolete(true);
435 440
436 // Also remove from the working set, caches for an 'obsolete' group 441 // Also remove from the working set, caches for an 'obsolete' group
437 // may linger in use, but the group itself cannot be looked up by 442 // may linger in use, but the group itself cannot be looked up by
438 // 'manifest_url' in the working set any longer. 443 // 'manifest_url' in the working set any longer.
439 working_set()->RemoveGroup(group.get()); 444 working_set()->RemoveGroup(group.get());
440 445
441 if (delegate_ref->delegate) 446 if (delegate_ref->delegate)
442 delegate_ref->delegate->OnGroupMadeObsolete(group.get(), true); 447 delegate_ref->delegate->OnGroupMadeObsolete(
448 group.get(), true, response_code);
443 } 449 }
444 450
445 void MockAppCacheStorage::ScheduleTask(const base::Closure& task) { 451 void MockAppCacheStorage::ScheduleTask(const base::Closure& task) {
446 pending_tasks_.push_back(task); 452 pending_tasks_.push_back(task);
447 base::MessageLoop::current()->PostTask( 453 base::MessageLoop::current()->PostTask(
448 FROM_HERE, 454 FROM_HERE,
449 base::Bind(&MockAppCacheStorage::RunOnePendingTask, 455 base::Bind(&MockAppCacheStorage::RunOnePendingTask,
450 weak_factory_.GetWeakPtr())); 456 weak_factory_.GetWeakPtr()));
451 } 457 }
452 458
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { 534 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) {
529 if (!cache) 535 if (!cache)
530 return true; 536 return true;
531 537
532 // If the 'stored' ref is the only ref, real storage will have to load from 538 // If the 'stored' ref is the only ref, real storage will have to load from
533 // the database. 539 // the database.
534 return IsCacheStored(cache) && cache->HasOneRef(); 540 return IsCacheStored(cache) && cache->HasOneRef();
535 } 541 }
536 542
537 } // namespace appcache 543 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/browser/appcache/mock_appcache_storage.h ('k') | webkit/browser/appcache/mock_appcache_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698