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

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: 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 10
11 namespace net {
12 class URLRequestContext;
13 }
14
11 namespace content { 15 namespace content {
12 16
17 class ChromeBlobStorageContext;
18
13 // TODO(jkarlin): Fill this in with a real Cache implementation as 19 // TODO(jkarlin): Fill this in with a real Cache implementation as
14 // specified in 20 // specified in
15 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 21 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
16 // TODO(jkarlin): Unload cache backend from memory once the cache object is no 22 // TODO(jkarlin): Unload cache backend from memory once the cache object is no
17 // longer referenced in javascript. 23 // longer referenced in javascript.
18 24
19 // Represents a ServiceWorker Cache as seen in 25 // Represents a ServiceWorker Cache as seen in
20 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 26 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
21 // InitializeIfNeeded must be called before calling the other public members. 27 // InitializeIfNeeded must be called before calling the other public members.
22 class ServiceWorkerCache { 28 class ServiceWorkerCache {
23 public: 29 public:
24 static ServiceWorkerCache* CreateMemoryCache(const std::string& name); 30 static ServiceWorkerCache* CreateMemoryCache(
25 static ServiceWorkerCache* CreatePersistentCache(const base::FilePath& path, 31 const std::string& name,
26 const std::string& name); 32 net::URLRequestContext* request_context,
33 ChromeBlobStorageContext* blob_context);
michaeln 2014/08/12 03:48:52 Since these classes are used on the IO thread, it
34 static ServiceWorkerCache* CreatePersistentCache(
35 const base::FilePath& path,
36 const std::string& name,
37 net::URLRequestContext* request_context,
38 ChromeBlobStorageContext* blob_context);
27 virtual ~ServiceWorkerCache(); 39 virtual ~ServiceWorkerCache();
28 40
29 // Loads the backend and calls the callback with the result (true for 41 // Loads the backend and calls the callback with the result (true for
30 // success). This must be called before member functions that require a 42 // success). This must be called before member functions that require a
31 // backend are called. 43 // backend are called.
32 void CreateBackend(const base::Callback<void(bool)>& callback); 44 void CreateBackend(const base::Callback<void(bool)>& callback);
33 45
34 void set_name(const std::string& name) { name_ = name; } 46 void set_name(const std::string& name) { name_ = name; }
35 const std::string& name() const { return name_; } 47 const std::string& name() const { return name_; }
36 int32 id() const { return id_; } 48 int32 id() const { return id_; }
37 void set_id(int32 id) { id_ = id; } 49 void set_id(int32 id) { id_ = id; }
38 50
39 private: 51 private:
40 ServiceWorkerCache(const base::FilePath& path, const std::string& name); 52 ServiceWorkerCache(const base::FilePath& path,
53 const std::string& name,
54 net::URLRequestContext* request_context,
55 ChromeBlobStorageContext* blob_context);
41 56
42 base::FilePath path_; 57 base::FilePath path_;
43 std::string name_; 58 std::string name_;
59 net::URLRequestContext* request_context_;
michaeln 2014/08/12 03:48:52 always makes me queasy to see the rawptrs, but wha
60 ChromeBlobStorageContext* blob_storage_context_;
michaeln 2014/08/12 03:48:52 ditto base::WeakPtr<webkit_blob::BlobStorageContex
44 int32 id_; 61 int32 id_;
45 62
46 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 63 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
47 }; 64 };
48 65
49 } // namespace content 66 } // namespace content
50 67
51 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 68 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698