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

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

Issue 7210006: AppCaches which belong to hosted apps are not protected from deletion (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Test beautification. Created 9 years, 5 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-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 MockAppCacheStorage::~MockAppCacheStorage() { 43 MockAppCacheStorage::~MockAppCacheStorage() {
44 STLDeleteElements(&pending_tasks_); 44 STLDeleteElements(&pending_tasks_);
45 } 45 }
46 46
47 void MockAppCacheStorage::GetAllInfo(Delegate* delegate) { 47 void MockAppCacheStorage::GetAllInfo(Delegate* delegate) {
48 ScheduleTask(method_factory_.NewRunnableMethod( 48 ScheduleTask(method_factory_.NewRunnableMethod(
49 &MockAppCacheStorage::ProcessGetAllInfo, 49 &MockAppCacheStorage::ProcessGetAllInfo,
50 make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 50 make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
51 } 51 }
52 52
53 void MockAppCacheStorage::SyncGetAllInfo(Delegate* delegate) {
54 ProcessGetAllInfo(make_scoped_refptr(GetOrCreateDelegateReference(delegate)));
55 }
56
53 void MockAppCacheStorage::LoadCache(int64 id, Delegate* delegate) { 57 void MockAppCacheStorage::LoadCache(int64 id, Delegate* delegate) {
54 DCHECK(delegate); 58 DCHECK(delegate);
55 AppCache* cache = working_set_.GetCache(id); 59 AppCache* cache = working_set_.GetCache(id);
56 if (ShouldCacheLoadAppearAsync(cache)) { 60 if (ShouldCacheLoadAppearAsync(cache)) {
57 ScheduleTask(method_factory_.NewRunnableMethod( 61 ScheduleTask(method_factory_.NewRunnableMethod(
58 &MockAppCacheStorage::ProcessLoadCache, 62 &MockAppCacheStorage::ProcessLoadCache,
59 id, make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 63 id, make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
60 return; 64 return;
61 } 65 }
62 ProcessLoadCache(id, GetOrCreateDelegateReference(delegate)); 66 ProcessLoadCache(id, GetOrCreateDelegateReference(delegate));
63 } 67 }
64 68
65 void MockAppCacheStorage::LoadOrCreateGroup( 69 void MockAppCacheStorage::LoadOrCreateGroup(
66 const GURL& manifest_url, Delegate* delegate) { 70 const GURL& manifest_url, Delegate* delegate) {
67 DCHECK(delegate); 71 DCHECK(delegate);
68 AppCacheGroup* group = working_set_.GetGroup(manifest_url); 72 AppCacheGroup* group = working_set_.GetGroup(manifest_url);
69 if (ShouldGroupLoadAppearAsync(group)) { 73 if (ShouldGroupLoadAppearAsync(group)) {
70 ScheduleTask(method_factory_.NewRunnableMethod( 74 ScheduleTask(method_factory_.NewRunnableMethod(
71 &MockAppCacheStorage::ProcessLoadOrCreateGroup, 75 &MockAppCacheStorage::ProcessLoadOrCreateGroup,
72 manifest_url, 76 manifest_url,
73 make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 77 make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
74 return; 78 return;
75 } 79 }
76 ProcessLoadOrCreateGroup( 80 ProcessLoadOrCreateGroup(
77 manifest_url, GetOrCreateDelegateReference(delegate)); 81 manifest_url, GetOrCreateDelegateReference(delegate));
78 } 82 }
79 83
84 void MockAppCacheStorage::SyncLoadOrCreateGroup(
85 const GURL& manifest_url, Delegate* delegate) {
86 DCHECK(delegate);
87 ProcessLoadOrCreateGroup(
88 manifest_url,
89 make_scoped_refptr(GetOrCreateDelegateReference(delegate)));
90 }
91
80 void MockAppCacheStorage::StoreGroupAndNewestCache( 92 void MockAppCacheStorage::StoreGroupAndNewestCache(
81 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate) { 93 AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate) {
82 DCHECK(group && delegate && newest_cache); 94 DCHECK(group && delegate && newest_cache);
83 95
84 // Always make this operation look async. 96 // Always make this operation look async.
85 ScheduleTask(method_factory_.NewRunnableMethod( 97 ScheduleTask(method_factory_.NewRunnableMethod(
86 &MockAppCacheStorage::ProcessStoreGroupAndNewestCache, 98 &MockAppCacheStorage::ProcessStoreGroupAndNewestCache,
87 make_scoped_refptr(group), 99 make_scoped_refptr(group),
88 make_scoped_refptr(newest_cache), 100 make_scoped_refptr(newest_cache),
89 make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 101 make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 AppCacheGroup* group, Delegate* delegate) { 150 AppCacheGroup* group, Delegate* delegate) {
139 DCHECK(group && delegate); 151 DCHECK(group && delegate);
140 152
141 // Always make this method look async. 153 // Always make this method look async.
142 ScheduleTask(method_factory_.NewRunnableMethod( 154 ScheduleTask(method_factory_.NewRunnableMethod(
143 &MockAppCacheStorage::ProcessMakeGroupObsolete, 155 &MockAppCacheStorage::ProcessMakeGroupObsolete,
144 make_scoped_refptr(group), 156 make_scoped_refptr(group),
145 make_scoped_refptr(GetOrCreateDelegateReference(delegate)))); 157 make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
146 } 158 }
147 159
160 void MockAppCacheStorage::SyncMakeGroupObsolete(
161 AppCacheGroup* group, Delegate* delegate) {
162 DCHECK(group && delegate);
163 ProcessMakeGroupObsolete(
164 make_scoped_refptr(group),
165 make_scoped_refptr(GetOrCreateDelegateReference(delegate)));
166 }
167
148 AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader( 168 AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader(
149 const GURL& manifest_url, int64 response_id) { 169 const GURL& manifest_url, int64 response_id) {
150 return new AppCacheResponseReader(response_id, disk_cache()); 170 return new AppCacheResponseReader(response_id, disk_cache());
151 } 171 }
152 172
153 AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter( 173 AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter(
154 const GURL& manifest_url) { 174 const GURL& manifest_url) {
155 return new AppCacheResponseWriter(NewResponseId(), disk_cache()); 175 return new AppCacheResponseWriter(NewResponseId(), disk_cache());
156 } 176 }
157 177
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { 501 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) {
482 if (!cache) 502 if (!cache)
483 return true; 503 return true;
484 504
485 // If the 'stored' ref is the only ref, real storage will have to load from 505 // If the 'stored' ref is the only ref, real storage will have to load from
486 // the database. 506 // the database.
487 return IsCacheStored(cache) && cache->HasOneRef(); 507 return IsCacheStored(cache) && cache->HasOneRef();
488 } 508 }
489 509
490 } // namespace appcache 510 } // namespace appcache
OLDNEW
« webkit/appcache/appcache_storage_impl.cc ('K') | « webkit/appcache/mock_appcache_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698