| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (requests[i]->hasBody() && requests[i]->bodyUsed()) { | 550 if (requests[i]->hasBody() && requests[i]->bodyUsed()) { |
| 551 barrierCallback->onError("Request body is already used"); | 551 barrierCallback->onError("Request body is already used"); |
| 552 return promise; | 552 return promise; |
| 553 } | 553 } |
| 554 if (responses[i]->hasBody() && responses[i]->bodyUsed()) { | 554 if (responses[i]->hasBody() && responses[i]->bodyUsed()) { |
| 555 barrierCallback->onError("Response body is already used"); | 555 barrierCallback->onError("Response body is already used"); |
| 556 return promise; | 556 return promise; |
| 557 } | 557 } |
| 558 | 558 |
| 559 if (requests[i]->hasBody()) | 559 if (requests[i]->hasBody()) |
| 560 requests[i]->lockBody(Body::PassBody); | 560 requests[i]->setBodyPassed(); |
| 561 if (responses[i]->hasBody()) | 561 if (responses[i]->hasBody()) |
| 562 responses[i]->lockBody(Body::PassBody); | 562 responses[i]->setBodyPassed(); |
| 563 | 563 |
| 564 if (OwnPtr<DrainingBodyStreamBuffer> buffer = responses[i]->createIntern
alDrainingStream()) { | 564 BodyStreamBuffer* buffer = responses[i]->internalBodyBuffer(); |
| 565 if (buffer->hasBody()) { |
| 565 // If the response has body, read the all data and create | 566 // If the response has body, read the all data and create |
| 566 // the blob handle and dispatch the put batch asynchronously. | 567 // the blob handle and dispatch the put batch asynchronously. |
| 567 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle(
responses[i]->internalMIMEType()); | 568 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle(
responses[i]->internalMIMEType()); |
| 568 buffer->startLoading(loader, new BlobHandleCallbackForPut(i, barrier
Callback, requests[i], responses[i])); | 569 buffer->startLoading(scriptState->executionContext(), loader, new Bl
obHandleCallbackForPut(i, barrierCallback, requests[i], responses[i])); |
| 569 continue; | 570 continue; |
| 570 } | 571 } |
| 571 | 572 |
| 572 WebServiceWorkerCache::BatchOperation batchOperation; | 573 WebServiceWorkerCache::BatchOperation batchOperation; |
| 573 batchOperation.operationType = WebServiceWorkerCache::OperationTypePut; | 574 batchOperation.operationType = WebServiceWorkerCache::OperationTypePut; |
| 574 requests[i]->populateWebServiceWorkerRequest(batchOperation.request); | 575 requests[i]->populateWebServiceWorkerRequest(batchOperation.request); |
| 575 responses[i]->populateWebServiceWorkerResponse(batchOperation.response); | 576 responses[i]->populateWebServiceWorkerResponse(batchOperation.response); |
| 576 barrierCallback->onSuccess(i, batchOperation); | 577 barrierCallback->onSuccess(i, batchOperation); |
| 577 } | 578 } |
| 578 | 579 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 597 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 598 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
| 598 return promise; | 599 return promise; |
| 599 } | 600 } |
| 600 | 601 |
| 601 WebServiceWorkerCache* Cache::webCache() const | 602 WebServiceWorkerCache* Cache::webCache() const |
| 602 { | 603 { |
| 603 return m_webCache.get(); | 604 return m_webCache.get(); |
| 604 } | 605 } |
| 605 | 606 |
| 606 } // namespace blink | 607 } // namespace blink |
| OLD | NEW |