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 #include "config.h" | 5 #include "config.h" |
6 #include "modules/cachestorage/InspectorCacheStorageAgent.h" | 6 #include "modules/cachestorage/InspectorCacheStorageAgent.h" |
7 | 7 |
8 #include "core/InspectorBackendDispatcher.h" | 8 #include "core/InspectorBackendDispatcher.h" |
9 #include "core/InspectorTypeBuilder.h" | 9 #include "core/InspectorTypeBuilder.h" |
10 #include "platform/JSONValues.h" | 10 #include "platform/JSONValues.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 : public WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks { | 107 : public WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks { |
108 WTF_MAKE_NONCOPYABLE(RequestCacheNames); | 108 WTF_MAKE_NONCOPYABLE(RequestCacheNames); |
109 | 109 |
110 public: | 110 public: |
111 RequestCacheNames(const String& securityOrigin, PassRefPtrWillBeRawPtr<Reque
stCacheNamesCallback> callback) | 111 RequestCacheNames(const String& securityOrigin, PassRefPtrWillBeRawPtr<Reque
stCacheNamesCallback> callback) |
112 : m_securityOrigin(securityOrigin) | 112 : m_securityOrigin(securityOrigin) |
113 , m_callback(callback) | 113 , m_callback(callback) |
114 { | 114 { |
115 } | 115 } |
116 | 116 |
117 virtual ~RequestCacheNames() { } | 117 ~RequestCacheNames() override { } |
118 | 118 |
119 void onSuccess(WebVector<WebString>* caches) | 119 void onSuccess(WebVector<WebString>* caches) |
120 { | 120 { |
121 RefPtr<Array<Cache>> array = Array<Cache>::create(); | 121 RefPtr<Array<Cache>> array = Array<Cache>::create(); |
122 for (size_t i = 0; i < caches->size(); i++) { | 122 for (size_t i = 0; i < caches->size(); i++) { |
123 String name = String((*caches)[i]); | 123 String name = String((*caches)[i]); |
124 RefPtr<Cache> entry = Cache::create() | 124 RefPtr<Cache> entry = Cache::create() |
125 .setSecurityOrigin(m_securityOrigin) | 125 .setSecurityOrigin(m_securityOrigin) |
126 .setCacheName(name) | 126 .setCacheName(name) |
127 .setCacheId(buildCacheId(m_securityOrigin, name)); | 127 .setCacheId(buildCacheId(m_securityOrigin, name)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 public: | 214 public: |
215 GetCacheResponsesForRequestData( | 215 GetCacheResponsesForRequestData( |
216 const DataRequestParams& params, const WebServiceWorkerRequest& request, | 216 const DataRequestParams& params, const WebServiceWorkerRequest& request, |
217 PassRefPtr<ResponsesAccumulator> accum, PassRefPtrWillBeRawPtr<RequestEn
triesCallback> callback) | 217 PassRefPtr<ResponsesAccumulator> accum, PassRefPtrWillBeRawPtr<RequestEn
triesCallback> callback) |
218 : m_params(params) | 218 : m_params(params) |
219 , m_request(request) | 219 , m_request(request) |
220 , m_accumulator(accum) | 220 , m_accumulator(accum) |
221 , m_callback(callback) | 221 , m_callback(callback) |
222 { | 222 { |
223 } | 223 } |
224 virtual ~GetCacheResponsesForRequestData() { } | 224 ~GetCacheResponsesForRequestData() override { } |
225 | 225 |
226 void onSuccess(WebServiceWorkerResponse* response) | 226 void onSuccess(WebServiceWorkerResponse* response) |
227 { | 227 { |
228 m_accumulator->addRequestResponsePair(m_request, *response); | 228 m_accumulator->addRequestResponsePair(m_request, *response); |
229 } | 229 } |
230 | 230 |
231 void onError(WebServiceWorkerCacheError* error) | 231 void onError(WebServiceWorkerCacheError* error) |
232 { | 232 { |
233 m_callback->sendFailure(String::format("Error requesting responses for c
ache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(e
rror).data())); | 233 m_callback->sendFailure(String::format("Error requesting responses for c
ache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(e
rror).data())); |
234 } | 234 } |
235 | 235 |
236 private: | 236 private: |
237 DataRequestParams m_params; | 237 DataRequestParams m_params; |
238 WebServiceWorkerRequest m_request; | 238 WebServiceWorkerRequest m_request; |
239 RefPtr<ResponsesAccumulator> m_accumulator; | 239 RefPtr<ResponsesAccumulator> m_accumulator; |
240 RefPtrWillBePersistent<RequestEntriesCallback> m_callback; | 240 RefPtrWillBePersistent<RequestEntriesCallback> m_callback; |
241 }; | 241 }; |
242 | 242 |
243 class GetCacheKeysForRequestData : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { | 243 class GetCacheKeysForRequestData : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { |
244 WTF_MAKE_NONCOPYABLE(GetCacheKeysForRequestData); | 244 WTF_MAKE_NONCOPYABLE(GetCacheKeysForRequestData); |
245 | 245 |
246 public: | 246 public: |
247 GetCacheKeysForRequestData(const DataRequestParams& params, PassOwnPtr<WebSe
rviceWorkerCache> cache, PassRefPtrWillBeRawPtr<RequestEntriesCallback> callback
) | 247 GetCacheKeysForRequestData(const DataRequestParams& params, PassOwnPtr<WebSe
rviceWorkerCache> cache, PassRefPtrWillBeRawPtr<RequestEntriesCallback> callback
) |
248 : m_params(params) | 248 : m_params(params) |
249 , m_cache(cache) | 249 , m_cache(cache) |
250 , m_callback(callback) | 250 , m_callback(callback) |
251 { | 251 { |
252 } | 252 } |
253 virtual ~GetCacheKeysForRequestData() { } | 253 ~GetCacheKeysForRequestData() override { } |
254 | 254 |
255 void onSuccess(WebVector<WebServiceWorkerRequest>* requests) | 255 void onSuccess(WebVector<WebServiceWorkerRequest>* requests) |
256 { | 256 { |
257 if (requests->isEmpty()) { | 257 if (requests->isEmpty()) { |
258 RefPtr<Array<DataEntry>> array = Array<DataEntry>::create(); | 258 RefPtr<Array<DataEntry>> array = Array<DataEntry>::create(); |
259 m_callback->sendSuccess(array, false); | 259 m_callback->sendSuccess(array, false); |
260 return; | 260 return; |
261 } | 261 } |
262 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul
ator(requests->size(), m_params, m_callback)); | 262 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul
ator(requests->size(), m_params, m_callback)); |
263 | 263 |
(...skipping 18 matching lines...) Expand all Loading... |
282 class GetCacheForRequestData | 282 class GetCacheForRequestData |
283 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { | 283 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { |
284 WTF_MAKE_NONCOPYABLE(GetCacheForRequestData); | 284 WTF_MAKE_NONCOPYABLE(GetCacheForRequestData); |
285 | 285 |
286 public: | 286 public: |
287 GetCacheForRequestData(const DataRequestParams& params, PassRefPtrWillBeRawP
tr<RequestEntriesCallback> callback) | 287 GetCacheForRequestData(const DataRequestParams& params, PassRefPtrWillBeRawP
tr<RequestEntriesCallback> callback) |
288 : m_params(params) | 288 : m_params(params) |
289 , m_callback(callback) | 289 , m_callback(callback) |
290 { | 290 { |
291 } | 291 } |
292 virtual ~GetCacheForRequestData() { } | 292 ~GetCacheForRequestData() override { } |
293 | 293 |
294 void onSuccess(WebServiceWorkerCache* cache) | 294 void onSuccess(WebServiceWorkerCache* cache) |
295 { | 295 { |
296 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c
ache), m_callback); | 296 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c
ache), m_callback); |
297 cache->dispatchKeys(cacheRequest, nullptr, WebServiceWorkerCache::QueryP
arams()); | 297 cache->dispatchKeys(cacheRequest, nullptr, WebServiceWorkerCache::QueryP
arams()); |
298 } | 298 } |
299 | 299 |
300 void onError(WebServiceWorkerCacheError* error) | 300 void onError(WebServiceWorkerCacheError* error) |
301 { | 301 { |
302 m_callback->sendFailure(String::format("Error requesting cache %s: %s",
m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data())); | 302 m_callback->sendFailure(String::format("Error requesting cache %s: %s",
m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data())); |
303 } | 303 } |
304 | 304 |
305 private: | 305 private: |
306 DataRequestParams m_params; | 306 DataRequestParams m_params; |
307 RefPtrWillBePersistent<RequestEntriesCallback> m_callback; | 307 RefPtrWillBePersistent<RequestEntriesCallback> m_callback; |
308 }; | 308 }; |
309 | 309 |
310 class DeleteCache : public WebServiceWorkerCacheStorage::CacheStorageCallbacks { | 310 class DeleteCache : public WebServiceWorkerCacheStorage::CacheStorageCallbacks { |
311 WTF_MAKE_NONCOPYABLE(DeleteCache); | 311 WTF_MAKE_NONCOPYABLE(DeleteCache); |
312 | 312 |
313 public: | 313 public: |
314 DeleteCache(PassRefPtrWillBeRawPtr<DeleteCacheCallback> callback) | 314 DeleteCache(PassRefPtrWillBeRawPtr<DeleteCacheCallback> callback) |
315 : m_callback(callback) | 315 : m_callback(callback) |
316 { | 316 { |
317 } | 317 } |
318 virtual ~DeleteCache() { } | 318 ~DeleteCache() override { } |
319 | 319 |
320 void onSuccess() | 320 void onSuccess() |
321 { | 321 { |
322 m_callback->sendSuccess(); | 322 m_callback->sendSuccess(); |
323 } | 323 } |
324 | 324 |
325 void onError(WebServiceWorkerCacheError* error) | 325 void onError(WebServiceWorkerCacheError* error) |
326 { | 326 { |
327 m_callback->sendFailure(String::format("Error requesting cache names: %s
", serviceWorkerCacheErrorString(error).data())); | 327 m_callback->sendFailure(String::format("Error requesting cache names: %s
", serviceWorkerCacheErrorString(error).data())); |
328 } | 328 } |
329 | 329 |
330 private: | 330 private: |
331 RefPtrWillBePersistent<DeleteCacheCallback> m_callback; | 331 RefPtrWillBePersistent<DeleteCacheCallback> m_callback; |
332 }; | 332 }; |
333 | 333 |
334 class DeleteCacheEntry : public WebServiceWorkerCache::CacheBatchCallbacks { | 334 class DeleteCacheEntry : public WebServiceWorkerCache::CacheBatchCallbacks { |
335 WTF_MAKE_NONCOPYABLE(DeleteCacheEntry); | 335 WTF_MAKE_NONCOPYABLE(DeleteCacheEntry); |
336 public: | 336 public: |
337 | 337 |
338 DeleteCacheEntry(PassRefPtrWillBeRawPtr<DeleteEntryCallback> callback) | 338 DeleteCacheEntry(PassRefPtrWillBeRawPtr<DeleteEntryCallback> callback) |
339 : m_callback(callback) | 339 : m_callback(callback) |
340 { | 340 { |
341 } | 341 } |
342 virtual ~DeleteCacheEntry() { } | 342 ~DeleteCacheEntry() override { } |
343 | 343 |
344 void onSuccess() | 344 void onSuccess() |
345 { | 345 { |
346 m_callback->sendSuccess(); | 346 m_callback->sendSuccess(); |
347 } | 347 } |
348 | 348 |
349 void onError(WebServiceWorkerCacheError* error) | 349 void onError(WebServiceWorkerCacheError* error) |
350 { | 350 { |
351 m_callback->sendFailure(String::format("Error requesting cache names: %s
", serviceWorkerCacheErrorString(error).data())); | 351 m_callback->sendFailure(String::format("Error requesting cache names: %s
", serviceWorkerCacheErrorString(error).data())); |
352 } | 352 } |
353 | 353 |
354 private: | 354 private: |
355 RefPtrWillBePersistent<DeleteEntryCallback> m_callback; | 355 RefPtrWillBePersistent<DeleteEntryCallback> m_callback; |
356 }; | 356 }; |
357 | 357 |
358 class GetCacheForDeleteEntry | 358 class GetCacheForDeleteEntry |
359 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { | 359 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { |
360 WTF_MAKE_NONCOPYABLE(GetCacheForDeleteEntry); | 360 WTF_MAKE_NONCOPYABLE(GetCacheForDeleteEntry); |
361 | 361 |
362 public: | 362 public: |
363 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, P
assRefPtrWillBeRawPtr<DeleteEntryCallback> callback) | 363 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, P
assRefPtrWillBeRawPtr<DeleteEntryCallback> callback) |
364 : m_requestSpec(requestSpec) | 364 : m_requestSpec(requestSpec) |
365 , m_cacheName(cacheName) | 365 , m_cacheName(cacheName) |
366 , m_callback(callback) | 366 , m_callback(callback) |
367 { | 367 { |
368 } | 368 } |
369 virtual ~GetCacheForDeleteEntry() { } | 369 ~GetCacheForDeleteEntry() override { } |
370 | 370 |
371 void onSuccess(WebServiceWorkerCache* cache) | 371 void onSuccess(WebServiceWorkerCache* cache) |
372 { | 372 { |
373 auto* deleteRequest = new DeleteCacheEntry( m_callback); | 373 auto* deleteRequest = new DeleteCacheEntry( m_callback); |
374 BatchOperation deleteOperation; | 374 BatchOperation deleteOperation; |
375 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele
te; | 375 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele
te; |
376 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec)); | 376 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec)); |
377 Vector<BatchOperation> operations; | 377 Vector<BatchOperation> operations; |
378 operations.append(deleteOperation); | 378 operations.append(deleteOperation); |
379 cache->dispatchBatch(deleteRequest, WebVector<BatchOperation>(operations
)); | 379 cache->dispatchBatch(deleteRequest, WebVector<BatchOperation>(operations
)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId(
errorString, cacheId, &cacheName); | 446 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId(
errorString, cacheId, &cacheName); |
447 if (!cache) { | 447 if (!cache) { |
448 callback->sendFailure(*errorString); | 448 callback->sendFailure(*errorString); |
449 return; | 449 return; |
450 } | 450 } |
451 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, callback)
, WebString(cacheName)); | 451 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, callback)
, WebString(cacheName)); |
452 } | 452 } |
453 | 453 |
454 | 454 |
455 } // namespace blink | 455 } // namespace blink |
OLD | NEW |