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

Unified Diff: content/browser/service_worker/service_worker_disk_cache_migrator.h

Issue 1152543002: ServiceWorker: Migrate the script cache backend from BlockFile to Simple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove needs_disk_cache_migration Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
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
index 283db71a4abfde10662b44ed6874650eb704b2b3..20d0981f97c95e6fcd0a167d4bed56615d17d16d 100644
--- a/content/browser/service_worker/service_worker_disk_cache_migrator.h
+++ b/content/browser/service_worker/service_worker_disk_cache_migrator.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISK_CACHE_MIGRATOR_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISK_CACHE_MIGRATOR_H_
+
#include "content/browser/service_worker/service_worker_disk_cache.h"
#include "base/id_map.h"
@@ -22,8 +25,11 @@ class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator {
public:
using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
- ServiceWorkerDiskCacheMigrator(ServiceWorkerDiskCache* src,
- ServiceWorkerDiskCache* dest);
+ ServiceWorkerDiskCacheMigrator(
+ const base::FilePath& src_path,
+ const base::FilePath& dest_path,
+ int max_disk_cache_size,
+ const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread);
~ServiceWorkerDiskCacheMigrator();
// Returns SERVICE_WORKER_OK if all resources are successfully migrated. The
@@ -31,12 +37,20 @@ class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator {
void Start(const StatusCallback& callback);
private:
- friend class ServiceWorkerDiskCacheMigratorTest;
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDiskCacheMigratorTest,
+ ThrottleInflightTasks);
+
class Task;
class WrappedEntry;
using InflightTaskMap = IDMap<Task, IDMapOwnPointer>;
+ void DidDeleteDestDirectory(bool deleted);
+ void DidInitializeDiskCache(bool* is_failed,
+ const base::Closure& barrier_closure,
+ int result);
+ void DidInitializeAllDiskCaches(bool* is_failed);
+
void OpenNextEntry();
void OnNextEntryOpened(scoped_ptr<WrappedEntry> entry, int result);
void RunPendingTask();
@@ -51,14 +65,21 @@ class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator {
scoped_ptr<disk_cache::Backend::Iterator> iterator_;
bool is_iterating_ = false;
- ServiceWorkerDiskCache* src_;
- ServiceWorkerDiskCache* dest_;
+ base::FilePath src_path_;
+ base::FilePath dest_path_;
+ scoped_ptr<ServiceWorkerDiskCache> src_;
+ scoped_ptr<ServiceWorkerDiskCache> dest_;
+ const int max_disk_cache_size_;
+ scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_;
InflightTaskMap::KeyType next_task_id_ = 0;
InflightTaskMap inflight_tasks_;
scoped_ptr<Task> pending_task_;
size_t max_number_of_inflight_tasks_ = 10;
+ base::TimeTicks start_time_;
+ size_t number_of_migrated_resources_ = 0;
+
StatusCallback callback_;
base::WeakPtrFactory<ServiceWorkerDiskCacheMigrator> weak_factory_;
@@ -67,3 +88,5 @@ class CONTENT_EXPORT ServiceWorkerDiskCacheMigrator {
};
} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISK_CACHE_MIGRATOR_H_

Powered by Google App Engine
This is Rietveld 408576698