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

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

Issue 503823002: Creates CacheContext for ServiceWorkerCacheStorage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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"
(...skipping 13 matching lines...) Expand all
24 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 24 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
25 // 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
26 // longer referenced in javascript. 26 // longer referenced in javascript.
27 27
28 // Represents a ServiceWorker Cache as seen in 28 // Represents a ServiceWorker Cache as seen in
29 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 29 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
30 // InitializeIfNeeded must be called before calling the other public members. 30 // InitializeIfNeeded must be called before calling the other public members.
31 class ServiceWorkerCache { 31 class ServiceWorkerCache {
32 public: 32 public:
33 static scoped_ptr<ServiceWorkerCache> CreateMemoryCache( 33 static scoped_ptr<ServiceWorkerCache> CreateMemoryCache(
34 const std::string& name,
35 net::URLRequestContext* request_context, 34 net::URLRequestContext* request_context,
36 base::WeakPtr<storage::BlobStorageContext> blob_context); 35 base::WeakPtr<storage::BlobStorageContext> blob_context);
37 static scoped_ptr<ServiceWorkerCache> CreatePersistentCache( 36 static scoped_ptr<ServiceWorkerCache> CreatePersistentCache(
38 const base::FilePath& path, 37 const base::FilePath& path,
39 const std::string& name,
40 net::URLRequestContext* request_context, 38 net::URLRequestContext* request_context,
41 base::WeakPtr<storage::BlobStorageContext> blob_context); 39 base::WeakPtr<storage::BlobStorageContext> blob_context);
42 40
43 virtual ~ServiceWorkerCache(); 41 virtual ~ServiceWorkerCache();
44 42
45 // 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
46 // success). This must be called before member functions that require a 44 // success). This must be called before member functions that require a
47 // backend are called. 45 // backend are called.
48 void CreateBackend(const base::Callback<void(bool)>& callback); 46 void CreateBackend(const base::Callback<void(bool)>& callback);
49 47
50 void set_name(const std::string& name) { name_ = name; }
51 const std::string& name() const { return name_; }
52 int32 id() const { return id_; }
53 void set_id(int32 id) { id_ = id; }
54
55 base::WeakPtr<ServiceWorkerCache> AsWeakPtr(); 48 base::WeakPtr<ServiceWorkerCache> AsWeakPtr();
56 49
57 private: 50 private:
58 ServiceWorkerCache(const base::FilePath& path, 51 ServiceWorkerCache(const base::FilePath& path,
59 const std::string& name,
60 net::URLRequestContext* request_context, 52 net::URLRequestContext* request_context,
61 base::WeakPtr<storage::BlobStorageContext> blob_context); 53 base::WeakPtr<storage::BlobStorageContext> blob_context);
62 54
63 base::FilePath path_; 55 base::FilePath path_;
64 std::string name_;
65 net::URLRequestContext* request_context_; 56 net::URLRequestContext* request_context_;
66 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; 57 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_;
67 int32 id_;
68 58
69 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; 59 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
70 60
71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 61 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
72 }; 62 };
73 63
74 } // namespace content 64 } // namespace content
75 65
76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 66 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698