OLD | NEW |
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/appcache_service.h" | 5 #include "webkit/appcache/appcache_service.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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 void AppCacheService::DeleteHelper::OnGroupMadeObsolete( | 205 void AppCacheService::DeleteHelper::OnGroupMadeObsolete( |
206 appcache::AppCacheGroup* group, bool success) { | 206 appcache::AppCacheGroup* group, bool success) { |
207 CallCallback(success ? net::OK : net::ERR_FAILED); | 207 CallCallback(success ? net::OK : net::ERR_FAILED); |
208 delete this; | 208 delete this; |
209 } | 209 } |
210 | 210 |
211 // DeleteOriginHelper ------- | 211 // DeleteOriginHelper ------- |
212 | 212 |
213 class AppCacheService::DeleteOriginHelper : public AsyncHelper { | 213 class AppCacheService::DeleteOriginHelper : public NewAsyncHelper { |
214 public: | 214 public: |
215 DeleteOriginHelper( | 215 DeleteOriginHelper( |
216 AppCacheService* service, const GURL& origin, | 216 AppCacheService* service, const GURL& origin, |
217 net::OldCompletionCallback* callback) | 217 const net::CompletionCallback& callback) |
218 : AsyncHelper(service, callback), origin_(origin), | 218 : NewAsyncHelper(service, callback), origin_(origin), |
219 num_caches_to_delete_(0), successes_(0), failures_(0) { | 219 num_caches_to_delete_(0), successes_(0), failures_(0) { |
220 } | 220 } |
221 | 221 |
222 virtual void Start() { | 222 virtual void Start() { |
223 // We start by listing all caches, continues in OnAllInfo(). | 223 // We start by listing all caches, continues in OnAllInfo(). |
224 service_->storage()->GetAllInfo(this); | 224 service_->storage()->GetAllInfo(this); |
225 } | 225 } |
226 | 226 |
227 private: | 227 private: |
228 // AppCacheStorage::Delegate implementation. | 228 // AppCacheStorage::Delegate implementation. |
229 virtual void OnAllInfo(AppCacheInfoCollection* collection); | 229 virtual void OnAllInfo(AppCacheInfoCollection* collection); |
230 virtual void OnGroupLoaded( | 230 virtual void OnGroupLoaded( |
231 appcache::AppCacheGroup* group, const GURL& manifest_url); | 231 appcache::AppCacheGroup* group, const GURL& manifest_url); |
232 virtual void OnGroupMadeObsolete( | 232 virtual void OnGroupMadeObsolete( |
233 appcache::AppCacheGroup* group, bool success); | 233 appcache::AppCacheGroup* group, bool success); |
234 | 234 |
235 void CacheCompleted(bool success); | 235 void CacheCompleted(bool success); |
236 | 236 |
237 GURL origin_; | 237 GURL origin_; |
238 int num_caches_to_delete_; | 238 int num_caches_to_delete_; |
239 int successes_; | 239 int successes_; |
240 int failures_; | 240 int failures_; |
| 241 |
241 DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper); | 242 DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper); |
242 }; | 243 }; |
243 | 244 |
244 void AppCacheService::DeleteOriginHelper::OnAllInfo( | 245 void AppCacheService::DeleteOriginHelper::OnAllInfo( |
245 AppCacheInfoCollection* collection) { | 246 AppCacheInfoCollection* collection) { |
246 if (!collection) { | 247 if (!collection) { |
247 // Failed to get a listing. | 248 // Failed to get a listing. |
248 CallCallback(net::ERR_FAILED); | 249 CallCallback(net::ERR_FAILED); |
249 delete this; | 250 delete this; |
250 return; | 251 return; |
251 } | 252 } |
| 253 |
252 std::map<GURL, AppCacheInfoVector>::iterator found = | 254 std::map<GURL, AppCacheInfoVector>::iterator found = |
253 collection->infos_by_origin.find(origin_); | 255 collection->infos_by_origin.find(origin_); |
254 if (found == collection->infos_by_origin.end() || found->second.empty()) { | 256 if (found == collection->infos_by_origin.end() || found->second.empty()) { |
255 // No caches for this origin. | 257 // No caches for this origin. |
256 CallCallback(net::OK); | 258 CallCallback(net::OK); |
257 delete this; | 259 delete this; |
258 return; | 260 return; |
259 } | 261 } |
260 | 262 |
261 // We have some caches to delete. | 263 // We have some caches to delete. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 519 } |
518 | 520 |
519 void AppCacheService::DeleteAppCacheGroup( | 521 void AppCacheService::DeleteAppCacheGroup( |
520 const GURL& manifest_url, | 522 const GURL& manifest_url, |
521 const net::CompletionCallback& callback) { | 523 const net::CompletionCallback& callback) { |
522 DeleteHelper* helper = new DeleteHelper(this, manifest_url, callback); | 524 DeleteHelper* helper = new DeleteHelper(this, manifest_url, callback); |
523 helper->Start(); | 525 helper->Start(); |
524 } | 526 } |
525 | 527 |
526 void AppCacheService::DeleteAppCachesForOrigin( | 528 void AppCacheService::DeleteAppCachesForOrigin( |
527 const GURL& origin, net::OldCompletionCallback* callback) { | 529 const GURL& origin, const net::CompletionCallback& callback) { |
528 DeleteOriginHelper* helper = new DeleteOriginHelper(this, origin, callback); | 530 DeleteOriginHelper* helper = new DeleteOriginHelper(this, origin, callback); |
529 helper->Start(); | 531 helper->Start(); |
530 } | 532 } |
531 | 533 |
532 void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url, | 534 void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url, |
533 int64 cache_id, | 535 int64 cache_id, |
534 int64 response_id) { | 536 int64 response_id) { |
535 CheckResponseHelper* helper = new CheckResponseHelper( | 537 CheckResponseHelper* helper = new CheckResponseHelper( |
536 this, manifest_url, cache_id, response_id); | 538 this, manifest_url, cache_id, response_id); |
537 helper->Start(); | 539 helper->Start(); |
(...skipping 10 matching lines...) Expand all Loading... |
548 backends_.insert( | 550 backends_.insert( |
549 BackendMap::value_type(backend_impl->process_id(), backend_impl)); | 551 BackendMap::value_type(backend_impl->process_id(), backend_impl)); |
550 } | 552 } |
551 | 553 |
552 void AppCacheService::UnregisterBackend( | 554 void AppCacheService::UnregisterBackend( |
553 AppCacheBackendImpl* backend_impl) { | 555 AppCacheBackendImpl* backend_impl) { |
554 backends_.erase(backend_impl->process_id()); | 556 backends_.erase(backend_impl->process_id()); |
555 } | 557 } |
556 | 558 |
557 } // namespace appcache | 559 } // namespace appcache |
OLD | NEW |