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

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

Issue 1039763002: Cache Storage: Move files to content/*/cache_storage, rename classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GN fix Created 5 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_LISTENER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_LISTENER_H_
7
8 #include <list>
9 #include <map>
10
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "content/browser/service_worker/cache_storage_dispatcher_host.h"
14 #include "content/browser/service_worker/service_worker_cache.h"
15 #include "content/browser/service_worker/service_worker_cache_storage.h"
16
17 namespace content {
18
19 struct ServiceWorkerBatchOperation;
20 struct ServiceWorkerCacheQueryParams;
21 struct ServiceWorkerFetchRequest;
22
23 // This class listens for requests on the Cache APIs, and sends response
24 // messages to the renderer process. There is one instance per
25 // CacheStorageDispatcherHost instance.
26 class ServiceWorkerCacheListener {
27 public:
28 ServiceWorkerCacheListener(CacheStorageDispatcherHost* dispatcher,
29 CacheStorageContextImpl* context);
30 ~ServiceWorkerCacheListener();
31
32 bool OnMessageReceived(const IPC::Message& message);
33
34 private:
35 // The message receiver functions for the CacheStorage API:
36 void OnCacheStorageGet(int thread_id,
37 int request_id,
38 const GURL& origin,
39 const base::string16& cache_name);
40 void OnCacheStorageHas(int thread_id,
41 int request_id,
42 const GURL& origin,
43 const base::string16& cache_name);
44 void OnCacheStorageCreate(int thread_id,
45 int request_id,
46 const GURL& origin,
47 const base::string16& cache_name);
48 void OnCacheStorageOpen(int thread_id,
49 int request_id,
50 const GURL& origin,
51 const base::string16& cache_name);
52 void OnCacheStorageDelete(int thread_id,
53 int request_id,
54 const GURL& origin,
55 const base::string16& cache_name);
56 void OnCacheStorageKeys(int thread_id, int request_id, const GURL& origin);
57 void OnCacheStorageMatch(int thread_id,
58 int request_id,
59 const GURL& origin,
60 const ServiceWorkerFetchRequest& request,
61 const ServiceWorkerCacheQueryParams& match_params);
62
63 // The message receiver functions for the Cache API:
64 void OnCacheMatch(int thread_id,
65 int request_id,
66 int cache_id,
67 const ServiceWorkerFetchRequest& request,
68 const ServiceWorkerCacheQueryParams& match_params);
69 void OnCacheMatchAll(int thread_id,
70 int request_id,
71 int cache_id,
72 const ServiceWorkerFetchRequest& request,
73 const ServiceWorkerCacheQueryParams& match_params);
74 void OnCacheKeys(int thread_id,
75 int request_id,
76 int cache_id,
77 const ServiceWorkerFetchRequest& request,
78 const ServiceWorkerCacheQueryParams& match_params);
79 void OnCacheBatch(int thread_id,
80 int request_id,
81 int cache_id,
82 const std::vector<ServiceWorkerBatchOperation>& operations);
83 void OnCacheClosed(int cache_id);
84 void OnBlobDataHandled(const std::string& uuid);
85
86 private:
87 typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit.
88 typedef std::map<CacheID, scoped_refptr<ServiceWorkerCache>> IDToCacheMap;
89 typedef std::map<std::string, std::list<storage::BlobDataHandle>>
90 UUIDToBlobDataHandleList;
91
92 void Send(IPC::Message* message);
93
94 // CacheStorageManager callbacks
95 void OnCacheStorageGetCallback(
96 int thread_id,
97 int request_id,
98 const scoped_refptr<ServiceWorkerCache>& cache,
99 ServiceWorkerCacheStorage::CacheStorageError error);
100 void OnCacheStorageHasCallback(
101 int thread_id,
102 int request_id,
103 bool has_cache,
104 ServiceWorkerCacheStorage::CacheStorageError error);
105 void OnCacheStorageCreateCallback(
106 int thread_id,
107 int request_id,
108 const scoped_refptr<ServiceWorkerCache>& cache,
109 ServiceWorkerCacheStorage::CacheStorageError error);
110 void OnCacheStorageOpenCallback(
111 int thread_id,
112 int request_id,
113 const scoped_refptr<ServiceWorkerCache>& cache,
114 ServiceWorkerCacheStorage::CacheStorageError error);
115 void OnCacheStorageDeleteCallback(
116 int thread_id,
117 int request_id,
118 bool deleted,
119 ServiceWorkerCacheStorage::CacheStorageError error);
120 void OnCacheStorageKeysCallback(
121 int thread_id,
122 int request_id,
123 const std::vector<std::string>& strings,
124 ServiceWorkerCacheStorage::CacheStorageError error);
125 void OnCacheStorageMatchCallback(
126 int thread_id,
127 int request_id,
128 ServiceWorkerCache::ErrorType error,
129 scoped_ptr<ServiceWorkerResponse> response,
130 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
131
132 // Cache callbacks
133 void OnCacheMatchCallback(
134 int thread_id,
135 int request_id,
136 const scoped_refptr<ServiceWorkerCache>& cache,
137 ServiceWorkerCache::ErrorType error,
138 scoped_ptr<ServiceWorkerResponse> response,
139 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
140 void OnCacheKeysCallback(int thread_id,
141 int request_id,
142 const scoped_refptr<ServiceWorkerCache>& cache,
143 ServiceWorkerCache::ErrorType error,
144 scoped_ptr<ServiceWorkerCache::Requests> requests);
145 void OnCacheDeleteCallback(int thread_id,
146 int request_id,
147 const scoped_refptr<ServiceWorkerCache>& cache,
148 ServiceWorkerCache::ErrorType error);
149 void OnCachePutCallback(int thread_id,
150 int request_id,
151 const scoped_refptr<ServiceWorkerCache>& cache,
152 ServiceWorkerCache::ErrorType error,
153 scoped_ptr<ServiceWorkerResponse> response,
154 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
155
156 // Hangs onto a scoped_refptr for the cache if it isn't already doing so.
157 // Returns a unique cache_id. Call DropCacheReference when the client is done
158 // with this cache.
159 CacheID StoreCacheReference(const scoped_refptr<ServiceWorkerCache>& cache);
160 void DropCacheReference(CacheID cache_id);
161
162 // Stores blob handles while waiting for acknowledgement of receipt from the
163 // renderer.
164 void StoreBlobDataHandle(
165 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
166 void DropBlobDataHandle(std::string uuid);
167
168 // Pointer to the context that owns this instance.
169 CacheStorageDispatcherHost* dispatcher_;
170
171 scoped_refptr<CacheStorageContextImpl> context_;
172
173 IDToCacheMap id_to_cache_map_;
174 CacheID next_cache_id_ = 0;
175
176 UUIDToBlobDataHandleList blob_handle_store_;
177
178 base::WeakPtrFactory<ServiceWorkerCacheListener> weak_factory_;
179
180 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheListener);
181 };
182
183 } // namespace content
184
185 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_LISTENER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698