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

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

Powered by Google App Engine
This is Rietveld 408576698