| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 { | 481 { |
| 482 if (!m_upload) | 482 if (!m_upload) |
| 483 m_upload = XMLHttpRequestUpload::create(this); | 483 m_upload = XMLHttpRequestUpload::create(this); |
| 484 return m_upload.get(); | 484 return m_upload.get(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void XMLHttpRequest::trackProgress(long long length) | 487 void XMLHttpRequest::trackProgress(long long length) |
| 488 { | 488 { |
| 489 m_receivedLength += length; | 489 m_receivedLength += length; |
| 490 | 490 |
| 491 if (m_state != LOADING) { | 491 changeState(LOADING); |
| 492 changeState(LOADING); | 492 if (m_async) { |
| 493 } else { | 493 // readyStateChange event is fired as well. |
| 494 // Dispatch a readystatechange event because many applications use | 494 dispatchProgressEventFromSnapshot(EventTypeNames::progress); |
| 495 // it to track progress although this is not specified. | |
| 496 // | |
| 497 // FIXME: Stop dispatching this event for progress tracking. | |
| 498 dispatchReadyStateChangeEvent(); | |
| 499 } | 495 } |
| 500 if (m_async) | |
| 501 dispatchProgressEventFromSnapshot(EventTypeNames::progress); | |
| 502 } | 496 } |
| 503 | 497 |
| 504 void XMLHttpRequest::changeState(State newState) | 498 void XMLHttpRequest::changeState(State newState) |
| 505 { | 499 { |
| 506 if (m_state != newState) { | 500 if (m_state != newState) { |
| 507 m_state = newState; | 501 m_state = newState; |
| 508 dispatchReadyStateChangeEvent(); | 502 dispatchReadyStateChangeEvent(); |
| 509 } | 503 } |
| 510 } | 504 } |
| 511 | 505 |
| 512 void XMLHttpRequest::dispatchReadyStateChangeEvent() | 506 void XMLHttpRequest::dispatchReadyStateChangeEvent() |
| 513 { | 507 { |
| 514 if (!executionContext()) | 508 if (!executionContext()) |
| 515 return; | 509 return; |
| 516 | 510 |
| 517 // We need this protection because dispatchReadyStateChangeEvent may | |
| 518 // dispatch multiple events. | |
| 519 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); | 511 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); |
| 520 if (m_async || (m_state <= OPENED || m_state == DONE)) { | 512 if (m_async || (m_state <= OPENED || m_state == DONE)) { |
| 521 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect
orXhrReadyStateChangeEvent::data(executionContext(), this)); | 513 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect
orXhrReadyStateChangeEvent::data(executionContext(), this)); |
| 522 XMLHttpRequestProgressEventThrottle::DeferredEventAction action = XMLHtt
pRequestProgressEventThrottle::Ignore; | 514 XMLHttpRequestProgressEventThrottle::DeferredEventAction action = XMLHtt
pRequestProgressEventThrottle::Ignore; |
| 523 if (m_state == DONE) { | 515 if (m_state == DONE) { |
| 524 if (m_error) | 516 if (m_error) |
| 525 action = XMLHttpRequestProgressEventThrottle::Clear; | 517 action = XMLHttpRequestProgressEventThrottle::Clear; |
| 526 else | 518 else |
| 527 action = XMLHttpRequestProgressEventThrottle::Flush; | 519 action = XMLHttpRequestProgressEventThrottle::Flush; |
| 528 } | 520 } |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 } | 1661 } |
| 1670 | 1662 |
| 1671 void XMLHttpRequest::resume() | 1663 void XMLHttpRequest::resume() |
| 1672 { | 1664 { |
| 1673 m_progressEventThrottle->resume(); | 1665 m_progressEventThrottle->resume(); |
| 1674 } | 1666 } |
| 1675 | 1667 |
| 1676 void XMLHttpRequest::stop() | 1668 void XMLHttpRequest::stop() |
| 1677 { | 1669 { |
| 1678 InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this,
m_method, m_url); | 1670 InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this,
m_method, m_url); |
| 1671 m_progressEventThrottle->stop(); |
| 1679 internalAbort(); | 1672 internalAbort(); |
| 1680 } | 1673 } |
| 1681 | 1674 |
| 1682 bool XMLHttpRequest::hasPendingActivity() const | 1675 bool XMLHttpRequest::hasPendingActivity() const |
| 1683 { | 1676 { |
| 1684 // Neither this object nor the JavaScript wrapper should be deleted while | 1677 // Neither this object nor the JavaScript wrapper should be deleted while |
| 1685 // a request is in progress because we need to keep the listeners alive, | 1678 // a request is in progress because we need to keep the listeners alive, |
| 1686 // and they are referenced by the JavaScript wrapper. | 1679 // and they are referenced by the JavaScript wrapper. |
| 1687 // |m_loader| is non-null while request is active and ThreadableLoaderClient | 1680 // |m_loader| is non-null while request is active and ThreadableLoaderClient |
| 1688 // callbacks may be called, and |m_responseDocumentParser| is non-null while | 1681 // callbacks may be called, and |m_responseDocumentParser| is non-null while |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1716 visitor->trace(m_responseDocumentParser); | 1709 visitor->trace(m_responseDocumentParser); |
| 1717 visitor->trace(m_progressEventThrottle); | 1710 visitor->trace(m_progressEventThrottle); |
| 1718 visitor->trace(m_upload); | 1711 visitor->trace(m_upload); |
| 1719 visitor->trace(m_blobLoader); | 1712 visitor->trace(m_blobLoader); |
| 1720 XMLHttpRequestEventTarget::trace(visitor); | 1713 XMLHttpRequestEventTarget::trace(visitor); |
| 1721 DocumentParserClient::trace(visitor); | 1714 DocumentParserClient::trace(visitor); |
| 1722 ActiveDOMObject::trace(visitor); | 1715 ActiveDOMObject::trace(visitor); |
| 1723 } | 1716 } |
| 1724 | 1717 |
| 1725 } // namespace blink | 1718 } // namespace blink |
| OLD | NEW |