Decouple Cache Storage messaging from Service Worker/Embedded Worker
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_cache_scheduler.h
blob0cad875521f09133aa882f64700427f22633302b
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.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_
8 #include <list>
10 #include "base/callback.h"
11 #include "content/common/content_export.h"
13 namespace content {
15 class CONTENT_EXPORT ServiceWorkerCacheScheduler {
16 public:
17 ServiceWorkerCacheScheduler();
18 virtual ~ServiceWorkerCacheScheduler();
20 // Adds the operation to the tail of the queue and starts it if the scheduler
21 // is idle.
22 void ScheduleOperation(const base::Closure& closure);
24 // Call this after each operation completes. It cleans up the current
25 // operation and starts the next.
26 void CompleteOperationAndRunNext();
28 // Returns true if there are any running or pending operations.
29 bool ScheduledOperations() const;
31 private:
32 void RunOperationIfIdle();
34 // The list of operations waiting on initialization.
35 std::list<base::Closure> pending_operations_;
36 bool operation_running_;
38 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheScheduler);
41 } // namespace content
43 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_SCHEDULER_H_