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