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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Response.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 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/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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 333
334 Headers* Response::headers() const 334 Headers* Response::headers() const
335 { 335 {
336 // "The headers attribute's getter must return the associated Headers object ." 336 // "The headers attribute's getter must return the associated Headers object ."
337 return m_headers; 337 return m_headers;
338 } 338 }
339 339
340 Response* Response::clone(ExceptionState& exceptionState) 340 Response* Response::clone(ExceptionState& exceptionState)
341 { 341 {
342 if (bodyUsed()) { 342 if (isBodyLocked() || bodyUsed()) {
343 exceptionState.throwTypeError("Response body is already used"); 343 exceptionState.throwTypeError("Response body is already used");
344 return nullptr; 344 return nullptr;
345 } 345 }
346 346
347 FetchResponseData* response = m_response->clone(executionContext()); 347 FetchResponseData* response = m_response->clone(executionContext());
348 Headers* headers = Headers::create(response->headerList()); 348 Headers* headers = Headers::create(response->headerList());
349 headers->setGuard(m_headers->guard()); 349 headers->setGuard(m_headers->guard());
350 return new Response(executionContext(), response, headers); 350 return new Response(executionContext(), response, headers);
351 } 351 }
352 352
(...skipping 30 matching lines...) Expand all
383 } 383 }
384 384
385 Response::Response(ExecutionContext* context, FetchResponseData* response, Heade rs* headers) 385 Response::Response(ExecutionContext* context, FetchResponseData* response, Heade rs* headers)
386 : Body(context) , m_response(response) , m_headers(headers) {} 386 : Body(context) , m_response(response) , m_headers(headers) {}
387 387
388 bool Response::hasBody() const 388 bool Response::hasBody() const
389 { 389 {
390 return m_response->internalBuffer(); 390 return m_response->internalBuffer();
391 } 391 }
392 392
393 bool Response::bodyUsed()
394 {
395 return internalBodyBuffer() && internalBodyBuffer()->stream()->isDisturbed() ;
396 }
397
393 String Response::mimeType() const 398 String Response::mimeType() const
394 { 399 {
395 return m_response->mimeType(); 400 return m_response->mimeType();
396 } 401 }
397 402
398 String Response::internalMIMEType() const 403 String Response::internalMIMEType() const
399 { 404 {
400 return m_response->internalMIMEType(); 405 return m_response->internalMIMEType();
401 } 406 }
402 407
403 DEFINE_TRACE(Response) 408 DEFINE_TRACE(Response)
404 { 409 {
405 Body::trace(visitor); 410 Body::trace(visitor);
406 visitor->trace(m_response); 411 visitor->trace(m_response);
407 visitor->trace(m_headers); 412 visitor->trace(m_headers);
408 } 413 }
409 414
410 } // namespace blink 415 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/Response.h ('k') | third_party/WebKit/Source/modules/fetch/Response.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698