Chromium Code Reviews| 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/serviceworkers/Cache.h" | 6 #include "modules/serviceworkers/Cache.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8ThrowException.h" | |
| 12 #include "core/dom/DOMException.h" | |
| 13 #include "modules/serviceworkers/Request.h" | |
| 14 #include "modules/serviceworkers/Response.h" | |
| 15 #include "public/platform/WebServiceWorkerCache.h" | |
| 10 | 16 |
| 11 namespace blink { | 17 namespace blink { |
| 12 | 18 |
| 13 namespace { | 19 namespace { |
| 14 | 20 |
| 21 WebServiceWorkerCache::QueryParams queryParamsFromDictionary(const Dictionary& d ictionary) | |
|
jsbell
2014/09/18 21:45:00
We can now use real Dictionary subclasses in modul
| |
| 22 { | |
| 23 WebServiceWorkerCache::QueryParams queryParams; | |
| 24 DictionaryHelper::get(dictionary, "ignoreSearch", queryParams.ignoreSearch); | |
| 25 DictionaryHelper::get(dictionary, "ignoreMethod", queryParams.ignoreMethod); | |
| 26 DictionaryHelper::get(dictionary, "ignoreVary", queryParams.ignoreVary); | |
| 27 DictionaryHelper::get(dictionary, "prefixMatch", queryParams.prefixMatch); | |
| 28 { | |
| 29 String cacheName; | |
| 30 DictionaryHelper::get(dictionary, "cacheName", cacheName); | |
| 31 queryParams.cacheName = cacheName; | |
| 32 } | |
| 33 return queryParams; | |
| 34 } | |
| 35 | |
| 36 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { | |
|
jsbell
2014/09/18 21:45:00
As noted in a FIXME over in CacheStorage.cpp we sh
| |
| 37 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); | |
| 38 public: | |
| 39 CacheMatchCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) | |
| 40 : m_resolver(resolver) { } | |
| 41 | |
| 42 virtual void onSuccess(WebServiceWorkerResponse* webResponse) OVERRIDE | |
| 43 { | |
| 44 m_resolver->resolve(Response::create(m_resolver->scriptState()->executio nContext(), *webResponse)); | |
| 45 m_resolver.clear(); | |
| 46 } | |
| 47 | |
| 48 virtual void onError(WebServiceWorkerCacheError* reason) OVERRIDE | |
| 49 { | |
| 50 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | |
| 51 m_resolver.clear(); | |
| 52 } | |
| 53 | |
| 54 private: | |
| 55 RefPtr<ScriptPromiseResolver> m_resolver; | |
| 56 }; | |
| 57 | |
| 58 class CacheWithResponsesCallbacks : public WebServiceWorkerCache::CacheWithRespo nsesCallbacks { | |
| 59 WTF_MAKE_NONCOPYABLE(CacheWithResponsesCallbacks); | |
| 60 public: | |
| 61 CacheWithResponsesCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) | |
| 62 : m_resolver(resolver) { } | |
| 63 | |
| 64 virtual void onSuccess(WebVector<WebServiceWorkerResponse>* webResponses) OV ERRIDE | |
| 65 { | |
| 66 Vector<Response*> responses; | |
| 67 for (size_t i = 0; i < webResponses->size(); ++i) | |
| 68 responses.append(Response::create(m_resolver->scriptState()->executi onContext(), (*webResponses)[i])); | |
| 69 m_resolver->resolve(responses); | |
| 70 m_resolver.clear(); | |
| 71 } | |
| 72 | |
| 73 virtual void onError(WebServiceWorkerCacheError* reason) OVERRIDE | |
| 74 { | |
| 75 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | |
| 76 m_resolver.clear(); | |
| 77 } | |
| 78 | |
| 79 private: | |
| 80 RefPtr<ScriptPromiseResolver> m_resolver; | |
| 81 }; | |
| 82 | |
| 83 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques tsCallbacks { | |
| 84 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); | |
| 85 public: | |
| 86 CacheWithRequestsCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) | |
| 87 : m_resolver(resolver) { } | |
| 88 | |
| 89 virtual void onSuccess(WebVector<WebServiceWorkerRequest>* webRequests) OVER RIDE | |
| 90 { | |
| 91 Vector<Request*> requests; | |
|
tkent
2014/09/18 23:35:55
This should be HeapVector<Member<Request>>.
gavinp
2014/09/22 16:05:24
Done. What about Vector<Response*> above?
jsbell
2014/09/22 16:42:50
Might as well be consistent. :)
Oilpan protects o
jsbell
2014/09/22 16:45:34
And http://www.chromium.org/blink/blink-gc require
tkent
2014/09/23 23:56:25
Right. We should use HeapVector<Member<Response>>
| |
| 92 for (size_t i = 0; i < webRequests->size(); ++i) | |
| 93 requests.append(Request::create(m_resolver->scriptState()->execution Context(), (*webRequests)[i])); | |
| 94 m_resolver->resolve(requests); | |
| 95 m_resolver.clear(); | |
| 96 } | |
| 97 | |
| 98 virtual void onError(WebServiceWorkerCacheError* reason) OVERRIDE | |
| 99 { | |
| 100 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | |
| 101 m_resolver.clear(); | |
| 102 } | |
| 103 | |
| 104 private: | |
| 105 RefPtr<ScriptPromiseResolver> m_resolver; | |
| 106 }; | |
| 107 | |
| 108 ScriptPromise rejectForCacheError(ScriptState* scriptState, WebServiceWorkerCach eError error) | |
| 109 { | |
| 110 return ScriptPromise::rejectWithDOMException(scriptState, Cache::domExceptio nForCacheError(error)); | |
| 111 } | |
| 112 | |
| 15 ScriptPromise rejectAsNotImplemented(ScriptState* scriptState) | 113 ScriptPromise rejectAsNotImplemented(ScriptState* scriptState) |
| 16 { | 114 { |
| 115 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError, "Cache is not implemented")); | |
| 116 } | |
| 117 | |
| 118 } // namespace | |
| 119 | |
| 120 Cache* Cache::fromWebServiceWorkerCache(WebServiceWorkerCache* webCache) | |
| 121 { | |
| 122 if (Cache* cache = static_cast<Cache*>(webCache->proxyInterface())) | |
| 123 return cache; | |
| 124 return new Cache(webCache); | |
| 125 } | |
| 126 | |
| 127 ScriptPromise Cache::match(ScriptState* scriptState, Request* originalRequest, c onst Dictionary& queryParamsDict) | |
| 128 { | |
| 129 TrackExceptionState exceptionState; | |
| 130 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 131 if (exceptionState.hadException()) { | |
| 132 // FIXME: We should throw the caught error. | |
| 133 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 134 } | |
| 135 return matchImpl(scriptState, request, queryParamsDict); | |
| 136 } | |
| 137 | |
| 138 ScriptPromise Cache::match(ScriptState* scriptState, const String& requestString , const Dictionary& queryParamsDict) | |
| 139 { | |
| 140 TrackExceptionState exceptionState; | |
| 141 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 142 if (exceptionState.hadException()) { | |
| 143 // FIXME: We should throw the caught error. | |
| 144 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 145 } | |
| 146 return matchImpl(scriptState, request, queryParamsDict); | |
| 147 } | |
| 148 | |
| 149 ScriptPromise Cache::matchAll(ScriptState* scriptState, Request* originalRequest , const Dictionary& queryParamsDict) | |
| 150 { | |
| 151 TrackExceptionState exceptionState; | |
| 152 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 153 if (exceptionState.hadException()) { | |
| 154 // FIXME: We should throw the caught error. | |
| 155 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 156 } | |
| 157 return matchAllImpl(scriptState, request, queryParamsDict); | |
| 158 } | |
| 159 | |
| 160 ScriptPromise Cache::matchAll(ScriptState* scriptState, const String& requestStr ing, const Dictionary& queryParamsDict) | |
| 161 { | |
| 162 TrackExceptionState exceptionState; | |
| 163 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 164 if (exceptionState.hadException()) { | |
| 165 // FIXME: We should throw the caught error. | |
| 166 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 167 } | |
| 168 return matchAllImpl(scriptState, request, queryParamsDict); | |
| 169 } | |
| 170 | |
| 171 ScriptPromise Cache::add(ScriptState* scriptState, Request* originalRequest) | |
| 172 { | |
| 173 TrackExceptionState exceptionState; | |
| 174 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 175 if (exceptionState.hadException()) { | |
| 176 // FIXME: We should throw the caught error. | |
| 177 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 178 } | |
| 179 return addImpl(scriptState, request); | |
| 180 } | |
| 181 | |
| 182 ScriptPromise Cache::add(ScriptState* scriptState, const String& requestString) | |
| 183 { | |
| 184 TrackExceptionState exceptionState; | |
| 185 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 186 if (exceptionState.hadException()) { | |
| 187 // FIXME: We should throw the caught error. | |
| 188 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 189 } | |
| 190 return addImpl(scriptState, request); | |
| 191 } | |
| 192 | |
| 193 ScriptPromise Cache::addAll(ScriptState* scriptState, const Vector<ScriptValue>& rawRequests) | |
| 194 { | |
| 195 // FIXME: Implement this. | |
| 196 return rejectAsNotImplemented(scriptState); | |
| 197 } | |
| 198 | |
| 199 ScriptPromise Cache::deleteFunction(ScriptState* scriptState, Request* originalR equest, const Dictionary& queryParamsDict) | |
| 200 { | |
| 201 TrackExceptionState exceptionState; | |
| 202 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 203 if (exceptionState.hadException()) { | |
| 204 // FIXME: We should throw the caught error. | |
| 205 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 206 } | |
| 207 return deleteImpl(scriptState, request, queryParamsDict); | |
| 208 } | |
| 209 | |
| 210 ScriptPromise Cache::deleteFunction(ScriptState* scriptState, const String& requ estString, const Dictionary& queryParamsDict) | |
| 211 { | |
| 212 TrackExceptionState exceptionState; | |
| 213 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 214 if (exceptionState.hadException()) { | |
| 215 // FIXME: We should throw the caught error. | |
| 216 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 217 } | |
| 218 return deleteImpl(scriptState, request, queryParamsDict); | |
| 219 } | |
| 220 | |
| 221 ScriptPromise Cache::put(ScriptState* scriptState, Request* originalRequest, con st Response* response) | |
| 222 { | |
| 223 TrackExceptionState exceptionState; | |
| 224 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 225 if (exceptionState.hadException()) { | |
| 226 // FIXME: We should throw the caught error. | |
| 227 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 228 } | |
| 229 return putImpl(scriptState, request, response); | |
| 230 } | |
| 231 | |
| 232 ScriptPromise Cache::put(ScriptState* scriptState, const String& requestString, const Response* response) | |
| 233 { | |
| 234 TrackExceptionState exceptionState; | |
| 235 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 236 if (exceptionState.hadException()) { | |
| 237 // FIXME: We should throw the caught error. | |
| 238 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 239 } | |
| 240 return putImpl(scriptState, request, response); | |
| 241 } | |
| 242 | |
| 243 ScriptPromise Cache::keys(ScriptState* scriptState) | |
| 244 { | |
| 245 return keysImpl(scriptState); | |
| 246 } | |
| 247 | |
| 248 ScriptPromise Cache::keys(ScriptState* scriptState, Request* originalRequest, co nst Dictionary& queryParamsDict) | |
| 249 { | |
| 250 TrackExceptionState exceptionState; | |
| 251 Request* request = Request::create(scriptState->executionContext(), original Request, exceptionState); | |
| 252 if (exceptionState.hadException()) { | |
| 253 // FIXME: We should throw the caught error. | |
| 254 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 255 } | |
| 256 return keysImpl(scriptState, request, queryParamsDict); | |
| 257 } | |
| 258 | |
| 259 ScriptPromise Cache::keys(ScriptState* scriptState, const String& requestString, const Dictionary& queryParamsDict) | |
| 260 { | |
| 261 TrackExceptionState exceptionState; | |
| 262 Request* request = Request::create(scriptState->executionContext(), requestS tring, exceptionState); | |
| 263 if (exceptionState.hadException()) { | |
| 264 // FIXME: We should throw the caught error. | |
| 265 return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFou nd); | |
| 266 } | |
| 267 return keysImpl(scriptState, request, queryParamsDict); | |
| 268 } | |
| 269 | |
| 270 Cache::Cache(WebServiceWorkerCache* webCache) | |
| 271 : m_webCache(adoptPtr(webCache)) | |
| 272 { | |
| 273 ASSERT(!m_webCache->proxyInterface()); | |
| 274 m_webCache->setProxyInterface(this); | |
| 275 } | |
| 276 | |
| 277 Cache* Cache::create(WebServiceWorkerCache* webCache) | |
| 278 { | |
| 279 return new Cache(webCache); | |
| 280 } | |
| 281 | |
| 282 ScriptPromise Cache::matchImpl(ScriptState* scriptState, Request* request, const Dictionary& queryParamsDict) | |
| 283 { | |
| 284 WebServiceWorkerRequest webRequest; | |
| 285 request->populateWebServiceWorkerRequest(webRequest); | |
| 286 | |
| 17 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | 287 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
| 18 const ScriptPromise promise = resolver->promise(); | 288 const ScriptPromise promise = resolver->promise(); |
| 19 resolver->reject(DOMException::create(NotSupportedError, "Cache is not imple mented")); | 289 m_webCache->dispatchMatch(new CacheMatchCallbacks(resolver), webRequest, que ryParamsFromDictionary(queryParamsDict)); |
| 20 return promise; | 290 return promise; |
| 21 } | 291 } |
| 22 | 292 |
| 23 } | 293 ScriptPromise Cache::matchAllImpl(ScriptState* scriptState, Request* request, co nst Dictionary& queryParamsDict) |
| 24 | 294 { |
| 25 Cache* Cache::fromWebServiceWorkerCache(WebServiceWorkerCache* webCache) | 295 WebServiceWorkerRequest webRequest; |
| 26 { | 296 request->populateWebServiceWorkerRequest(webRequest); |
| 27 return new Cache(webCache); | 297 |
| 28 } | 298 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); |
| 29 | 299 const ScriptPromise promise = resolver->promise(); |
| 30 // FIXME: Implement these methods. | 300 m_webCache->dispatchMatchAll(new CacheWithResponsesCallbacks(resolver), webR equest, queryParamsFromDictionary(queryParamsDict)); |
| 31 ScriptPromise Cache::match(ScriptState* scriptState, Request* request, const Dic tionary& queryParams) | 301 return promise; |
| 32 { | 302 } |
| 303 | |
| 304 ScriptPromise Cache::addImpl(ScriptState* scriptState, Request*) | |
| 305 { | |
| 306 // FIXME: Implement this. | |
| 33 return rejectAsNotImplemented(scriptState); | 307 return rejectAsNotImplemented(scriptState); |
| 34 } | 308 } |
| 35 | 309 |
| 36 ScriptPromise Cache::match(ScriptState* scriptState, const String& requestString , const Dictionary& queryParams) | 310 ScriptPromise Cache::addAllImpl(ScriptState* scriptState, Vector<Request*>) |
| 37 { | 311 { |
| 312 // FIXME: Implement this. | |
| 38 return rejectAsNotImplemented(scriptState); | 313 return rejectAsNotImplemented(scriptState); |
| 39 } | 314 } |
| 40 | 315 |
| 41 ScriptPromise Cache::matchAll(ScriptState* scriptState, Request* request, const Dictionary& queryParams) | |
| 42 { | |
| 43 return rejectAsNotImplemented(scriptState); | |
| 44 } | |
| 45 | |
| 46 ScriptPromise Cache::matchAll(ScriptState* scriptState, const String& requestStr ing, const Dictionary& queryParams) | |
| 47 { | |
| 48 return rejectAsNotImplemented(scriptState); | |
| 49 } | |
| 50 | |
| 51 ScriptPromise Cache::add(ScriptState* scriptState, Request* request) | |
| 52 { | |
| 53 return rejectAsNotImplemented(scriptState); | |
| 54 } | |
| 55 | |
| 56 ScriptPromise Cache::add(ScriptState* scriptState, const String& requestString) | |
| 57 { | |
| 58 return rejectAsNotImplemented(scriptState); | |
| 59 } | |
| 60 | |
| 61 ScriptPromise Cache::addAll(ScriptState* scriptState, const Vector<ScriptValue>& rawRequests) | |
| 62 { | |
| 63 return rejectAsNotImplemented(scriptState); | |
| 64 } | |
| 65 | |
| 66 ScriptPromise Cache::deleteFunction(ScriptState* scriptState, Request* request, const Dictionary& queryParams) | |
| 67 { | |
| 68 return rejectAsNotImplemented(scriptState); | |
| 69 } | |
| 70 | |
| 71 ScriptPromise Cache::deleteFunction(ScriptState* scriptState, const String& requ estString, const Dictionary& queryParams) | |
| 72 { | |
| 73 return rejectAsNotImplemented(scriptState); | |
| 74 } | |
| 75 | |
| 76 ScriptPromise Cache::put(ScriptState* scriptState, Request* request, Response*) | |
| 77 { | |
| 78 return rejectAsNotImplemented(scriptState); | |
| 79 } | |
| 80 | |
| 81 ScriptPromise Cache::put(ScriptState* scriptState, const String& requestString, Response*) | |
| 82 { | |
| 83 return rejectAsNotImplemented(scriptState); | |
| 84 } | |
| 85 | |
| 86 ScriptPromise Cache::keys(ScriptState* scriptState) | |
| 87 { | |
| 88 return rejectAsNotImplemented(scriptState); | |
| 89 } | |
| 90 | |
| 91 ScriptPromise Cache::keys(ScriptState* scriptState, Request* request, const Dict ionary& queryParams) | |
| 92 { | |
| 93 return rejectAsNotImplemented(scriptState); | |
| 94 } | |
| 95 | |
| 96 ScriptPromise Cache::keys(ScriptState* scriptState, const String& requestString, const Dictionary& queryParams) | |
| 97 { | |
| 98 return rejectAsNotImplemented(scriptState); | |
| 99 } | |
| 100 | |
| 101 PassRefPtrWillBeRawPtr<DOMException> Cache::domExceptionForCacheError(WebService WorkerCacheError reason) | 316 PassRefPtrWillBeRawPtr<DOMException> Cache::domExceptionForCacheError(WebService WorkerCacheError reason) |
| 102 { | 317 { |
| 103 switch (reason) { | 318 switch (reason) { |
| 104 case WebServiceWorkerCacheErrorNotImplemented: | 319 case WebServiceWorkerCacheErrorNotImplemented: |
| 105 return DOMException::create(NotSupportedError, "Method is not implemente d."); | 320 return DOMException::create(NotSupportedError, "Method is not implemente d."); |
| 106 case WebServiceWorkerCacheErrorNotFound: | 321 case WebServiceWorkerCacheErrorNotFound: |
| 107 return DOMException::create(NotFoundError, "Entry was not found."); | 322 return DOMException::create(NotFoundError, "Entry was not found."); |
| 108 case WebServiceWorkerCacheErrorExists: | 323 case WebServiceWorkerCacheErrorExists: |
| 109 return DOMException::create(InvalidAccessError, "Entry already exists.") ; | 324 return DOMException::create(InvalidAccessError, "Entry already exists.") ; |
| 110 default: | 325 default: |
| 111 ASSERT_NOT_REACHED(); | 326 ASSERT_NOT_REACHED(); |
| 112 return DOMException::create(NotSupportedError, "Unknown error."); | 327 return DOMException::create(NotSupportedError, "Unknown error."); |
| 113 } | 328 } |
| 114 } | 329 } |
| 115 | 330 |
| 116 Cache::Cache(WebServiceWorkerCache* webCache) : m_webCache(webCache) | 331 ScriptPromise Cache::deleteImpl(ScriptState* scriptState, Request* request, cons t Dictionary& queryParamsDict) |
| 117 { | 332 { |
| 333 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); | |
| 334 batchOperations[0].operationType = WebServiceWorkerCache::WebServiceWorkerCa cheOperationTypeDelete; | |
| 335 request->populateWebServiceWorkerRequest(batchOperations[0].request); | |
| 336 batchOperations[0].matchParams = queryParamsFromDictionary(queryParamsDict); | |
| 337 | |
| 338 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | |
| 339 const ScriptPromise promise = resolver->promise(); | |
| 340 m_webCache->dispatchBatch(new CacheWithResponsesCallbacks(resolver), batchOp erations); | |
| 341 return promise; | |
| 342 } | |
| 343 | |
| 344 ScriptPromise Cache::putImpl(ScriptState* scriptState, Request* request, const R esponse* response) | |
| 345 { | |
| 346 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); | |
| 347 batchOperations[0].operationType = WebServiceWorkerCache::WebServiceWorkerCa cheOperationTypePut; | |
| 348 request->populateWebServiceWorkerRequest(batchOperations[0].request); | |
| 349 response->populateWebServiceWorkerResponse(batchOperations[0].response); | |
| 350 | |
| 351 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | |
| 352 const ScriptPromise promise = resolver->promise(); | |
| 353 m_webCache->dispatchBatch(new CacheWithResponsesCallbacks(resolver), batchOp erations); | |
| 354 return promise; | |
| 355 } | |
| 356 | |
| 357 ScriptPromise Cache::keysImpl(ScriptState* scriptState) | |
| 358 { | |
| 359 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | |
| 360 const ScriptPromise promise = resolver->promise(); | |
| 361 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, WebSer viceWorkerCache::QueryParams()); | |
| 362 return promise; | |
| 363 } | |
| 364 | |
| 365 ScriptPromise Cache::keysImpl(ScriptState* scriptState, Request* request, const Dictionary& queryParamsDict) | |
| 366 { | |
| 367 WebServiceWorkerRequest webRequest; | |
| 368 request->populateWebServiceWorkerRequest(webRequest); | |
| 369 | |
| 370 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); | |
| 371 const ScriptPromise promise = resolver->promise(); | |
| 372 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, queryP aramsFromDictionary(queryParamsDict)); | |
| 373 return promise; | |
| 118 } | 374 } |
| 119 | 375 |
| 120 } // namespace blink | 376 } // namespace blink |
| OLD | NEW |