| 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/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 331 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 332 const ScriptPromise promise = resolver->promise(); | 332 const ScriptPromise promise = resolver->promise(); |
| 333 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations
); | 333 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations
); |
| 334 return promise; | 334 return promise; |
| 335 } | 335 } |
| 336 | 336 |
| 337 ScriptPromise Cache::putImpl(ScriptState* scriptState, const Request* request, R
esponse* response) | 337 ScriptPromise Cache::putImpl(ScriptState* scriptState, const Request* request, R
esponse* response) |
| 338 { | 338 { |
| 339 KURL url(KURL(), request->url()); | 339 KURL url(KURL(), request->url()); |
| 340 if (!url.protocolIsInHTTPFamily()) | 340 if (!url.protocolIsInHTTPFamily()) |
| 341 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror("Request scheme '" + url.protocol() + "' is unsupported", scriptState->isola
te())); | 341 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Request scheme '" + url.protocol() + "' is unsuppor
ted")); |
| 342 if (request->method() != "GET") | 342 if (request->method() != "GET") |
| 343 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror("Request method '" + request->method() + "' is unsupported", scriptState->is
olate())); | 343 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Request method '" + request->method() + "' is unsup
ported")); |
| 344 | 344 |
| 345 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); | 345 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); |
| 346 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypePut; | 346 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypePut; |
| 347 request->populateWebServiceWorkerRequest(batchOperations[0].request); | 347 request->populateWebServiceWorkerRequest(batchOperations[0].request); |
| 348 response->populateWebServiceWorkerResponse(batchOperations[0].response); | 348 response->populateWebServiceWorkerResponse(batchOperations[0].response); |
| 349 | 349 |
| 350 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 350 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 351 const ScriptPromise promise = resolver->promise(); | 351 const ScriptPromise promise = resolver->promise(); |
| 352 m_webCache->dispatchBatch(new CacheAddOrPutCallbacks(resolver), batchOperati
ons); | 352 m_webCache->dispatchBatch(new CacheAddOrPutCallbacks(resolver), batchOperati
ons); |
| 353 return promise; | 353 return promise; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 366 WebServiceWorkerRequest webRequest; | 366 WebServiceWorkerRequest webRequest; |
| 367 request->populateWebServiceWorkerRequest(webRequest); | 367 request->populateWebServiceWorkerRequest(webRequest); |
| 368 | 368 |
| 369 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 369 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 370 const ScriptPromise promise = resolver->promise(); | 370 const ScriptPromise promise = resolver->promise(); |
| 371 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 371 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
| 372 return promise; | 372 return promise; |
| 373 } | 373 } |
| 374 | 374 |
| 375 } // namespace blink | 375 } // namespace blink |
| OLD | NEW |