OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |