OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/service_worker/service_worker_disk_cache.h" |
| 6 |
| 7 #include "base/id_map.h" |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/browser/service_worker/service_worker_database.h" |
| 10 #include "content/common/service_worker/service_worker_status_code.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 // This is used for migrating the ServiceWorkerDiskCache from the BlockFile |
| 15 // backend to the Simple backend. The migrator iterates over resources in the |
| 16 // src DiskCache and moves them into the dest DiskCache one by one. |
| 17 // |
| 18 // TODO(nhiroki): Remove this migrator after several milestones pass |
| 19 // (http://crbug.com/487482) |
| 20 class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator { |
| 21 public: |
| 22 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>; |
| 23 |
| 24 ServiceWorkerDiskCacheMigrator(ServiceWorkerDiskCache* src, |
| 25 ServiceWorkerDiskCache* dest, |
| 26 const StatusCallback& callback); |
| 27 ~ServiceWorkerDiskCacheMigrator(); |
| 28 |
| 29 void Start(); |
| 30 |
| 31 private: |
| 32 class Task; |
| 33 |
| 34 void ContinueMigratingResources(); |
| 35 void OnOpenNextEntry(const scoped_refptr<Task>& next_task, int result); |
| 36 void OnResourceMigrated(IDMap<Task>::KeyType task_id, |
| 37 ServiceWorkerStatusCode status); |
| 38 |
| 39 void AbortAllTasks(); |
| 40 |
| 41 scoped_ptr<disk_cache::Backend::Iterator> iterator_; |
| 42 ServiceWorkerDiskCache* src_; |
| 43 ServiceWorkerDiskCache* dest_; |
| 44 |
| 45 IDMap<Task> inflight_tasks_; |
| 46 const StatusCallback callback_; |
| 47 |
| 48 base::WeakPtrFactory<ServiceWorkerDiskCacheMigrator> weak_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDiskCacheMigrator); |
| 51 }; |
| 52 |
| 53 } // namespace content |
OLD | NEW |