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

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

Issue 1418813004: [Fetch API] Reflect spec changes of bodyUsed property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We don't read |request[i]|'s body, so we don't check its
499 barrierCallback->onError("Request body is already used"); 499 // availability.
hiroshige 2015/11/19 12:50:36 The spec says we must not check the request's body
yhirano 2015/11/19 13:19:03 Done.
yhirano 2015/11/19 14:17:15 Actually, a Request having 'GET' method must not h
500 return promise; 500
501 } 501 if (responses[i]->bodyUsed() || responses[i]->isBodyLocked()) {
502 if (responses[i]->hasBody() && responses[i]->bodyUsed()) {
503 barrierCallback->onError("Response body is already used"); 502 barrierCallback->onError("Response body is already used");
504 return promise; 503 return promise;
505 } 504 }
506 505
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(); 506 BodyStreamBuffer* buffer = responses[i]->internalBodyBuffer();
513 if (buffer) { 507 if (buffer) {
514 // If the response has body, read the all data and create 508 // If the response has body, read the all data and create
515 // the blob handle and dispatch the put batch asynchronously. 509 // the blob handle and dispatch the put batch asynchronously.
516 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle( responses[i]->internalMIMEType()); 510 FetchDataLoader* loader = FetchDataLoader::createLoaderAsBlobHandle( responses[i]->internalMIMEType());
517 buffer->startLoading(scriptState->executionContext(), loader, new Bl obHandleCallbackForPut(i, barrierCallback, requests[i], responses[i])); 511 buffer->startLoading(scriptState->executionContext(), loader, new Bl obHandleCallbackForPut(i, barrierCallback, requests[i], responses[i]));
518 continue; 512 continue;
519 } 513 }
520 514
521 WebServiceWorkerCache::BatchOperation batchOperation; 515 WebServiceWorkerCache::BatchOperation batchOperation;
(...skipping 25 matching lines...) Expand all
547 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ ueryParams(options)); 541 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ ueryParams(options));
548 return promise; 542 return promise;
549 } 543 }
550 544
551 WebServiceWorkerCache* Cache::webCache() const 545 WebServiceWorkerCache* Cache::webCache() const
552 { 546 {
553 return m_webCache.get(); 547 return m_webCache.get();
554 } 548 }
555 549
556 } // namespace blink 550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698