OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right | 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 dispatchProgressProgressEvent(ProgressEvent::create( | 105 dispatchProgressProgressEvent(ProgressEvent::create( |
106 EventTypeNames::progress, lengthComputable, loaded, total)); | 106 EventTypeNames::progress, lengthComputable, loaded, total)); |
107 startOneShot(kMinimumProgressEventDispatchingIntervalInSeconds, | 107 startOneShot(kMinimumProgressEventDispatchingIntervalInSeconds, |
108 BLINK_FROM_HERE); | 108 BLINK_FROM_HERE); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent( | 112 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent( |
113 Event* event, | 113 Event* event, |
114 DeferredEventAction action) { | 114 DeferredEventAction action) { |
115 XMLHttpRequest::State state = m_target->readyState(); | 115 XMLHttpRequest::State state = m_target->getReadyState(); |
116 // Given that ResourceDispatcher doesn't deliver an event when suspended, | 116 // Given that ResourceDispatcher doesn't deliver an event when suspended, |
117 // we don't have to worry about event dispatching while suspended. | 117 // we don't have to worry about event dispatching while suspended. |
118 if (action == Flush) { | 118 if (action == Flush) { |
119 if (m_deferred.isSet()) | 119 if (m_deferred.isSet()) |
120 dispatchProgressProgressEvent(m_deferred.take()); | 120 dispatchProgressProgressEvent(m_deferred.take()); |
121 | 121 |
122 stop(); | 122 stop(); |
123 } else if (action == Clear) { | 123 } else if (action == Clear) { |
124 m_deferred.clear(); | 124 m_deferred.clear(); |
125 stop(); | 125 stop(); |
126 } | 126 } |
127 | 127 |
128 m_hasDispatchedProgressProgressEvent = false; | 128 m_hasDispatchedProgressProgressEvent = false; |
129 if (state == m_target->readyState()) { | 129 if (state == m_target->getReadyState()) { |
130 // We don't dispatch the event when an event handler associated with | 130 // We don't dispatch the event when an event handler associated with |
131 // the previously dispatched event changes the readyState (e.g. when | 131 // the previously dispatched event changes the readyState (e.g. when |
132 // the event handler calls xhr.abort()). In such cases a | 132 // the event handler calls xhr.abort()). In such cases a |
133 // readystatechange should have been already dispatched if necessary. | 133 // readystatechange should have been already dispatched if necessary. |
134 InspectorInstrumentation::AsyncTask asyncTask( | 134 InspectorInstrumentation::AsyncTask asyncTask( |
135 m_target->getExecutionContext(), m_target, m_target->isAsync()); | 135 m_target->getExecutionContext(), m_target, m_target->isAsync()); |
136 m_target->dispatchEvent(event); | 136 m_target->dispatchEvent(event); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent( | 140 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent( |
141 Event* progressEvent) { | 141 Event* progressEvent) { |
142 XMLHttpRequest::State state = m_target->readyState(); | 142 XMLHttpRequest::State state = m_target->getReadyState(); |
143 if (m_target->readyState() == XMLHttpRequest::kLoading && | 143 if (m_target->getReadyState() == XMLHttpRequest::kLoading && |
144 m_hasDispatchedProgressProgressEvent) { | 144 m_hasDispatchedProgressProgressEvent) { |
145 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", | 145 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", |
146 InspectorXhrReadyStateChangeEvent::data( | 146 InspectorXhrReadyStateChangeEvent::data( |
147 m_target->getExecutionContext(), m_target)); | 147 m_target->getExecutionContext(), m_target)); |
148 InspectorInstrumentation::AsyncTask asyncTask( | 148 InspectorInstrumentation::AsyncTask asyncTask( |
149 m_target->getExecutionContext(), m_target, m_target->isAsync()); | 149 m_target->getExecutionContext(), m_target, m_target->isAsync()); |
150 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)); | 150 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)); |
151 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), | 151 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), |
152 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", | 152 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", |
153 InspectorUpdateCountersEvent::data()); | 153 InspectorUpdateCountersEvent::data()); |
154 } | 154 } |
155 | 155 |
156 if (m_target->readyState() != state) | 156 if (m_target->getReadyState() != state) |
157 return; | 157 return; |
158 | 158 |
159 m_hasDispatchedProgressProgressEvent = true; | 159 m_hasDispatchedProgressProgressEvent = true; |
160 InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext(), | 160 InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext(), |
161 m_target, m_target->isAsync()); | 161 m_target, m_target->isAsync()); |
162 m_target->dispatchEvent(progressEvent); | 162 m_target->dispatchEvent(progressEvent); |
163 } | 163 } |
164 | 164 |
165 void XMLHttpRequestProgressEventThrottle::fired() { | 165 void XMLHttpRequestProgressEventThrottle::fired() { |
166 if (!m_deferred.isSet()) { | 166 if (!m_deferred.isSet()) { |
(...skipping 21 matching lines...) Expand all Loading... |
188 // over the list of active DOM objects to resume them, and any activated JS | 188 // over the list of active DOM objects to resume them, and any activated JS |
189 // event-handler could insert new active DOM objects to the list. | 189 // event-handler could insert new active DOM objects to the list. |
190 startOneShot(0, BLINK_FROM_HERE); | 190 startOneShot(0, BLINK_FROM_HERE); |
191 } | 191 } |
192 | 192 |
193 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) { | 193 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) { |
194 visitor->trace(m_target); | 194 visitor->trace(m_target); |
195 } | 195 } |
196 | 196 |
197 } // namespace blink | 197 } // namespace blink |
OLD | NEW |