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

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

Powered by Google App Engine
This is Rietveld 408576698