| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> | 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> |
| 3 * All right reserved. | 3 * All right reserved. |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // them at the required frequency. If this object is suspended, the given | 68 // them at the required frequency. If this object is suspended, the given |
| 69 // ProgressEvent overwrites the existing. I.e. only the latest one gets | 69 // ProgressEvent overwrites the existing. I.e. only the latest one gets |
| 70 // queued. If the timer is running, this method just updates | 70 // queued. If the timer is running, this method just updates |
| 71 // m_lengthComputable, m_loaded and m_total. They'll be used on next | 71 // m_lengthComputable, m_loaded and m_total. They'll be used on next |
| 72 // fired() call. | 72 // fired() call. |
| 73 // For an event named "progress", a readyStateChange will be dispatched | 73 // For an event named "progress", a readyStateChange will be dispatched |
| 74 // as well. | 74 // as well. |
| 75 void dispatchProgressEvent(const AtomicString&, bool lengthComputable, unsig
ned long long loaded, unsigned long long total); | 75 void dispatchProgressEvent(const AtomicString&, bool lengthComputable, unsig
ned long long loaded, unsigned long long total); |
| 76 // Dispatches the given event after operation about the "progress" event | 76 // Dispatches the given event after operation about the "progress" event |
| 77 // depending on the value of the ProgressEventAction argument. | 77 // depending on the value of the ProgressEventAction argument. |
| 78 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, DeferredEv
entAction); | 78 void dispatchReadyStateChangeEvent(RawPtr<Event>, DeferredEventAction); |
| 79 | 79 |
| 80 void suspend(); | 80 void suspend(); |
| 81 void resume(); | 81 void resume(); |
| 82 | 82 |
| 83 // Need to promptly stop this timer when it is deemed finalizable. | 83 // Need to promptly stop this timer when it is deemed finalizable. |
| 84 EAGERLY_FINALIZE(); | 84 EAGERLY_FINALIZE(); |
| 85 DECLARE_TRACE(); | 85 DECLARE_TRACE(); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); | 88 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); |
| 89 | 89 |
| 90 // Dispatches a "progress" progress event and usually a readyStateChange | 90 // Dispatches a "progress" progress event and usually a readyStateChange |
| 91 // event as well. | 91 // event as well. |
| 92 void dispatchProgressProgressEvent(PassRefPtrWillBeRawPtr<Event>); | 92 void dispatchProgressProgressEvent(RawPtr<Event>); |
| 93 | 93 |
| 94 // The main purpose of this class is to throttle the "progress" | 94 // The main purpose of this class is to throttle the "progress" |
| 95 // ProgressEvent dispatching. This class represents such a deferred | 95 // ProgressEvent dispatching. This class represents such a deferred |
| 96 // "progress" ProgressEvent. | 96 // "progress" ProgressEvent. |
| 97 class DeferredEvent { | 97 class DeferredEvent { |
| 98 public: | 98 public: |
| 99 DeferredEvent(); | 99 DeferredEvent(); |
| 100 void set(bool lengthComputable, unsigned long long loaded, unsigned long
long total); | 100 void set(bool lengthComputable, unsigned long long loaded, unsigned long
long total); |
| 101 void clear(); | 101 void clear(); |
| 102 bool isSet() const { return m_isSet; } | 102 bool isSet() const { return m_isSet; } |
| 103 PassRefPtrWillBeRawPtr<Event> take(); | 103 RawPtr<Event> take(); |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 unsigned long long m_loaded; | 106 unsigned long long m_loaded; |
| 107 unsigned long long m_total; | 107 unsigned long long m_total; |
| 108 bool m_lengthComputable; | 108 bool m_lengthComputable; |
| 109 | 109 |
| 110 bool m_isSet; | 110 bool m_isSet; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 void fired() override; | 113 void fired() override; |
| 114 | 114 |
| 115 Member<XMLHttpRequest> m_target; | 115 Member<XMLHttpRequest> m_target; |
| 116 | 116 |
| 117 // A slot for the deferred "progress" ProgressEvent. When multiple events | 117 // A slot for the deferred "progress" ProgressEvent. When multiple events |
| 118 // arrive, only the last one is stored and others are discarded. | 118 // arrive, only the last one is stored and others are discarded. |
| 119 DeferredEvent m_deferred; | 119 DeferredEvent m_deferred; |
| 120 | 120 |
| 121 // True if any "progress" progress event has been dispatched since | 121 // True if any "progress" progress event has been dispatched since |
| 122 // |m_target|'s readyState changed. | 122 // |m_target|'s readyState changed. |
| 123 bool m_hasDispatchedProgressProgressEvent; | 123 bool m_hasDispatchedProgressProgressEvent; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| 127 | 127 |
| 128 #endif // XMLHttpRequestProgressEventThrottle_h | 128 #endif // XMLHttpRequestProgressEventThrottle_h |
| OLD | NEW |