Chromium Code Reviews| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 return m_response.url().string(); | 435 return m_response.url().string(); |
| 436 } | 436 } |
| 437 | 437 |
| 438 XMLHttpRequestUpload* XMLHttpRequest::upload() | 438 XMLHttpRequestUpload* XMLHttpRequest::upload() |
| 439 { | 439 { |
| 440 if (!m_upload) | 440 if (!m_upload) |
| 441 m_upload = XMLHttpRequestUpload::create(this); | 441 m_upload = XMLHttpRequestUpload::create(this); |
| 442 return m_upload.get(); | 442 return m_upload.get(); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void XMLHttpRequest::trackProgress(int length) | 445 void XMLHttpRequest::trackProgress(long long length) |
|
tkent
2014/10/01 03:16:49
Why |long long|?
tyoshino (SeeGerritForStatus)
2014/10/01 03:36:09
The argument of didDownloadData() is still "int".
| |
| 446 { | 446 { |
| 447 m_receivedLength += length; | 447 m_receivedLength += length; |
| 448 | 448 |
| 449 if (m_state != LOADING) { | 449 if (m_state != LOADING) { |
| 450 changeState(LOADING); | 450 changeState(LOADING); |
| 451 } else { | 451 } else { |
| 452 // Dispatch a readystatechange event because many applications use | 452 // Dispatch a readystatechange event because many applications use |
| 453 // it to track progress although this is not specified. | 453 // it to track progress although this is not specified. |
| 454 // | 454 // |
| 455 // FIXME: Stop dispatching this event for progress tracking. | 455 // FIXME: Stop dispatching this event for progress tracking. |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 m_response = response; | 1385 m_response = response; |
| 1386 if (!m_mimeTypeOverride.isEmpty()) { | 1386 if (!m_mimeTypeOverride.isEmpty()) { |
| 1387 m_response.setHTTPHeaderField("Content-Type", m_mimeTypeOverride); | 1387 m_response.setHTTPHeaderField("Content-Type", m_mimeTypeOverride); |
| 1388 m_finalResponseCharset = extractCharsetFromMediaType(m_mimeTypeOverride) ; | 1388 m_finalResponseCharset = extractCharsetFromMediaType(m_mimeTypeOverride) ; |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 if (m_finalResponseCharset.isEmpty()) | 1391 if (m_finalResponseCharset.isEmpty()) |
| 1392 m_finalResponseCharset = response.textEncodingName(); | 1392 m_finalResponseCharset = response.textEncodingName(); |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 void XMLHttpRequest::parseDocumentChunk(const char* data, int len) | 1395 void XMLHttpRequest::parseDocumentChunk(const char* data, unsigned len) |
| 1396 { | 1396 { |
| 1397 if (!m_responseDocumentParser) { | 1397 if (!m_responseDocumentParser) { |
| 1398 ASSERT(!m_responseDocument); | 1398 ASSERT(!m_responseDocument); |
| 1399 initResponseDocument(); | 1399 initResponseDocument(); |
| 1400 if (!m_responseDocument) | 1400 if (!m_responseDocument) |
| 1401 return; | 1401 return; |
| 1402 | 1402 |
| 1403 m_responseDocumentParser = m_responseDocument->implicitOpen(); | 1403 m_responseDocumentParser = m_responseDocument->implicitOpen(); |
| 1404 m_responseDocumentParser->addClient(this); | 1404 m_responseDocumentParser->addClient(this); |
| 1405 } | 1405 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1429 | 1429 |
| 1430 return decoder.release(); | 1430 return decoder.release(); |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 if (responseIsHTML()) | 1433 if (responseIsHTML()) |
| 1434 return TextResourceDecoder::create("text/html", "UTF-8"); | 1434 return TextResourceDecoder::create("text/html", "UTF-8"); |
| 1435 | 1435 |
| 1436 return TextResourceDecoder::create("text/plain", "UTF-8"); | 1436 return TextResourceDecoder::create("text/plain", "UTF-8"); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 void XMLHttpRequest::didReceiveData(const char* data, int len) | 1439 void XMLHttpRequest::didReceiveData(const char* data, unsigned len) |
| 1440 { | 1440 { |
| 1441 ASSERT(!m_downloadingToFile); | 1441 ASSERT(!m_downloadingToFile); |
| 1442 | 1442 |
| 1443 if (m_error) | 1443 if (m_error) |
| 1444 return; | 1444 return; |
| 1445 | 1445 |
| 1446 if (m_state < HEADERS_RECEIVED) | 1446 if (m_state < HEADERS_RECEIVED) |
| 1447 changeState(HEADERS_RECEIVED); | 1447 changeState(HEADERS_RECEIVED); |
| 1448 | 1448 |
| 1449 // We need to check for |m_error| again, because |changeState| may trigger | 1449 // We need to check for |m_error| again, because |changeState| may trigger |
| 1450 // readystatechange, and user javascript can cause |abort()|. | 1450 // readystatechange, and user javascript can cause |abort()|. |
| 1451 if (m_error) | 1451 if (m_error) |
| 1452 return; | 1452 return; |
| 1453 | 1453 |
| 1454 if (!len) | 1454 if (!len) |
| 1455 return; | 1455 return; |
| 1456 | 1456 |
| 1457 if (len == -1) | |
| 1458 len = strlen(data); | |
| 1459 | |
| 1460 if (m_responseTypeCode == ResponseTypeDocument && responseIsHTML()) { | 1457 if (m_responseTypeCode == ResponseTypeDocument && responseIsHTML()) { |
| 1461 parseDocumentChunk(data, len); | 1458 parseDocumentChunk(data, len); |
| 1462 } else if (m_responseTypeCode == ResponseTypeDefault || m_responseTypeCode = = ResponseTypeText || m_responseTypeCode == ResponseTypeJSON || m_responseTypeCo de == ResponseTypeDocument) { | 1459 } else if (m_responseTypeCode == ResponseTypeDefault || m_responseTypeCode = = ResponseTypeText || m_responseTypeCode == ResponseTypeJSON || m_responseTypeCo de == ResponseTypeDocument) { |
| 1463 if (!m_decoder) | 1460 if (!m_decoder) |
| 1464 m_decoder = createDecoder(); | 1461 m_decoder = createDecoder(); |
| 1465 | 1462 |
| 1466 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data, len)); | 1463 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data, len)); |
| 1467 } else if (m_responseTypeCode == ResponseTypeArrayBuffer || m_responseTypeCo de == ResponseTypeBlob) { | 1464 } else if (m_responseTypeCode == ResponseTypeArrayBuffer || m_responseTypeCo de == ResponseTypeBlob) { |
| 1468 // Buffer binary data. | 1465 // Buffer binary data. |
| 1469 if (!m_binaryResponseBuilder) | 1466 if (!m_binaryResponseBuilder) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 visitor->trace(m_responseStream); | 1567 visitor->trace(m_responseStream); |
| 1571 visitor->trace(m_streamSource); | 1568 visitor->trace(m_streamSource); |
| 1572 visitor->trace(m_responseDocument); | 1569 visitor->trace(m_responseDocument); |
| 1573 visitor->trace(m_responseDocumentParser); | 1570 visitor->trace(m_responseDocumentParser); |
| 1574 visitor->trace(m_progressEventThrottle); | 1571 visitor->trace(m_progressEventThrottle); |
| 1575 visitor->trace(m_upload); | 1572 visitor->trace(m_upload); |
| 1576 XMLHttpRequestEventTarget::trace(visitor); | 1573 XMLHttpRequestEventTarget::trace(visitor); |
| 1577 } | 1574 } |
| 1578 | 1575 |
| 1579 } // namespace blink | 1576 } // namespace blink |
| OLD | NEW |