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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h" | 27 #include "core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h" |
28 | 28 |
29 #include "core/EventTypeNames.h" | 29 #include "core/EventTypeNames.h" |
| 30 #include "core/events/ProgressEvent.h" |
30 #include "core/inspector/InspectorInstrumentation.h" | 31 #include "core/inspector/InspectorInstrumentation.h" |
31 #include "core/inspector/InspectorTraceEvents.h" | 32 #include "core/inspector/InspectorTraceEvents.h" |
32 #include "core/xmlhttprequest/XMLHttpRequest.h" | 33 #include "core/xmlhttprequest/XMLHttpRequest.h" |
33 #include "core/xmlhttprequest/XMLHttpRequestProgressEvent.h" | |
34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
35 #include "wtf/text/AtomicString.h" | 35 #include "wtf/text/AtomicString.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 XMLHttpRequestProgressEventThrottle::DeferredEvent::DeferredEvent() | 39 XMLHttpRequestProgressEventThrottle::DeferredEvent::DeferredEvent() |
40 { | 40 { |
41 clear(); | 41 clear(); |
42 } | 42 } |
43 | 43 |
(...skipping 12 matching lines...) Expand all Loading... |
56 | 56 |
57 m_lengthComputable = false; | 57 m_lengthComputable = false; |
58 m_loaded = 0; | 58 m_loaded = 0; |
59 m_total = 0; | 59 m_total = 0; |
60 } | 60 } |
61 | 61 |
62 PassRefPtrWillBeRawPtr<Event> XMLHttpRequestProgressEventThrottle::DeferredEvent
::take() | 62 PassRefPtrWillBeRawPtr<Event> XMLHttpRequestProgressEventThrottle::DeferredEvent
::take() |
63 { | 63 { |
64 ASSERT(m_isSet); | 64 ASSERT(m_isSet); |
65 | 65 |
66 RefPtrWillBeRawPtr<Event> event = XMLHttpRequestProgressEvent::create(EventT
ypeNames::progress, m_lengthComputable, m_loaded, m_total); | 66 RefPtrWillBeRawPtr<Event> event = ProgressEvent::create(EventTypeNames::prog
ress, m_lengthComputable, m_loaded, m_total); |
67 clear(); | 67 clear(); |
68 return event.release(); | 68 return event.release(); |
69 } | 69 } |
70 | 70 |
71 const double XMLHttpRequestProgressEventThrottle::minimumProgressEventDispatchin
gIntervalInSeconds = .05; // 50 ms per specification. | 71 const double XMLHttpRequestProgressEventThrottle::minimumProgressEventDispatchin
gIntervalInSeconds = .05; // 50 ms per specification. |
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 } |
79 | 79 |
80 XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle() | 80 XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle() |
81 { | 81 { |
82 } | 82 } |
83 | 83 |
84 void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicStri
ng& type, bool lengthComputable, unsigned long long loaded, unsigned long long t
otal) | 84 void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicStri
ng& type, bool lengthComputable, unsigned long long loaded, unsigned long long t
otal) |
85 { | 85 { |
86 // Given that ResourceDispatcher doesn't deliver an event when suspended, | 86 // Given that ResourceDispatcher doesn't deliver an event when suspended, |
87 // we don't have to worry about event dispatching while suspended. | 87 // we don't have to worry about event dispatching while suspended. |
88 if (type != EventTypeNames::progress) { | 88 if (type != EventTypeNames::progress) { |
89 m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(type, length
Computable, loaded, total)); | 89 m_target->dispatchEvent(ProgressEvent::create(type, lengthComputable, lo
aded, total)); |
90 return; | 90 return; |
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(XMLHttpRequestProgressEvent::create(EventT
ypeNames::progress, lengthComputable, loaded, total)); | 96 dispatchProgressProgressEvent(ProgressEvent::create(EventTypeNames::prog
ress, lengthComputable, loaded, total)); |
97 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, BLINK_FRO
M_HERE); | 97 startOneShot(minimumProgressEventDispatchingIntervalInSeconds, BLINK_FRO
M_HERE); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
trWillBeRawPtr<Event> event, DeferredEventAction action) | 101 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
trWillBeRawPtr<Event> 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) { |
(...skipping 61 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 |