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

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

Issue 459003002: Plumbs URLRequestContext and CacheBlobStorageContext down to cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cache1
Patch Set: Rebase 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
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 #include "base/memory/weak_ptr.h"
11 11
12 namespace net {
13 class URLRequestContext;
14 }
15
12 namespace content { 16 namespace content {
13 17
18 class ChromeBlobStorageContext;
19
14 // TODO(jkarlin): Fill this in with a real Cache implementation as 20 // TODO(jkarlin): Fill this in with a real Cache implementation as
15 // specified in 21 // specified in
16 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 22 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
17 // TODO(jkarlin): Unload cache backend from memory once the cache object is no 23 // TODO(jkarlin): Unload cache backend from memory once the cache object is no
18 // longer referenced in javascript. 24 // longer referenced in javascript.
19 25
20 // Represents a ServiceWorker Cache as seen in 26 // Represents a ServiceWorker Cache as seen in
21 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 27 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
22 // InitializeIfNeeded must be called before calling the other public members. 28 // InitializeIfNeeded must be called before calling the other public members.
23 class ServiceWorkerCache { 29 class ServiceWorkerCache {
24 public: 30 public:
25 static scoped_ptr<ServiceWorkerCache> CreateMemoryCache( 31 static scoped_ptr<ServiceWorkerCache> CreateMemoryCache(
26 const std::string& name); 32 const std::string& name,
33 net::URLRequestContext* request_context,
34 ChromeBlobStorageContext* blob_context);
27 static scoped_ptr<ServiceWorkerCache> CreatePersistentCache( 35 static scoped_ptr<ServiceWorkerCache> CreatePersistentCache(
28 const base::FilePath& path, 36 const base::FilePath& path,
29 const std::string& name); 37 const std::string& name,
38 net::URLRequestContext* request_context,
39 ChromeBlobStorageContext* blob_context);
40
30 virtual ~ServiceWorkerCache(); 41 virtual ~ServiceWorkerCache();
31 42
32 // Loads the backend and calls the callback with the result (true for 43 // Loads the backend and calls the callback with the result (true for
33 // success). This must be called before member functions that require a 44 // success). This must be called before member functions that require a
34 // backend are called. 45 // backend are called.
35 void CreateBackend(const base::Callback<void(bool)>& callback); 46 void CreateBackend(const base::Callback<void(bool)>& callback);
36 47
37 void set_name(const std::string& name) { name_ = name; } 48 void set_name(const std::string& name) { name_ = name; }
38 const std::string& name() const { return name_; } 49 const std::string& name() const { return name_; }
39 int32 id() const { return id_; } 50 int32 id() const { return id_; }
40 void set_id(int32 id) { id_ = id; } 51 void set_id(int32 id) { id_ = id; }
41 52
42 base::WeakPtr<ServiceWorkerCache> GetWeakPtr() { 53 base::WeakPtr<ServiceWorkerCache> GetWeakPtr() {
43 return weak_ptr_factory_.GetWeakPtr(); 54 return weak_ptr_factory_.GetWeakPtr();
44 } 55 }
45 56
46 private: 57 private:
47 ServiceWorkerCache(const base::FilePath& path, const std::string& name); 58 ServiceWorkerCache(const base::FilePath& path,
59 const std::string& name,
60 net::URLRequestContext* request_context,
61 ChromeBlobStorageContext* blob_context);
48 62
49 base::FilePath path_; 63 base::FilePath path_;
50 std::string name_; 64 std::string name_;
65 net::URLRequestContext* request_context_;
66 ChromeBlobStorageContext* blob_storage_context_;
51 int32 id_; 67 int32 id_;
52 68
53 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; 69 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
54 70
55 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
56 }; 72 };
57 73
58 } // namespace content 74 } // namespace content
59 75
60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698