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

Side by Side Diff: content/browser/service_worker/service_worker_cache.h

Issue 460683002: Change threading in ServiceWorkerCacheStorage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder members Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CACHE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_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 #include "base/memory/weak_ptr.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 // TODO(jkarlin): Fill this in with a real Cache implementation as 14 // TODO(jkarlin): Fill this in with a real Cache implementation as
14 // specified in 15 // specified in
15 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 16 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
16 // TODO(jkarlin): Unload cache backend from memory once the cache object is no 17 // TODO(jkarlin): Unload cache backend from memory once the cache object is no
17 // longer referenced in javascript. 18 // longer referenced in javascript.
18 19
19 // Represents a ServiceWorker Cache as seen in 20 // Represents a ServiceWorker Cache as seen in
20 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 21 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
21 // InitializeIfNeeded must be called before calling the other public members. 22 // InitializeIfNeeded must be called before calling the other public members.
22 class ServiceWorkerCache { 23 class ServiceWorkerCache {
23 public: 24 public:
24 static ServiceWorkerCache* CreateMemoryCache(const std::string& name); 25 static scoped_ptr<ServiceWorkerCache> CreateMemoryCache(
michaeln 2014/08/12 23:34:32 nice change on the rv types
jkarlin 2014/08/12 23:52:55 Acknowledged.
25 static ServiceWorkerCache* CreatePersistentCache(const base::FilePath& path, 26 const std::string& name);
26 const std::string& name); 27 static scoped_ptr<ServiceWorkerCache> CreatePersistentCache(
28 const base::FilePath& path,
29 const std::string& name);
27 virtual ~ServiceWorkerCache(); 30 virtual ~ServiceWorkerCache();
28 31
29 // Loads the backend and calls the callback with the result (true for 32 // Loads the backend and calls the callback with the result (true for
30 // success). This must be called before member functions that require a 33 // success). This must be called before member functions that require a
31 // backend are called. 34 // backend are called.
32 void CreateBackend(const base::Callback<void(bool)>& callback); 35 void CreateBackend(const base::Callback<void(bool)>& callback);
33 36
34 void set_name(const std::string& name) { name_ = name; } 37 void set_name(const std::string& name) { name_ = name; }
35 const std::string& name() const { return name_; } 38 const std::string& name() const { return name_; }
36 int32 id() const { return id_; } 39 int32 id() const { return id_; }
37 void set_id(int32 id) { id_ = id; } 40 void set_id(int32 id) { id_ = id; }
38 41
42 base::WeakPtr<ServiceWorkerCache> GetWeakPtr() {
michaeln 2014/08/12 23:34:32 typicically a methods on classes that vend weakptr
jkarlin 2014/08/12 23:52:55 Done.
43 return weak_ptr_factory_.GetWeakPtr();
44 }
45
39 private: 46 private:
40 ServiceWorkerCache(const base::FilePath& path, const std::string& name); 47 ServiceWorkerCache(const base::FilePath& path, const std::string& name);
41 48
42 base::FilePath path_; 49 base::FilePath path_;
43 std::string name_; 50 std::string name_;
44 int32 id_; 51 int32 id_;
45 52
53 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
54
46 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 55 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
47 }; 56 };
48 57
49 } // namespace content 58 } // namespace content
50 59
51 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698