Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: Source/modules/cachestorage/Cache.cpp

Issue 1233573002: [Fetch API] Remove DrainingBuffer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/streams/UnderlyingSource.h ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/streams/UnderlyingSource.h ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698