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

Side by Side Diff: Source/modules/fetch/Response.cpp

Issue 1049983003: [Fetch] Body consume function should not set bodyUsed flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@stream-clone
Patch Set: Created 5 years, 8 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
« no previous file with comments | « Source/modules/fetch/Body.cpp ('k') | Source/modules/serviceworkers/Cache.cpp » ('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/fetch/Response.h" 6 #include "modules/fetch/Response.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/dom/DOMArrayBuffer.h" 10 #include "core/dom/DOMArrayBuffer.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // "The headers attribute's getter must return the associated Headers object ." 288 // "The headers attribute's getter must return the associated Headers object ."
289 return m_headers; 289 return m_headers;
290 } 290 }
291 291
292 Response* Response::clone(ExceptionState& exceptionState) 292 Response* Response::clone(ExceptionState& exceptionState)
293 { 293 {
294 if (bodyUsed()) { 294 if (bodyUsed()) {
295 exceptionState.throwTypeError("Response body is already used"); 295 exceptionState.throwTypeError("Response body is already used");
296 return nullptr; 296 return nullptr;
297 } 297 }
298 if (streamAccessed()) { 298 if (isBodyConsumed()) {
299 BodyStreamBuffer* drainingStream = createDrainingStream(); 299 BodyStreamBuffer* drainingStream = createDrainingStream();
300 m_response->replaceBodyStreamBuffer(drainingStream); 300 m_response->replaceBodyStreamBuffer(drainingStream);
301 } 301 }
302 // Lock the old body and set |body| property to the new one. 302 // Lock the old body and set |body| property to the new one.
303 lockBody(); 303 lockBody();
304 refreshBody(); 304 refreshBody();
305 305
306 FetchResponseData* response = m_response->clone(); 306 FetchResponseData* response = m_response->clone();
307 Headers* headers = Headers::create(response->headerList()); 307 Headers* headers = Headers::create(response->headerList());
308 headers->setGuard(m_headers->guard()); 308 headers->setGuard(m_headers->guard());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 DEFINE_TRACE(Response) 373 DEFINE_TRACE(Response)
374 { 374 {
375 Body::trace(visitor); 375 Body::trace(visitor);
376 visitor->trace(m_response); 376 visitor->trace(m_response);
377 visitor->trace(m_headers); 377 visitor->trace(m_headers);
378 } 378 }
379 379
380 } // namespace blink 380 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/fetch/Body.cpp ('k') | Source/modules/serviceworkers/Cache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698