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/Cache.h" | 6 #include "modules/cachestorage/Cache.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "public/platform/WebServiceWorkerCache.h" | 23 #include "public/platform/WebServiceWorkerCache.h" |
24 | 24 |
25 namespace blink { | 25 namespace blink { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // FIXME: Consider using CallbackPromiseAdapter. | 29 // FIXME: Consider using CallbackPromiseAdapter. |
30 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { | 30 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { |
31 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); | 31 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); |
32 public: | 32 public: |
33 CacheMatchCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver) | 33 explicit CacheMatchCallbacks(ScriptPromiseResolver* resolver) |
34 : m_resolver(resolver) { } | 34 : m_resolver(resolver) { } |
35 | 35 |
36 void onSuccess(WebServiceWorkerResponse* webResponse) override | 36 void onSuccess(WebServiceWorkerResponse* webResponse) override |
37 { | 37 { |
38 m_resolver->resolve(Response::create(m_resolver->scriptState()->executio
nContext(), *webResponse)); | 38 m_resolver->resolve(Response::create(m_resolver->scriptState()->executio
nContext(), *webResponse)); |
39 m_resolver.clear(); | 39 m_resolver.clear(); |
40 } | 40 } |
41 | 41 |
42 // Ownership of |rawReason| must be passed. | 42 // Ownership of |rawReason| must be passed. |
43 void onError(WebServiceWorkerCacheError* rawReason) override | 43 void onError(WebServiceWorkerCacheError* rawReason) override |
44 { | 44 { |
45 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); | 45 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); |
46 if (*reason == WebServiceWorkerCacheErrorNotFound) | 46 if (*reason == WebServiceWorkerCacheErrorNotFound) |
47 m_resolver->resolve(); | 47 m_resolver->resolve(); |
48 else | 48 else |
49 m_resolver->reject(CacheStorageError::createException(*reason)); | 49 m_resolver->reject(CacheStorageError::createException(*reason)); |
50 m_resolver.clear(); | 50 m_resolver.clear(); |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 54 Persistent<ScriptPromiseResolver> m_resolver; |
55 }; | 55 }; |
56 | 56 |
57 // FIXME: Consider using CallbackPromiseAdapter. | 57 // FIXME: Consider using CallbackPromiseAdapter. |
58 class CacheWithResponsesCallbacks : public WebServiceWorkerCache::CacheWithRespo
nsesCallbacks { | 58 class CacheWithResponsesCallbacks : public WebServiceWorkerCache::CacheWithRespo
nsesCallbacks { |
59 WTF_MAKE_NONCOPYABLE(CacheWithResponsesCallbacks); | 59 WTF_MAKE_NONCOPYABLE(CacheWithResponsesCallbacks); |
60 public: | 60 public: |
61 CacheWithResponsesCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> re
solver) | 61 explicit CacheWithResponsesCallbacks(ScriptPromiseResolver* resolver) |
62 : m_resolver(resolver) { } | 62 : m_resolver(resolver) { } |
63 | 63 |
64 void onSuccess(WebVector<WebServiceWorkerResponse>* webResponses) override | 64 void onSuccess(WebVector<WebServiceWorkerResponse>* webResponses) override |
65 { | 65 { |
66 HeapVector<Member<Response>> responses; | 66 HeapVector<Member<Response>> responses; |
67 for (size_t i = 0; i < webResponses->size(); ++i) | 67 for (size_t i = 0; i < webResponses->size(); ++i) |
68 responses.append(Response::create(m_resolver->scriptState()->executi
onContext(), (*webResponses)[i])); | 68 responses.append(Response::create(m_resolver->scriptState()->executi
onContext(), (*webResponses)[i])); |
69 m_resolver->resolve(responses); | 69 m_resolver->resolve(responses); |
70 m_resolver.clear(); | 70 m_resolver.clear(); |
71 } | 71 } |
72 | 72 |
73 // Ownership of |rawReason| must be passed. | 73 // Ownership of |rawReason| must be passed. |
74 void onError(WebServiceWorkerCacheError* rawReason) override | 74 void onError(WebServiceWorkerCacheError* rawReason) override |
75 { | 75 { |
76 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); | 76 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); |
77 m_resolver->reject(CacheStorageError::createException(*reason)); | 77 m_resolver->reject(CacheStorageError::createException(*reason)); |
78 m_resolver.clear(); | 78 m_resolver.clear(); |
79 } | 79 } |
80 | 80 |
81 protected: | 81 protected: |
82 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 82 Persistent<ScriptPromiseResolver> m_resolver; |
83 }; | 83 }; |
84 | 84 |
85 // FIXME: Consider using CallbackPromiseAdapter. | 85 // FIXME: Consider using CallbackPromiseAdapter. |
86 class CacheDeleteCallback : public WebServiceWorkerCache::CacheBatchCallbacks { | 86 class CacheDeleteCallback : public WebServiceWorkerCache::CacheBatchCallbacks { |
87 WTF_MAKE_NONCOPYABLE(CacheDeleteCallback); | 87 WTF_MAKE_NONCOPYABLE(CacheDeleteCallback); |
88 public: | 88 public: |
89 CacheDeleteCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver) | 89 explicit CacheDeleteCallback(ScriptPromiseResolver* resolver) |
90 : m_resolver(resolver) { } | 90 : m_resolver(resolver) { } |
91 | 91 |
92 void onSuccess() override | 92 void onSuccess() override |
93 { | 93 { |
94 m_resolver->resolve(true); | 94 m_resolver->resolve(true); |
95 m_resolver.clear(); | 95 m_resolver.clear(); |
96 } | 96 } |
97 | 97 |
98 // Ownership of |rawReason| must be passed. | 98 // Ownership of |rawReason| must be passed. |
99 void onError(WebServiceWorkerCacheError* rawReason) override | 99 void onError(WebServiceWorkerCacheError* rawReason) override |
100 { | 100 { |
101 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); | 101 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); |
102 if (*reason == WebServiceWorkerCacheErrorNotFound) | 102 if (*reason == WebServiceWorkerCacheErrorNotFound) |
103 m_resolver->resolve(false); | 103 m_resolver->resolve(false); |
104 else | 104 else |
105 m_resolver->reject(CacheStorageError::createException(*reason)); | 105 m_resolver->reject(CacheStorageError::createException(*reason)); |
106 m_resolver.clear(); | 106 m_resolver.clear(); |
107 } | 107 } |
108 | 108 |
109 private: | 109 private: |
110 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 110 Persistent<ScriptPromiseResolver> m_resolver; |
111 }; | 111 }; |
112 | 112 |
113 // FIXME: Consider using CallbackPromiseAdapter. | 113 // FIXME: Consider using CallbackPromiseAdapter. |
114 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { | 114 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { |
115 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); | 115 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); |
116 public: | 116 public: |
117 CacheWithRequestsCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> res
olver) | 117 explicit CacheWithRequestsCallbacks(ScriptPromiseResolver* resolver) |
118 : m_resolver(resolver) { } | 118 : m_resolver(resolver) { } |
119 | 119 |
120 void onSuccess(WebVector<WebServiceWorkerRequest>* webRequests) override | 120 void onSuccess(WebVector<WebServiceWorkerRequest>* webRequests) override |
121 { | 121 { |
122 HeapVector<Member<Request>> requests; | 122 HeapVector<Member<Request>> requests; |
123 for (size_t i = 0; i < webRequests->size(); ++i) | 123 for (size_t i = 0; i < webRequests->size(); ++i) |
124 requests.append(Request::create(m_resolver->scriptState()->execution
Context(), (*webRequests)[i])); | 124 requests.append(Request::create(m_resolver->scriptState()->execution
Context(), (*webRequests)[i])); |
125 m_resolver->resolve(requests); | 125 m_resolver->resolve(requests); |
126 m_resolver.clear(); | 126 m_resolver.clear(); |
127 } | 127 } |
128 | 128 |
129 // Ownership of |rawReason| must be passed. | 129 // Ownership of |rawReason| must be passed. |
130 void onError(WebServiceWorkerCacheError* rawReason) override | 130 void onError(WebServiceWorkerCacheError* rawReason) override |
131 { | 131 { |
132 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); | 132 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); |
133 m_resolver->reject(CacheStorageError::createException(*reason)); | 133 m_resolver->reject(CacheStorageError::createException(*reason)); |
134 m_resolver.clear(); | 134 m_resolver.clear(); |
135 } | 135 } |
136 | 136 |
137 private: | 137 private: |
138 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 138 Persistent<ScriptPromiseResolver> m_resolver; |
139 }; | 139 }; |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch | 143 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch |
144 // promise. It should be better to achieve this only within C++ world. | 144 // promise. It should be better to achieve this only within C++ world. |
145 class Cache::FetchResolvedForAdd final : public ScriptFunction { | 145 class Cache::FetchResolvedForAdd final : public ScriptFunction { |
146 public: | 146 public: |
147 static v8::Local<v8::Function> create(ScriptState* scriptState, Cache* cache
, const HeapVector<Member<Request>>& requests) | 147 static v8::Local<v8::Function> create(ScriptState* scriptState, Cache* cache
, const HeapVector<Member<Request>>& requests) |
148 { | 148 { |
(...skipping 23 matching lines...) Expand all Loading... |
172 , m_requests(requests) | 172 , m_requests(requests) |
173 { | 173 { |
174 } | 174 } |
175 | 175 |
176 Member<Cache> m_cache; | 176 Member<Cache> m_cache; |
177 HeapVector<Member<Request>> m_requests; | 177 HeapVector<Member<Request>> m_requests; |
178 }; | 178 }; |
179 | 179 |
180 class Cache::BarrierCallbackForPut final : public GarbageCollectedFinalized<Barr
ierCallbackForPut> { | 180 class Cache::BarrierCallbackForPut final : public GarbageCollectedFinalized<Barr
ierCallbackForPut> { |
181 public: | 181 public: |
182 BarrierCallbackForPut(int numberOfOperations, Cache* cache, PassRefPtrWillBe
RawPtr<ScriptPromiseResolver> resolver) | 182 BarrierCallbackForPut(int numberOfOperations, Cache* cache, ScriptPromiseRes
olver* resolver) |
183 : m_numberOfRemainingOperations(numberOfOperations) | 183 : m_numberOfRemainingOperations(numberOfOperations) |
184 , m_cache(cache) | 184 , m_cache(cache) |
185 , m_resolver(resolver) | 185 , m_resolver(resolver) |
186 { | 186 { |
187 ASSERT(0 < m_numberOfRemainingOperations); | 187 ASSERT(0 < m_numberOfRemainingOperations); |
188 m_batchOperations.resize(numberOfOperations); | 188 m_batchOperations.resize(numberOfOperations); |
189 } | 189 } |
190 | 190 |
191 void onSuccess(size_t index, const WebServiceWorkerCache::BatchOperation& ba
tchOperation) | 191 void onSuccess(size_t index, const WebServiceWorkerCache::BatchOperation& ba
tchOperation) |
192 { | 192 { |
(...skipping 19 matching lines...) Expand all Loading... |
212 DEFINE_INLINE_VIRTUAL_TRACE() | 212 DEFINE_INLINE_VIRTUAL_TRACE() |
213 { | 213 { |
214 visitor->trace(m_cache); | 214 visitor->trace(m_cache); |
215 visitor->trace(m_resolver); | 215 visitor->trace(m_resolver); |
216 } | 216 } |
217 | 217 |
218 private: | 218 private: |
219 bool m_completed = false; | 219 bool m_completed = false; |
220 int m_numberOfRemainingOperations; | 220 int m_numberOfRemainingOperations; |
221 Member<Cache> m_cache; | 221 Member<Cache> m_cache; |
222 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; | 222 Member<ScriptPromiseResolver> m_resolver; |
223 Vector<WebServiceWorkerCache::BatchOperation> m_batchOperations; | 223 Vector<WebServiceWorkerCache::BatchOperation> m_batchOperations; |
224 }; | 224 }; |
225 | 225 |
226 class Cache::BlobHandleCallbackForPut final : public GarbageCollectedFinalized<B
lobHandleCallbackForPut>, public FetchDataLoader::Client { | 226 class Cache::BlobHandleCallbackForPut final : public GarbageCollectedFinalized<B
lobHandleCallbackForPut>, public FetchDataLoader::Client { |
227 USING_GARBAGE_COLLECTED_MIXIN(BlobHandleCallbackForPut); | 227 USING_GARBAGE_COLLECTED_MIXIN(BlobHandleCallbackForPut); |
228 public: | 228 public: |
229 BlobHandleCallbackForPut(size_t index, BarrierCallbackForPut* barrierCallbac
k, Request* request, Response* response) | 229 BlobHandleCallbackForPut(size_t index, BarrierCallbackForPut* barrierCallbac
k, Request* request, Response* response) |
230 : m_index(index) | 230 : m_index(index) |
231 , m_barrierCallback(barrierCallback) | 231 , m_barrierCallback(barrierCallback) |
232 { | 232 { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 Cache::Cache(WeakPtr<GlobalFetch::ScopedFetcher> fetcher, WebServiceWorkerCache*
webCache) | 379 Cache::Cache(WeakPtr<GlobalFetch::ScopedFetcher> fetcher, WebServiceWorkerCache*
webCache) |
380 : m_scopedFetcher(fetcher) | 380 : m_scopedFetcher(fetcher) |
381 , m_webCache(adoptPtr(webCache)) { } | 381 , m_webCache(adoptPtr(webCache)) { } |
382 | 382 |
383 ScriptPromise Cache::matchImpl(ScriptState* scriptState, const Request* request,
const CacheQueryOptions& options) | 383 ScriptPromise Cache::matchImpl(ScriptState* scriptState, const Request* request,
const CacheQueryOptions& options) |
384 { | 384 { |
385 WebServiceWorkerRequest webRequest; | 385 WebServiceWorkerRequest webRequest; |
386 request->populateWebServiceWorkerRequest(webRequest); | 386 request->populateWebServiceWorkerRequest(webRequest); |
387 | 387 |
388 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 388 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
389 const ScriptPromise promise = resolver->promise(); | 389 const ScriptPromise promise = resolver->promise(); |
390 m_webCache->dispatchMatch(new CacheMatchCallbacks(resolver), webRequest, toW
ebQueryParams(options)); | 390 m_webCache->dispatchMatch(new CacheMatchCallbacks(resolver), webRequest, toW
ebQueryParams(options)); |
391 return promise; | 391 return promise; |
392 } | 392 } |
393 | 393 |
394 ScriptPromise Cache::matchAllImpl(ScriptState* scriptState) | 394 ScriptPromise Cache::matchAllImpl(ScriptState* scriptState) |
395 { | 395 { |
396 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 396 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
397 const ScriptPromise promise = resolver->promise(); | 397 const ScriptPromise promise = resolver->promise(); |
398 m_webCache->dispatchMatchAll(new CacheWithResponsesCallbacks(resolver), WebS
erviceWorkerRequest(), WebServiceWorkerCache::QueryParams()); | 398 m_webCache->dispatchMatchAll(new CacheWithResponsesCallbacks(resolver), WebS
erviceWorkerRequest(), WebServiceWorkerCache::QueryParams()); |
399 return promise; | 399 return promise; |
400 } | 400 } |
401 | 401 |
402 ScriptPromise Cache::matchAllImpl(ScriptState* scriptState, const Request* reque
st, const CacheQueryOptions& options) | 402 ScriptPromise Cache::matchAllImpl(ScriptState* scriptState, const Request* reque
st, const CacheQueryOptions& options) |
403 { | 403 { |
404 WebServiceWorkerRequest webRequest; | 404 WebServiceWorkerRequest webRequest; |
405 request->populateWebServiceWorkerRequest(webRequest); | 405 request->populateWebServiceWorkerRequest(webRequest); |
406 | 406 |
407 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 407 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
408 const ScriptPromise promise = resolver->promise(); | 408 const ScriptPromise promise = resolver->promise(); |
409 m_webCache->dispatchMatchAll(new CacheWithResponsesCallbacks(resolver), webR
equest, toWebQueryParams(options)); | 409 m_webCache->dispatchMatchAll(new CacheWithResponsesCallbacks(resolver), webR
equest, toWebQueryParams(options)); |
410 return promise; | 410 return promise; |
411 } | 411 } |
412 | 412 |
413 ScriptPromise Cache::addAllImpl(ScriptState* scriptState, const HeapVector<Membe
r<Request>>& requests, ExceptionState& exceptionState) | 413 ScriptPromise Cache::addAllImpl(ScriptState* scriptState, const HeapVector<Membe
r<Request>>& requests, ExceptionState& exceptionState) |
414 { | 414 { |
415 if (requests.isEmpty()) | 415 if (requests.isEmpty()) |
416 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 416 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
417 | 417 |
(...skipping 14 matching lines...) Expand all Loading... |
432 return ScriptPromise::all(scriptState, promises).then(FetchResolvedForAdd::c
reate(scriptState, this, requests)); | 432 return ScriptPromise::all(scriptState, promises).then(FetchResolvedForAdd::c
reate(scriptState, this, requests)); |
433 } | 433 } |
434 | 434 |
435 ScriptPromise Cache::deleteImpl(ScriptState* scriptState, const Request* request
, const CacheQueryOptions& options) | 435 ScriptPromise Cache::deleteImpl(ScriptState* scriptState, const Request* request
, const CacheQueryOptions& options) |
436 { | 436 { |
437 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); | 437 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); |
438 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypeDelet
e; | 438 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypeDelet
e; |
439 request->populateWebServiceWorkerRequest(batchOperations[0].request); | 439 request->populateWebServiceWorkerRequest(batchOperations[0].request); |
440 batchOperations[0].matchParams = toWebQueryParams(options); | 440 batchOperations[0].matchParams = toWebQueryParams(options); |
441 | 441 |
442 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 442 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
443 const ScriptPromise promise = resolver->promise(); | 443 const ScriptPromise promise = resolver->promise(); |
444 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations
); | 444 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations
); |
445 return promise; | 445 return promise; |
446 } | 446 } |
447 | 447 |
448 ScriptPromise Cache::putImpl(ScriptState* scriptState, const HeapVector<Member<R
equest>>& requests, const HeapVector<Member<Response>>& responses) | 448 ScriptPromise Cache::putImpl(ScriptState* scriptState, const HeapVector<Member<R
equest>>& requests, const HeapVector<Member<Response>>& responses) |
449 { | 449 { |
450 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 450 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
451 const ScriptPromise promise = resolver->promise(); | 451 const ScriptPromise promise = resolver->promise(); |
452 BarrierCallbackForPut* barrierCallback = new BarrierCallbackForPut(requests.
size(), this, resolver.get()); | 452 BarrierCallbackForPut* barrierCallback = new BarrierCallbackForPut(requests.
size(), this, resolver); |
453 | 453 |
454 for (size_t i = 0; i < requests.size(); ++i) { | 454 for (size_t i = 0; i < requests.size(); ++i) { |
455 KURL url(KURL(), requests[i]->url()); | 455 KURL url(KURL(), requests[i]->url()); |
456 if (!url.protocolIsInHTTPFamily()) { | 456 if (!url.protocolIsInHTTPFamily()) { |
457 barrierCallback->onError("Request scheme '" + url.protocol() + "' is
unsupported"); | 457 barrierCallback->onError("Request scheme '" + url.protocol() + "' is
unsupported"); |
458 return promise; | 458 return promise; |
459 } | 459 } |
460 if (requests[i]->method() != "GET") { | 460 if (requests[i]->method() != "GET") { |
461 barrierCallback->onError("Request method '" + requests[i]->method()
+ "' is unsupported"); | 461 barrierCallback->onError("Request method '" + requests[i]->method()
+ "' is unsupported"); |
462 return promise; | 462 return promise; |
(...skipping 26 matching lines...) Expand all Loading... |
489 requests[i]->populateWebServiceWorkerRequest(batchOperation.request); | 489 requests[i]->populateWebServiceWorkerRequest(batchOperation.request); |
490 responses[i]->populateWebServiceWorkerResponse(batchOperation.response); | 490 responses[i]->populateWebServiceWorkerResponse(batchOperation.response); |
491 barrierCallback->onSuccess(i, batchOperation); | 491 barrierCallback->onSuccess(i, batchOperation); |
492 } | 492 } |
493 | 493 |
494 return promise; | 494 return promise; |
495 } | 495 } |
496 | 496 |
497 ScriptPromise Cache::keysImpl(ScriptState* scriptState) | 497 ScriptPromise Cache::keysImpl(ScriptState* scriptState) |
498 { | 498 { |
499 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 499 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
500 const ScriptPromise promise = resolver->promise(); | 500 const ScriptPromise promise = resolver->promise(); |
501 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, WebSer
viceWorkerCache::QueryParams()); | 501 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, WebSer
viceWorkerCache::QueryParams()); |
502 return promise; | 502 return promise; |
503 } | 503 } |
504 | 504 |
505 ScriptPromise Cache::keysImpl(ScriptState* scriptState, const Request* request,
const CacheQueryOptions& options) | 505 ScriptPromise Cache::keysImpl(ScriptState* scriptState, const Request* request,
const CacheQueryOptions& options) |
506 { | 506 { |
507 WebServiceWorkerRequest webRequest; | 507 WebServiceWorkerRequest webRequest; |
508 request->populateWebServiceWorkerRequest(webRequest); | 508 request->populateWebServiceWorkerRequest(webRequest); |
509 | 509 |
510 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 510 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
511 const ScriptPromise promise = resolver->promise(); | 511 const ScriptPromise promise = resolver->promise(); |
512 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 512 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
513 return promise; | 513 return promise; |
514 } | 514 } |
515 | 515 |
516 WebServiceWorkerCache* Cache::webCache() const | 516 WebServiceWorkerCache* Cache::webCache() const |
517 { | 517 { |
518 return m_webCache.get(); | 518 return m_webCache.get(); |
519 } | 519 } |
520 | 520 |
521 } // namespace blink | 521 } // namespace blink |
OLD | NEW |