OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORE_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORE_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 // TODO(jkarlin): Fill this in with a real FetchStore implementation as |
| 14 // specified in |
| 15 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. |
| 16 // TODO(jkarlin): Unload store backend from memory once the store object is no |
| 17 // longer referenced in javascript. |
| 18 |
| 19 // Represents a ServiceWorker FetchStore as seen in |
| 20 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. |
| 21 // InitializeIfNeeded must be called before calling the other public members. |
| 22 class ServiceWorkerFetchStore { |
| 23 public: |
| 24 static ServiceWorkerFetchStore* CreateMemoryStore(const std::string& name); |
| 25 static ServiceWorkerFetchStore* CreatePersistentStore( |
| 26 const base::FilePath& path, |
| 27 const std::string& name); |
| 28 virtual ~ServiceWorkerFetchStore(); |
| 29 |
| 30 // Loads the backend and calls the callback with the result (true for |
| 31 // success). This must be called before member functions that require a |
| 32 // backend are called. |
| 33 void CreateBackend(const base::Callback<void(bool)>& callback); |
| 34 |
| 35 void set_name(const std::string& name) { name_ = name; } |
| 36 const std::string& name() const { return name_; } |
| 37 int32 id() const { return id_; } |
| 38 void set_id(int32 id) { id_ = id; } |
| 39 |
| 40 private: |
| 41 ServiceWorkerFetchStore(const base::FilePath& path, const std::string& name); |
| 42 |
| 43 base::FilePath path_; |
| 44 std::string name_; |
| 45 int32 id_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchStore); |
| 48 }; |
| 49 |
| 50 } // namespace content |
| 51 |
| 52 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORE_H_ |
OLD | NEW |