| Index: content/browser/service_worker/service_worker_disk_cache_migrator.h
|
| diff --git a/content/browser/service_worker/service_worker_disk_cache_migrator.h b/content/browser/service_worker/service_worker_disk_cache_migrator.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4db787d784f734d478ec1ef9be2d8f70b09936c6
|
| --- /dev/null
|
| +++ b/content/browser/service_worker/service_worker_disk_cache_migrator.h
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/service_worker/service_worker_disk_cache.h"
|
| +
|
| +#include "base/id_map.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "content/browser/service_worker/service_worker_database.h"
|
| +#include "content/common/service_worker/service_worker_status_code.h"
|
| +
|
| +namespace content {
|
| +
|
| +// This is used for migrating the ServiceWorkerDiskCache from the BlockFile
|
| +// backend to the Simple backend. The migrator iterates over resources in the
|
| +// src DiskCache and moves them into the dest DiskCache one by one.
|
| +//
|
| +// TODO(nhiroki): Remove this migrator after several milestones pass
|
| +// (http://crbug.com/487482)
|
| +class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator {
|
| + public:
|
| + using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
|
| +
|
| + ServiceWorkerDiskCacheMigrator(ServiceWorkerDiskCache* src,
|
| + ServiceWorkerDiskCache* dest,
|
| + const StatusCallback& callback);
|
| + ~ServiceWorkerDiskCacheMigrator();
|
| +
|
| + void Start();
|
| +
|
| + private:
|
| + class Task;
|
| +
|
| + void ContinueMigratingResources();
|
| + void OnOpenNextEntry(const scoped_refptr<Task>& next_task, int result);
|
| + void OnResourceMigrated(IDMap<Task>::KeyType task_id,
|
| + ServiceWorkerStatusCode status);
|
| +
|
| + void AbortAllTasks();
|
| +
|
| + scoped_ptr<disk_cache::Backend::Iterator> iterator_;
|
| + ServiceWorkerDiskCache* src_;
|
| + ServiceWorkerDiskCache* dest_;
|
| +
|
| + IDMap<Task> inflight_tasks_;
|
| + const StatusCallback callback_;
|
| +
|
| + base::WeakPtrFactory<ServiceWorkerDiskCacheMigrator> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDiskCacheMigrator);
|
| +};
|
| +
|
| +} // namespace content
|
|
|