OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 m_responseDocument->setContextFeatures(document()->contextFeatures()
); | 253 m_responseDocument->setContextFeatures(document()->contextFeatures()
); |
254 if (!m_responseDocument->wellFormed()) | 254 if (!m_responseDocument->wellFormed()) |
255 m_responseDocument = 0; | 255 m_responseDocument = 0; |
256 } | 256 } |
257 m_createdDocument = true; | 257 m_createdDocument = true; |
258 } | 258 } |
259 | 259 |
260 return m_responseDocument.get(); | 260 return m_responseDocument.get(); |
261 } | 261 } |
262 | 262 |
263 Blob* XMLHttpRequest::responseBlob(ExceptionState& es) | 263 Blob* XMLHttpRequest::responseBlob() |
264 { | 264 { |
265 if (m_responseTypeCode != ResponseTypeBlob) { | 265 ASSERT(m_responseTypeCode == ResponseTypeBlob); |
266 es.throwDOMException(InvalidStateError); | 266 |
267 return 0; | |
268 } | |
269 // We always return null before DONE. | 267 // We always return null before DONE. |
270 if (m_error || m_state != DONE) | 268 if (m_error || m_state != DONE) |
271 return 0; | 269 return 0; |
272 | 270 |
273 if (!m_responseBlob) { | 271 if (!m_responseBlob) { |
274 // FIXME: This causes two (or more) unnecessary copies of the data. | 272 // FIXME: This causes two (or more) unnecessary copies of the data. |
275 // Chromium stores blob data in the browser process, so we're pulling th
e data | 273 // Chromium stores blob data in the browser process, so we're pulling th
e data |
276 // from the network only to copy it into the renderer to copy it back to
the browser. | 274 // from the network only to copy it into the renderer to copy it back to
the browser. |
277 // Ideally we'd get the blob/file-handle from the ResourceResponse direc
tly | 275 // Ideally we'd get the blob/file-handle from the ResourceResponse direc
tly |
278 // instead of copying the bytes. Embedders who store blob data in the | 276 // instead of copying the bytes. Embedders who store blob data in the |
279 // same process as WebCore would at least to teach BlobData to take | 277 // same process as WebCore would at least to teach BlobData to take |
280 // a SharedBuffer, even if they don't get the Blob from the network laye
r directly. | 278 // a SharedBuffer, even if they don't get the Blob from the network laye
r directly. |
281 OwnPtr<BlobData> blobData = BlobData::create(); | 279 OwnPtr<BlobData> blobData = BlobData::create(); |
282 // If we errored out or got no data, we still return a blob, just an emp
ty one. | 280 // If we errored out or got no data, we still return a blob, just an emp
ty one. |
283 size_t size = 0; | 281 size_t size = 0; |
284 if (m_binaryResponseBuilder) { | 282 if (m_binaryResponseBuilder) { |
285 RefPtr<RawData> rawData = RawData::create(); | 283 RefPtr<RawData> rawData = RawData::create(); |
286 size = m_binaryResponseBuilder->size(); | 284 size = m_binaryResponseBuilder->size(); |
287 rawData->mutableData()->append(m_binaryResponseBuilder->data(), size
); | 285 rawData->mutableData()->append(m_binaryResponseBuilder->data(), size
); |
288 blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile); | 286 blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile); |
289 blobData->setContentType(responseMIMEType()); // responseMIMEType de
faults to text/xml which may be incorrect. | 287 blobData->setContentType(responseMIMEType()); // responseMIMEType de
faults to text/xml which may be incorrect. |
290 m_binaryResponseBuilder.clear(); | 288 m_binaryResponseBuilder.clear(); |
291 } | 289 } |
292 m_responseBlob = Blob::create(blobData.release(), size); | 290 m_responseBlob = Blob::create(blobData.release(), size); |
293 } | 291 } |
294 | 292 |
295 return m_responseBlob.get(); | 293 return m_responseBlob.get(); |
296 } | 294 } |
297 | 295 |
298 ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionState& es) | 296 ArrayBuffer* XMLHttpRequest::responseArrayBuffer() |
299 { | 297 { |
300 if (m_responseTypeCode != ResponseTypeArrayBuffer) { | 298 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer); |
301 es.throwDOMException(InvalidStateError); | |
302 return 0; | |
303 } | |
304 | 299 |
305 if (m_error || m_state != DONE) | 300 if (m_error || m_state != DONE) |
306 return 0; | 301 return 0; |
307 | 302 |
308 if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binar
yResponseBuilder->size() > 0) { | 303 if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binar
yResponseBuilder->size() > 0) { |
309 m_responseArrayBuffer = m_binaryResponseBuilder->getAsArrayBuffer(); | 304 m_responseArrayBuffer = m_binaryResponseBuilder->getAsArrayBuffer(); |
310 m_binaryResponseBuilder.clear(); | 305 m_binaryResponseBuilder.clear(); |
311 } | 306 } |
312 | 307 |
313 return m_responseArrayBuffer.get(); | 308 return m_responseArrayBuffer.get(); |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 { | 1245 { |
1251 return &m_eventTargetData; | 1246 return &m_eventTargetData; |
1252 } | 1247 } |
1253 | 1248 |
1254 EventTargetData* XMLHttpRequest::ensureEventTargetData() | 1249 EventTargetData* XMLHttpRequest::ensureEventTargetData() |
1255 { | 1250 { |
1256 return &m_eventTargetData; | 1251 return &m_eventTargetData; |
1257 } | 1252 } |
1258 | 1253 |
1259 } // namespace WebCore | 1254 } // namespace WebCore |
OLD | NEW |