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

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

Issue 2269513002: Use per-frame task runner in XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make XHRPT own a clone of WebTaskRunner Created 4 years, 3 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // 43 //
44 // readystatechange events also go through this class since ProgressEvents and 44 // readystatechange events also go through this class since ProgressEvents and
45 // readystatechange events affect each other. 45 // readystatechange events affect each other.
46 // 46 //
47 // In the comments for this class: 47 // In the comments for this class:
48 // - "progress" event means an event named "progress" 48 // - "progress" event means an event named "progress"
49 // - ProgressEvent means an event using the ProgressEvent interface defined in 49 // - ProgressEvent means an event using the ProgressEvent interface defined in
50 // the spec. 50 // the spec.
51 class XMLHttpRequestProgressEventThrottle final : public GarbageCollectedFinaliz ed<XMLHttpRequestProgressEventThrottle>, public TimerBase { 51 class XMLHttpRequestProgressEventThrottle final : public GarbageCollectedFinaliz ed<XMLHttpRequestProgressEventThrottle>, public TimerBase {
52 public: 52 public:
53 static XMLHttpRequestProgressEventThrottle* create(XMLHttpRequest* eventTarg et) 53 static XMLHttpRequestProgressEventThrottle* create(XMLHttpRequest* eventTarg et);
54 {
55 return new XMLHttpRequestProgressEventThrottle(eventTarget);
56 }
57 ~XMLHttpRequestProgressEventThrottle() override; 54 ~XMLHttpRequestProgressEventThrottle() override;
58 55
59 enum DeferredEventAction { 56 enum DeferredEventAction {
60 Ignore, 57 Ignore,
61 Clear, 58 Clear,
62 Flush, 59 Flush,
63 }; 60 };
64 61
65 // Dispatches a ProgressEvent. 62 // Dispatches a ProgressEvent.
66 // 63 //
(...skipping 11 matching lines...) Expand all
78 void dispatchReadyStateChangeEvent(Event*, DeferredEventAction); 75 void dispatchReadyStateChangeEvent(Event*, DeferredEventAction);
79 76
80 void suspend(); 77 void suspend();
81 void resume(); 78 void resume();
82 79
83 // Need to promptly stop this timer when it is deemed finalizable. 80 // Need to promptly stop this timer when it is deemed finalizable.
84 EAGERLY_FINALIZE(); 81 EAGERLY_FINALIZE();
85 DECLARE_TRACE(); 82 DECLARE_TRACE();
86 83
87 private: 84 private:
88 explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest*); 85 XMLHttpRequestProgressEventThrottle(XMLHttpRequest*, std::unique_ptr<WebTask Runner>);
89 86
90 // Dispatches a "progress" progress event and usually a readyStateChange 87 // Dispatches a "progress" progress event and usually a readyStateChange
91 // event as well. 88 // event as well.
92 void dispatchProgressProgressEvent(Event*); 89 void dispatchProgressProgressEvent(Event*);
93 90
94 // The main purpose of this class is to throttle the "progress" 91 // The main purpose of this class is to throttle the "progress"
95 // ProgressEvent dispatching. This class represents such a deferred 92 // ProgressEvent dispatching. This class represents such a deferred
96 // "progress" ProgressEvent. 93 // "progress" ProgressEvent.
97 class DeferredEvent { 94 class DeferredEvent {
98 public: 95 public:
99 DeferredEvent(); 96 DeferredEvent();
100 void set(bool lengthComputable, unsigned long long loaded, unsigned long long total); 97 void set(bool lengthComputable, unsigned long long loaded, unsigned long long total);
101 void clear(); 98 void clear();
102 bool isSet() const { return m_isSet; } 99 bool isSet() const { return m_isSet; }
103 Event* take(); 100 Event* take();
104 101
105 private: 102 private:
106 unsigned long long m_loaded; 103 unsigned long long m_loaded;
107 unsigned long long m_total; 104 unsigned long long m_total;
108 bool m_lengthComputable; 105 bool m_lengthComputable;
109 106
110 bool m_isSet; 107 bool m_isSet;
111 }; 108 };
112 109
113 void fired() override; 110 void fired() override;
114 111
112 std::unique_ptr<WebTaskRunner> m_taskRunner;
yhirano 2016/08/25 04:28:25 Please add some comments describing why this is ne
tzik 2016/08/29 02:08:59 Done.
115 Member<XMLHttpRequest> m_target; 113 Member<XMLHttpRequest> m_target;
116 114
117 // A slot for the deferred "progress" ProgressEvent. When multiple events 115 // A slot for the deferred "progress" ProgressEvent. When multiple events
118 // arrive, only the last one is stored and others are discarded. 116 // arrive, only the last one is stored and others are discarded.
119 DeferredEvent m_deferred; 117 DeferredEvent m_deferred;
120 118
121 // True if any "progress" progress event has been dispatched since 119 // True if any "progress" progress event has been dispatched since
122 // |m_target|'s readyState changed. 120 // |m_target|'s readyState changed.
123 bool m_hasDispatchedProgressProgressEvent; 121 bool m_hasDispatchedProgressProgressEvent;
124 }; 122 };
125 123
126 } // namespace blink 124 } // namespace blink
127 125
128 #endif // XMLHttpRequestProgressEventThrottle_h 126 #endif // XMLHttpRequestProgressEventThrottle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698