Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h

Issue 1455513002: [XHR] Decrease readyStateChange event dispatching during loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
69 // them at the required frequency. If this object is suspended, the given 69 // them at the required frequency. If this object is suspended, the given
70 // ProgressEvent overwrites the existing. I.e. only the latest one gets 70 // ProgressEvent overwrites the existing. I.e. only the latest one gets
71 // queued. If the timer is running, this method just updates 71 // queued. If the timer is running, this method just updates
72 // m_lengthComputable, m_loaded and m_total. They'll be used on next 72 // m_lengthComputable, m_loaded and m_total. They'll be used on next
73 // fired() call. 73 // fired() call.
74 // For an event named "progress", a readyStateChange will be dispatched
75 // as well.
74 void dispatchProgressEvent(const AtomicString&, bool lengthComputable, unsig ned long long loaded, unsigned long long total); 76 void dispatchProgressEvent(const AtomicString&, bool lengthComputable, unsig ned long long loaded, unsigned long long total);
75 // Dispatches the given event after operation about the "progress" event 77 // Dispatches the given event after operation about the "progress" event
76 // depending on the value of the ProgressEventAction argument. 78 // depending on the value of the ProgressEventAction argument.
77 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, DeferredEv entAction); 79 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, DeferredEv entAction);
78 80
79 void suspend(); 81 void suspend();
80 void resume(); 82 void resume();
81 83
82 // Need to promptly stop this timer when it is deemed finalizable. 84 // Need to promptly stop this timer when it is deemed finalizable.
83 EAGERLY_FINALIZE(); 85 EAGERLY_FINALIZE();
84 DECLARE_TRACE(); 86 DECLARE_TRACE();
85 87
86 private: 88 private:
87 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); 89 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*);
88 90
91 // Dispatches a "progress" progress event and usually a readyStateChange
92 // event as well.
93 void dispatchProgressProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
94
89 // The main purpose of this class is to throttle the "progress" 95 // The main purpose of this class is to throttle the "progress"
90 // ProgressEvent dispatching. This class represents such a deferred 96 // ProgressEvent dispatching. This class represents such a deferred
91 // "progress" ProgressEvent. 97 // "progress" ProgressEvent.
92 class DeferredEvent; 98 class DeferredEvent;
93 static const double minimumProgressEventDispatchingIntervalInSeconds; 99 static const double minimumProgressEventDispatchingIntervalInSeconds;
94 100
95 void fired() override; 101 void fired() override;
96 void dispatchDeferredEvent(); 102 void dispatchDeferredEvent();
97 103
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 -
100 // this XMLHttpRequestProgressEventThrottle (part) object dies together
101 // with the XMLHttpRequest object.
102 Member<XMLHttpRequest> m_target; 104 Member<XMLHttpRequest> m_target;
103 105
104 // A slot for the deferred "progress" ProgressEvent. When multiple events 106 // A slot for the deferred "progress" ProgressEvent. When multiple events
105 // arrive, only the last one is stored and others are discarded. 107 // arrive, only the last one is stored and others are discarded.
106 const OwnPtr<DeferredEvent> m_deferred; 108 const OwnPtr<DeferredEvent> m_deferred;
109 // True if any "progress" progress event has been dispatched since
110 // |m_target|'s readyState changed.
111 bool m_hasDispatchedProgressProgressEvent;
107 }; 112 };
108 113
109 } // namespace blink 114 } // namespace blink
110 115
111 #endif // XMLHttpRequestProgressEventThrottle_h 116 #endif // XMLHttpRequestProgressEventThrottle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698