| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right reserv
ed. | 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right reserv
ed. |
| 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 void XMLHttpRequestProgressEventThrottle::DeferredEvent::clear() | 55 void XMLHttpRequestProgressEventThrottle::DeferredEvent::clear() |
| 56 { | 56 { |
| 57 m_isSet = false; | 57 m_isSet = false; |
| 58 | 58 |
| 59 m_lengthComputable = false; | 59 m_lengthComputable = false; |
| 60 m_loaded = 0; | 60 m_loaded = 0; |
| 61 m_total = 0; | 61 m_total = 0; |
| 62 } | 62 } |
| 63 | 63 |
| 64 PassRefPtrWillBeRawPtr<Event> XMLHttpRequestProgressEventThrottle::DeferredEvent
::take() | 64 RawPtr<Event> XMLHttpRequestProgressEventThrottle::DeferredEvent::take() |
| 65 { | 65 { |
| 66 ASSERT(m_isSet); | 66 ASSERT(m_isSet); |
| 67 | 67 |
| 68 RefPtrWillBeRawPtr<Event> event = ProgressEvent::create(EventTypeNames::prog
ress, m_lengthComputable, m_loaded, m_total); | 68 RawPtr<Event> event = ProgressEvent::create(EventTypeNames::progress, m_leng
thComputable, m_loaded, m_total); |
| 69 clear(); | 69 clear(); |
| 70 return event.release(); | 70 return event.release(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(XMLHttp
Request* target) | 73 XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(XMLHttp
Request* target) |
| 74 : m_target(target) | 74 : m_target(target) |
| 75 , m_hasDispatchedProgressProgressEvent(false) | 75 , m_hasDispatchedProgressProgressEvent(false) |
| 76 { | 76 { |
| 77 ASSERT(target); | 77 ASSERT(target); |
| 78 } | 78 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (isActive()) { | 93 if (isActive()) { |
| 94 m_deferred.set(lengthComputable, loaded, total); | 94 m_deferred.set(lengthComputable, loaded, total); |
| 95 } else { | 95 } else { |
| 96 dispatchProgressProgressEvent(ProgressEvent::create(EventTypeNames::prog
ress, lengthComputable, loaded, total)); | 96 dispatchProgressProgressEvent(ProgressEvent::create(EventTypeNames::prog
ress, lengthComputable, loaded, total)); |
| 97 startOneShot(kMinimumProgressEventDispatchingIntervalInSeconds, BLINK_FR
OM_HERE); | 97 startOneShot(kMinimumProgressEventDispatchingIntervalInSeconds, BLINK_FR
OM_HERE); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
trWillBeRawPtr<Event> event, DeferredEventAction action) | 101 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(RawPtr<E
vent> event, DeferredEventAction action) |
| 102 { | 102 { |
| 103 XMLHttpRequest::State state = m_target->readyState(); | 103 XMLHttpRequest::State state = m_target->readyState(); |
| 104 // Given that ResourceDispatcher doesn't deliver an event when suspended, | 104 // Given that ResourceDispatcher doesn't deliver an event when suspended, |
| 105 // we don't have to worry about event dispatching while suspended. | 105 // we don't have to worry about event dispatching while suspended. |
| 106 if (action == Flush) { | 106 if (action == Flush) { |
| 107 if (m_deferred.isSet()) | 107 if (m_deferred.isSet()) |
| 108 dispatchProgressProgressEvent(m_deferred.take()); | 108 dispatchProgressProgressEvent(m_deferred.take()); |
| 109 | 109 |
| 110 stop(); | 110 stop(); |
| 111 } else if (action == Clear) { | 111 } else if (action == Clear) { |
| 112 m_deferred.clear(); | 112 m_deferred.clear(); |
| 113 stop(); | 113 stop(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 m_hasDispatchedProgressProgressEvent = false; | 116 m_hasDispatchedProgressProgressEvent = false; |
| 117 if (state == m_target->readyState()) { | 117 if (state == m_target->readyState()) { |
| 118 // We don't dispatch the event when an event handler associated with | 118 // We don't dispatch the event when an event handler associated with |
| 119 // the previously dispatched event changes the readyState (e.g. when | 119 // the previously dispatched event changes the readyState (e.g. when |
| 120 // the event handler calls xhr.abort()). In such cases a | 120 // the event handler calls xhr.abort()). In such cases a |
| 121 // readystatechange should have been already dispatched if necessary. | 121 // readystatechange should have been already dispatched if necessary. |
| 122 m_target->dispatchEvent(event); | 122 m_target->dispatchEvent(event); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(PassRefP
trWillBeRawPtr<Event> progressEvent) | 126 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(RawPtr<E
vent> progressEvent) |
| 127 { | 127 { |
| 128 XMLHttpRequest::State state = m_target->readyState(); | 128 XMLHttpRequest::State state = m_target->readyState(); |
| 129 if (m_target->readyState() == XMLHttpRequest::LOADING && m_hasDispatchedProg
ressProgressEvent) { | 129 if (m_target->readyState() == XMLHttpRequest::LOADING && m_hasDispatchedProg
ressProgressEvent) { |
| 130 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect
orXhrReadyStateChangeEvent::data(m_target->getExecutionContext(), m_target)); | 130 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect
orXhrReadyStateChangeEvent::data(m_target->getExecutionContext(), m_target)); |
| 131 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange))
; | 131 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange))
; |
| 132 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::d
ata()); | 132 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::d
ata()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 if (m_target->readyState() != state) | 135 if (m_target->readyState() != state) |
| 136 return; | 136 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // event-handler could insert new active DOM objects to the list. | 168 // event-handler could insert new active DOM objects to the list. |
| 169 startOneShot(0, BLINK_FROM_HERE); | 169 startOneShot(0, BLINK_FROM_HERE); |
| 170 } | 170 } |
| 171 | 171 |
| 172 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) | 172 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) |
| 173 { | 173 { |
| 174 visitor->trace(m_target); | 174 visitor->trace(m_target); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |