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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // In the comments for this class: | 48 // In the comments for this class: |
49 // - "progress" event means an event named "progress" | 49 // - "progress" event means an event named "progress" |
50 // - ProgressEvent means an event using the ProgressEvent interface defined in | 50 // - ProgressEvent means an event using the ProgressEvent interface defined in |
51 // the spec. | 51 // the spec. |
52 class XMLHttpRequestProgressEventThrottle final : public NoBaseWillBeGarbageColl
ectedFinalized<XMLHttpRequestProgressEventThrottle>, public TimerBase { | 52 class XMLHttpRequestProgressEventThrottle final : public NoBaseWillBeGarbageColl
ectedFinalized<XMLHttpRequestProgressEventThrottle>, public TimerBase { |
53 public: | 53 public: |
54 static PassOwnPtrWillBeRawPtr<XMLHttpRequestProgressEventThrottle> create(XM
LHttpRequest* eventTarget) | 54 static PassOwnPtrWillBeRawPtr<XMLHttpRequestProgressEventThrottle> create(XM
LHttpRequest* eventTarget) |
55 { | 55 { |
56 return adoptPtrWillBeNoop(new XMLHttpRequestProgressEventThrottle(eventT
arget)); | 56 return adoptPtrWillBeNoop(new XMLHttpRequestProgressEventThrottle(eventT
arget)); |
57 } | 57 } |
58 virtual ~XMLHttpRequestProgressEventThrottle(); | 58 ~XMLHttpRequestProgressEventThrottle() override; |
59 | 59 |
60 enum DeferredEventAction { | 60 enum DeferredEventAction { |
61 Ignore, | 61 Ignore, |
62 Clear, | 62 Clear, |
63 Flush, | 63 Flush, |
64 }; | 64 }; |
65 | 65 |
66 // Dispatches a ProgressEvent. | 66 // Dispatches a ProgressEvent. |
67 // | 67 // |
68 // Special treatment for events named "progress" is implemented to dispatch | 68 // Special treatment for events named "progress" is implemented to dispatch |
(...skipping 16 matching lines...) Expand all Loading... |
85 | 85 |
86 private: | 86 private: |
87 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); | 87 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); |
88 | 88 |
89 // The main purpose of this class is to throttle the "progress" | 89 // The main purpose of this class is to throttle the "progress" |
90 // ProgressEvent dispatching. This class represents such a deferred | 90 // ProgressEvent dispatching. This class represents such a deferred |
91 // "progress" ProgressEvent. | 91 // "progress" ProgressEvent. |
92 class DeferredEvent; | 92 class DeferredEvent; |
93 static const double minimumProgressEventDispatchingIntervalInSeconds; | 93 static const double minimumProgressEventDispatchingIntervalInSeconds; |
94 | 94 |
95 virtual void fired() override; | 95 void fired() override; |
96 void dispatchDeferredEvent(); | 96 void dispatchDeferredEvent(); |
97 | 97 |
98 // Non-Oilpan, keep a weak pointer to our XMLHttpRequest object as it is | 98 // Non-Oilpan, keep a weak pointer to our XMLHttpRequest object as it is |
99 // the one holding us. With Oilpan, a simple strong Member can be used - | 99 // the one holding us. With Oilpan, a simple strong Member can be used - |
100 // this XMLHttpRequestProgressEventThrottle (part) object dies together | 100 // this XMLHttpRequestProgressEventThrottle (part) object dies together |
101 // with the XMLHttpRequest object. | 101 // with the XMLHttpRequest object. |
102 RawPtrWillBeMember<XMLHttpRequest> m_target; | 102 RawPtrWillBeMember<XMLHttpRequest> m_target; |
103 | 103 |
104 // A slot for the deferred "progress" ProgressEvent. When multiple events | 104 // A slot for the deferred "progress" ProgressEvent. When multiple events |
105 // arrive, only the last one is stored and others are discarded. | 105 // arrive, only the last one is stored and others are discarded. |
106 const OwnPtr<DeferredEvent> m_deferred; | 106 const OwnPtr<DeferredEvent> m_deferred; |
107 }; | 107 }; |
108 | 108 |
109 } // namespace blink | 109 } // namespace blink |
110 | 110 |
111 #endif // XMLHttpRequestProgressEventThrottle_h | 111 #endif // XMLHttpRequestProgressEventThrottle_h |
OLD | NEW |