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

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

Issue 658583006: [ServiceWorkerCache] Make ServiceWorkerCache::Put guarantee callback like the header says (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 11 matching lines...) Expand all
22 class BlobData; 22 class BlobData;
23 class BlobDataHandle; 23 class BlobDataHandle;
24 class BlobStorageContext; 24 class BlobStorageContext;
25 class QuotaManagerProxy; 25 class QuotaManagerProxy;
26 } 26 }
27 27
28 namespace content { 28 namespace content {
29 class ChromeBlobStorageContext; 29 class ChromeBlobStorageContext;
30 class ServiceWorkerCacheMetadata; 30 class ServiceWorkerCacheMetadata;
31 31
32 // TODO(jkarlin): Unload cache backend from memory once the cache object is no
33 // longer referenced in javascript.
34
35 // Represents a ServiceWorker Cache as seen in 32 // Represents a ServiceWorker Cache as seen in
36 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. 33 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html.
37 // InitializeIfNeeded must be called before calling the other public members. 34 // InitializeIfNeeded must be called before calling the other public members.
38 class CONTENT_EXPORT ServiceWorkerCache 35 class CONTENT_EXPORT ServiceWorkerCache
39 : public base::RefCounted<ServiceWorkerCache> { 36 : public base::RefCounted<ServiceWorkerCache> {
40 public: 37 public:
41 enum ErrorType { 38 enum ErrorType {
42 ErrorTypeOK = 0, 39 ErrorTypeOK = 0,
43 ErrorTypeExists, 40 ErrorTypeExists,
44 ErrorTypeStorage, 41 ErrorTypeStorage,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 93
97 void set_backend(scoped_ptr<disk_cache::Backend> backend) { 94 void set_backend(scoped_ptr<disk_cache::Backend> backend) {
98 backend_ = backend.Pass(); 95 backend_ = backend.Pass();
99 } 96 }
100 97
101 base::WeakPtr<ServiceWorkerCache> AsWeakPtr(); 98 base::WeakPtr<ServiceWorkerCache> AsWeakPtr();
102 99
103 private: 100 private:
104 friend class base::RefCounted<ServiceWorkerCache>; 101 friend class base::RefCounted<ServiceWorkerCache>;
105 102
103 class BlobReader;
106 struct KeysContext; 104 struct KeysContext;
105 struct PutContext;
107 typedef std::vector<disk_cache::Entry*> Entries; 106 typedef std::vector<disk_cache::Entry*> Entries;
108 107
109 ServiceWorkerCache( 108 ServiceWorkerCache(
110 const GURL& origin, 109 const GURL& origin,
111 const base::FilePath& path, 110 const base::FilePath& path,
112 net::URLRequestContext* request_context, 111 net::URLRequestContext* request_context,
113 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, 112 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy,
114 base::WeakPtr<storage::BlobStorageContext> blob_context); 113 base::WeakPtr<storage::BlobStorageContext> blob_context);
115 114
116 // Operations in progress will complete after the cache is deleted but pending 115 // Operations in progress will complete after the cache is deleted but pending
117 // operations (those operations waiting for init to finish) won't. 116 // operations (those operations waiting for init to finish) won't.
118 virtual ~ServiceWorkerCache(); 117 virtual ~ServiceWorkerCache();
119 118
120 void PutImpl(scoped_ptr<ServiceWorkerFetchRequest> request, 119 // Put callbacks.
121 scoped_ptr<ServiceWorkerResponse> response, 120 static void PutImpl(scoped_ptr<PutContext> put_context);
122 scoped_ptr<storage::BlobDataHandle> blob_data_handle, 121 static void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv);
123 const ResponseCallback& callback); 122 static void PutDidWriteHeaders(scoped_ptr<PutContext> put_context,
123 int expected_bytes,
124 int rv);
125 static void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context,
126 scoped_ptr<BlobReader> blob_reader,
127 disk_cache::ScopedEntryPtr entry,
128 bool success);
124 129
125 // Static callbacks for the Keys function. 130 // Static callbacks for the Keys function.
126 static void KeysDidOpenNextEntry(scoped_ptr<KeysContext> keys_context, 131 static void KeysDidOpenNextEntry(scoped_ptr<KeysContext> keys_context,
127 int rv); 132 int rv);
128 static void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context, 133 static void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context,
129 const Entries::iterator& iter); 134 const Entries::iterator& iter);
130 static void KeysDidReadMetadata( 135 static void KeysDidReadMetadata(
131 scoped_ptr<KeysContext> keys_context, 136 scoped_ptr<KeysContext> keys_context,
132 const Entries::iterator& iter, 137 const Entries::iterator& iter,
133 scoped_ptr<ServiceWorkerCacheMetadata> metadata); 138 scoped_ptr<ServiceWorkerCacheMetadata> metadata);
(...skipping 20 matching lines...) Expand all
154 bool memory_only_; 159 bool memory_only_;
155 160
156 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; 161 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_;
157 162
158 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); 163 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache);
159 }; 164 };
160 165
161 } // namespace content 166 } // namespace content
162 167
163 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ 168 #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