OLD | NEW |
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_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 std::unique_ptr<blink::WebServiceWorkerCache::CacheBatchCallbacks> | 159 std::unique_ptr<blink::WebServiceWorkerCache::CacheBatchCallbacks> |
160 callbacks, | 160 callbacks, |
161 const blink::WebVector<blink::WebServiceWorkerCache::BatchOperation>& | 161 const blink::WebVector<blink::WebServiceWorkerCache::BatchOperation>& |
162 batch_operations); | 162 batch_operations); |
163 | 163 |
164 void OnWebCacheDestruction(int cache_id); | 164 void OnWebCacheDestruction(int cache_id); |
165 | 165 |
166 private: | 166 private: |
167 class WebCache; | 167 class WebCache; |
168 | 168 |
169 typedef IDMap<blink::WebServiceWorkerCacheStorage::CacheStorageCallbacks, | 169 using CallbacksMap = IDMap<std::unique_ptr< |
170 IDMapOwnPointer> CallbacksMap; | 170 blink::WebServiceWorkerCacheStorage::CacheStorageCallbacks>>; |
171 typedef IDMap< | 171 using WithCacheCallbacksMap = IDMap<std::unique_ptr< |
172 blink::WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks, | 172 blink::WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks>>; |
173 IDMapOwnPointer> WithCacheCallbacksMap; | 173 using KeysCallbacksMap = IDMap<std::unique_ptr< |
174 typedef IDMap<blink::WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks, | 174 blink::WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks>>; |
175 IDMapOwnPointer> KeysCallbacksMap; | 175 using StorageMatchCallbacksMap = IDMap<std::unique_ptr< |
176 typedef IDMap<blink::WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks, | 176 blink::WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks>>; |
177 IDMapOwnPointer> StorageMatchCallbacksMap; | |
178 | 177 |
179 typedef base::hash_map<int32_t, base::TimeTicks> TimeMap; | 178 using TimeMap = base::hash_map<int32_t, base::TimeTicks>; |
180 | 179 |
181 typedef IDMap<blink::WebServiceWorkerCache::CacheMatchCallbacks, | 180 using MatchCallbacksMap = |
182 IDMapOwnPointer> MatchCallbacksMap; | 181 IDMap<std::unique_ptr<blink::WebServiceWorkerCache::CacheMatchCallbacks>>; |
183 typedef IDMap<blink::WebServiceWorkerCache::CacheWithResponsesCallbacks, | 182 using WithResponsesCallbacksMap = IDMap<std::unique_ptr< |
184 IDMapOwnPointer> WithResponsesCallbacksMap; | 183 blink::WebServiceWorkerCache::CacheWithResponsesCallbacks>>; |
185 typedef IDMap<blink::WebServiceWorkerCache::CacheWithRequestsCallbacks, | 184 using WithRequestsCallbacksMap = IDMap<std::unique_ptr< |
186 IDMapOwnPointer> WithRequestsCallbacksMap; | 185 blink::WebServiceWorkerCache::CacheWithRequestsCallbacks>>; |
187 using BatchCallbacksMap = | 186 using BatchCallbacksMap = |
188 IDMap<blink::WebServiceWorkerCache::CacheBatchCallbacks, IDMapOwnPointer>; | 187 IDMap<std::unique_ptr<blink::WebServiceWorkerCache::CacheBatchCallbacks>>; |
189 | 188 |
190 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } | 189 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } |
191 | 190 |
192 void PopulateWebResponseFromResponse( | 191 void PopulateWebResponseFromResponse( |
193 const ServiceWorkerResponse& response, | 192 const ServiceWorkerResponse& response, |
194 blink::WebServiceWorkerResponse* web_response); | 193 blink::WebServiceWorkerResponse* web_response); |
195 | 194 |
196 blink::WebVector<blink::WebServiceWorkerResponse> WebResponsesFromResponses( | 195 blink::WebVector<blink::WebServiceWorkerResponse> WebResponsesFromResponses( |
197 const std::vector<ServiceWorkerResponse>& responses); | 196 const std::vector<ServiceWorkerResponse>& responses); |
198 | 197 |
199 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 198 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
200 | 199 |
201 CallbacksMap has_callbacks_; | 200 CallbacksMap has_callbacks_; |
202 WithCacheCallbacksMap open_callbacks_; | 201 WithCacheCallbacksMap open_callbacks_; |
203 CallbacksMap delete_callbacks_; | 202 CallbacksMap delete_callbacks_; |
204 KeysCallbacksMap keys_callbacks_; | 203 KeysCallbacksMap keys_callbacks_; |
205 StorageMatchCallbacksMap match_callbacks_; | 204 StorageMatchCallbacksMap match_callbacks_; |
206 | 205 |
207 TimeMap has_times_; | 206 TimeMap has_times_; |
208 TimeMap open_times_; | 207 TimeMap open_times_; |
209 TimeMap delete_times_; | 208 TimeMap delete_times_; |
210 TimeMap keys_times_; | 209 TimeMap keys_times_; |
211 TimeMap match_times_; | 210 TimeMap match_times_; |
212 | 211 |
213 // The individual caches created under this CacheStorage object. | 212 // The individual caches created under this CacheStorage object. |
214 IDMap<WebCache, IDMapExternalPointer> web_caches_; | 213 IDMap<WebCache*> web_caches_; |
215 | 214 |
216 // These ID maps are held in the CacheStorage object rather than the Cache | 215 // These ID maps are held in the CacheStorage object rather than the Cache |
217 // object to ensure that the IDs are unique. | 216 // object to ensure that the IDs are unique. |
218 MatchCallbacksMap cache_match_callbacks_; | 217 MatchCallbacksMap cache_match_callbacks_; |
219 WithResponsesCallbacksMap cache_match_all_callbacks_; | 218 WithResponsesCallbacksMap cache_match_all_callbacks_; |
220 WithRequestsCallbacksMap cache_keys_callbacks_; | 219 WithRequestsCallbacksMap cache_keys_callbacks_; |
221 BatchCallbacksMap cache_batch_callbacks_; | 220 BatchCallbacksMap cache_batch_callbacks_; |
222 | 221 |
223 TimeMap cache_match_times_; | 222 TimeMap cache_match_times_; |
224 TimeMap cache_match_all_times_; | 223 TimeMap cache_match_all_times_; |
225 TimeMap cache_keys_times_; | 224 TimeMap cache_keys_times_; |
226 TimeMap cache_batch_times_; | 225 TimeMap cache_batch_times_; |
227 | 226 |
228 base::WeakPtrFactory<CacheStorageDispatcher> weak_factory_; | 227 base::WeakPtrFactory<CacheStorageDispatcher> weak_factory_; |
229 | 228 |
230 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcher); | 229 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcher); |
231 }; | 230 }; |
232 | 231 |
233 } // namespace content | 232 } // namespace content |
234 | 233 |
235 #endif // CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ | 234 #endif // CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
OLD | NEW |