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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // "The headers attribute's getter must return the associated Headers object
." | 294 // "The headers attribute's getter must return the associated Headers object
." |
295 return m_headers; | 295 return m_headers; |
296 } | 296 } |
297 | 297 |
298 Response* Response::clone(ExceptionState& exceptionState) | 298 Response* Response::clone(ExceptionState& exceptionState) |
299 { | 299 { |
300 if (bodyUsed()) { | 300 if (bodyUsed()) { |
301 exceptionState.throwTypeError("Response body is already used"); | 301 exceptionState.throwTypeError("Response body is already used"); |
302 return nullptr; | 302 return nullptr; |
303 } | 303 } |
304 // FIXME: We throw an error while cloning the Response which body was | |
305 // partially read. But in Request case, we don't. When the behavior of the | |
306 // partially read streams will be well defined in the spec, we have to | |
307 // implement the behavior correctly. | |
308 if (streamAccessed()) { | 304 if (streamAccessed()) { |
309 bool dataLost = false; | 305 BodyStreamBuffer* drainingStream = createDrainingStream(); |
310 BodyStreamBuffer* drainingStream = createDrainingStream(&dataLost); | |
311 if (dataLost) { | |
312 exceptionState.throwTypeError("Cloning the Response which body was p
artially read is not supported."); | |
313 return nullptr; | |
314 } | |
315 m_response->replaceBodyStreamBuffer(drainingStream); | 306 m_response->replaceBodyStreamBuffer(drainingStream); |
316 } | 307 } |
317 return Response::createClone(*this); | 308 return Response::createClone(*this); |
318 } | 309 } |
319 | 310 |
320 void Response::populateWebServiceWorkerResponse(WebServiceWorkerResponse& respon
se) | 311 void Response::populateWebServiceWorkerResponse(WebServiceWorkerResponse& respon
se) |
321 { | 312 { |
322 m_response->populateWebServiceWorkerResponse(response); | 313 m_response->populateWebServiceWorkerResponse(response); |
323 } | 314 } |
324 | 315 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 373 } |
383 | 374 |
384 DEFINE_TRACE(Response) | 375 DEFINE_TRACE(Response) |
385 { | 376 { |
386 Body::trace(visitor); | 377 Body::trace(visitor); |
387 visitor->trace(m_response); | 378 visitor->trace(m_response); |
388 visitor->trace(m_headers); | 379 visitor->trace(m_headers); |
389 } | 380 } |
390 | 381 |
391 } // namespace blink | 382 } // namespace blink |
OLD | NEW |