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

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

Issue 867903005: [ServiceWorkerCache] Serialize ServiceWorkerCacheStorage operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 5 years, 11 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_cache_scheduler.h
diff --git a/content/browser/service_worker/service_worker_cache_scheduler.h b/content/browser/service_worker/service_worker_cache_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..dcf6f87309643f9bbafee8e31b8a196df158d05d
--- /dev/null
+++ b/content/browser/service_worker/service_worker_cache_scheduler.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_
+
+#include <list>
+
+#include "base/callback.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class CONTENT_EXPORT ServiceWorkerCacheScheduler {
+ public:
+ ServiceWorkerCacheScheduler();
+ virtual ~ServiceWorkerCacheScheduler();
+
+ // Adds the operation to the tail of the queue and starts it if the scheduler
+ // is idle.
+ void ScheduleOperation(const base::Closure& closure);
+
+ // Call this after each operation completes. It cleans up the current
+ // operation and starts the next.
+ void CompleteOperationAndRunNext();
+
+ bool Empty() const;
+
+ private:
+ void RunOperationIfIdle();
+
+ // The list of operations waiting on initialization.
+ std::list<base::Closure> pending_operations_;
+ bool operation_running_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheScheduler);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698