| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // we don't have to worry about event dispatching while suspended. | 83 // we don't have to worry about event dispatching while suspended. |
| 84 if (type != EventTypeNames::progress) { | 84 if (type != EventTypeNames::progress) { |
| 85 m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(type, length
Computable, loaded, total)); | 85 m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(type, length
Computable, loaded, total)); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 | 88 |
| 89 if (isActive()) { | 89 if (isActive()) { |
| 90 m_deferred->set(lengthComputable, loaded, total); | 90 m_deferred->set(lengthComputable, loaded, total); |
| 91 } else { | 91 } else { |
| 92 m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(type, length
Computable, loaded, total)); | 92 m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(type, length
Computable, loaded, total)); |
| 93 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, FROM_HERE
); | 93 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, BLINK_FRO
M_HERE); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
trWillBeRawPtr<Event> event, DeferredEventAction action) | 97 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
trWillBeRawPtr<Event> event, DeferredEventAction action) |
| 98 { | 98 { |
| 99 XMLHttpRequest::State state = m_target->readyState(); | 99 XMLHttpRequest::State state = m_target->readyState(); |
| 100 // Given that ResourceDispatcher doesn't deliver an event when suspended, | 100 // Given that ResourceDispatcher doesn't deliver an event when suspended, |
| 101 // we don't have to worry about event dispatching while suspended. | 101 // we don't have to worry about event dispatching while suspended. |
| 102 if (action == Flush) { | 102 if (action == Flush) { |
| 103 dispatchDeferredEvent(); | 103 dispatchDeferredEvent(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 129 { | 129 { |
| 130 if (!m_deferred->isDeferred()) { | 130 if (!m_deferred->isDeferred()) { |
| 131 // No "progress" event was queued since the previous dispatch, we can | 131 // No "progress" event was queued since the previous dispatch, we can |
| 132 // safely stop the timer. | 132 // safely stop the timer. |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 dispatchDeferredEvent(); | 136 dispatchDeferredEvent(); |
| 137 | 137 |
| 138 // Watch if another "progress" ProgressEvent arrives in the next 50ms. | 138 // Watch if another "progress" ProgressEvent arrives in the next 50ms. |
| 139 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, FROM_HERE); | 139 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, BLINK_FROM_HE
RE); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void XMLHttpRequestProgressEventThrottle::suspend() | 142 void XMLHttpRequestProgressEventThrottle::suspend() |
| 143 { | 143 { |
| 144 stop(); | 144 stop(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void XMLHttpRequestProgressEventThrottle::resume() | 147 void XMLHttpRequestProgressEventThrottle::resume() |
| 148 { | 148 { |
| 149 if (!m_deferred->isDeferred()) | 149 if (!m_deferred->isDeferred()) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 // Do not dispatch events inline here, since ExecutionContext is iterating | 152 // Do not dispatch events inline here, since ExecutionContext is iterating |
| 153 // over the list of active DOM objects to resume them, and any activated JS | 153 // over the list of active DOM objects to resume them, and any activated JS |
| 154 // event-handler could insert new active DOM objects to the list. | 154 // event-handler could insert new active DOM objects to the list. |
| 155 startOneShot(0, FROM_HERE); | 155 startOneShot(0, BLINK_FROM_HERE); |
| 156 } | 156 } |
| 157 | 157 |
| 158 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) | 158 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) |
| 159 { | 159 { |
| 160 visitor->trace(m_target); | 160 visitor->trace(m_target); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |