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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 for (size_t i = 0; i < requests.size(); ++i) { | 488 for (size_t i = 0; i < requests.size(); ++i) { |
489 KURL url(KURL(), requests[i]->url()); | 489 KURL url(KURL(), requests[i]->url()); |
490 if (!url.protocolIsInHTTPFamily()) { | 490 if (!url.protocolIsInHTTPFamily()) { |
491 barrierCallback->onError("Request scheme '" + url.protocol() + "' is
unsupported"); | 491 barrierCallback->onError("Request scheme '" + url.protocol() + "' is
unsupported"); |
492 return promise; | 492 return promise; |
493 } | 493 } |
494 if (requests[i]->method() != "GET") { | 494 if (requests[i]->method() != "GET") { |
495 barrierCallback->onError("Request method '" + requests[i]->method()
+ "' is unsupported"); | 495 barrierCallback->onError("Request method '" + requests[i]->method()
+ "' is unsupported"); |
496 return promise; | 496 return promise; |
497 } | 497 } |
498 if (requests[i]->hasBody() && requests[i]->bodyUsed()) { | 498 ASSERT(!requests[i]->hasBody()); |
499 barrierCallback->onError("Request body is already used"); | 499 |
500 return promise; | 500 if (responses[i]->isBodyLocked() || responses[i]->bodyUsed()) { |
501 } | |
502 if (responses[i]->hasBody() && responses[i]->bodyUsed()) { | |
503 barrierCallback->onError("Response body is already used"); | 501 barrierCallback->onError("Response body is already used"); |
504 return promise; | 502 return promise; |
505 } | 503 } |
506 | 504 |
507 if (requests[i]->hasBody()) | |
508 requests[i]->setBodyPassed(); | |
509 if (responses[i]->hasBody()) | |
510 responses[i]->setBodyPassed(); | |
511 | |
512 BodyStreamBuffer* buffer = responses[i]->internalBodyBuffer(); | 505 BodyStreamBuffer* buffer = responses[i]->internalBodyBuffer(); |
513 if (buffer) { | 506 if (buffer) { |
514 // If the response has body, read the all data and create | 507 // If the response has body, read the all data and create |
515 // the blob handle and dispatch the put batch asynchronously. | 508 // the blob handle and dispatch the put batch asynchronously. |
516 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle(
responses[i]->internalMIMEType()); | 509 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle(
responses[i]->internalMIMEType()); |
517 buffer->startLoading(scriptState->executionContext(), loader, new Bl
obHandleCallbackForPut(i, barrierCallback, requests[i], responses[i])); | 510 buffer->startLoading(scriptState->executionContext(), loader, new Bl
obHandleCallbackForPut(i, barrierCallback, requests[i], responses[i])); |
518 continue; | 511 continue; |
519 } | 512 } |
520 | 513 |
521 WebServiceWorkerCache::BatchOperation batchOperation; | 514 WebServiceWorkerCache::BatchOperation batchOperation; |
(...skipping 25 matching lines...) Expand all Loading... |
547 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 540 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
548 return promise; | 541 return promise; |
549 } | 542 } |
550 | 543 |
551 WebServiceWorkerCache* Cache::webCache() const | 544 WebServiceWorkerCache* Cache::webCache() const |
552 { | 545 { |
553 return m_webCache.get(); | 546 return m_webCache.get(); |
554 } | 547 } |
555 | 548 |
556 } // namespace blink | 549 } // namespace blink |
OLD | NEW |