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

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