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

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

Issue 1217803002: Protect readystatechange event dispatch on XMLHttpRequest. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months 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 | Annotate | Revision Log
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 18 matching lines...) Expand all
29 29
30 #include "platform/Timer.h" 30 #include "platform/Timer.h"
31 #include "platform/heap/Handle.h" 31 #include "platform/heap/Handle.h"
32 #include "wtf/Forward.h" 32 #include "wtf/Forward.h"
33 #include "wtf/OwnPtr.h" 33 #include "wtf/OwnPtr.h"
34 #include "wtf/PassRefPtr.h" 34 #include "wtf/PassRefPtr.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class Event; 38 class Event;
39 class EventTarget; 39 class XMLHttpRequest;
40 40
41 // This class implements the XHR2 ProgressEvent dispatching: 41 // This class implements the XHR2 ProgressEvent dispatching:
42 // "dispatch a progress event named progress about every 50ms or for every 42 // "dispatch a progress event named progress about every 50ms or for every
43 // byte received, whichever is least frequent". 43 // byte received, whichever is least frequent".
44 // 44 //
45 // readystatechange events also go through this class since ProgressEvents and 45 // readystatechange events also go through this class since ProgressEvents and
46 // readystatechange events affect each other. 46 // readystatechange events affect each other.
47 // 47 //
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(Ev entTarget* 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 virtual ~XMLHttpRequestProgressEventThrottle();
59 59
60 enum DeferredEventAction { 60 enum DeferredEventAction {
61 Ignore, 61 Ignore,
62 Clear, 62 Clear,
63 Flush, 63 Flush,
64 }; 64 };
(...skipping 12 matching lines...) Expand all
77 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, DeferredEv entAction); 77 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, DeferredEv entAction);
78 78
79 void suspend(); 79 void suspend();
80 void resume(); 80 void resume();
81 81
82 // Need to promptly stop this timer when it is deemed finalizable. 82 // Need to promptly stop this timer when it is deemed finalizable.
83 EAGERLY_FINALIZE(); 83 EAGERLY_FINALIZE();
84 DECLARE_TRACE(); 84 DECLARE_TRACE();
85 85
86 private: 86 private:
87 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); 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 virtual 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<EventTarget> 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
OLDNEW
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.cpp ('k') | Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698