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

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

Issue 2746333002: DevTools: move recurring flag into AsyncTask, control cancelation from embedder only. (Closed)
Patch Set: using _END now Created 3 years, 9 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> All right 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right
3 * reserved. 3 * reserved.
4 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 stop(); 125 stop();
126 } 126 }
127 127
128 m_hasDispatchedProgressProgressEvent = false; 128 m_hasDispatchedProgressProgressEvent = false;
129 if (state == m_target->readyState()) { 129 if (state == m_target->readyState()) {
130 // We don't dispatch the event when an event handler associated with 130 // We don't dispatch the event when an event handler associated with
131 // the previously dispatched event changes the readyState (e.g. when 131 // the previously dispatched event changes the readyState (e.g. when
132 // the event handler calls xhr.abort()). In such cases a 132 // the event handler calls xhr.abort()). In such cases a
133 // readystatechange should have been already dispatched if necessary. 133 // readystatechange should have been already dispatched if necessary.
134 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, 134 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target,
135 m_target->isAsync()); 135 "progress", m_target->isAsync());
136 m_target->dispatchEvent(event); 136 m_target->dispatchEvent(event);
137 } 137 }
138 } 138 }
139 139
140 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent( 140 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(
141 Event* progressEvent) { 141 Event* progressEvent) {
142 XMLHttpRequest::State state = m_target->readyState(); 142 XMLHttpRequest::State state = m_target->readyState();
143 if (m_target->readyState() == XMLHttpRequest::kLoading && 143 if (m_target->readyState() == XMLHttpRequest::kLoading &&
144 m_hasDispatchedProgressProgressEvent) { 144 m_hasDispatchedProgressProgressEvent) {
145 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", 145 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data",
146 InspectorXhrReadyStateChangeEvent::data( 146 InspectorXhrReadyStateChangeEvent::data(
147 m_target->getExecutionContext(), m_target)); 147 m_target->getExecutionContext(), m_target));
148 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, 148 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target,
149 m_target->isAsync()); 149 "progress", m_target->isAsync());
150 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)); 150 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange));
151 } 151 }
152 152
153 if (m_target->readyState() != state) 153 if (m_target->readyState() != state)
154 return; 154 return;
155 155
156 m_hasDispatchedProgressProgressEvent = true; 156 m_hasDispatchedProgressProgressEvent = true;
157 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, 157 probe::AsyncTask asyncTask(m_target->getExecutionContext(), m_target,
158 m_target->isAsync()); 158 "progress", m_target->isAsync());
159 m_target->dispatchEvent(progressEvent); 159 m_target->dispatchEvent(progressEvent);
160 } 160 }
161 161
162 void XMLHttpRequestProgressEventThrottle::fired() { 162 void XMLHttpRequestProgressEventThrottle::fired() {
163 if (!m_deferred.isSet()) { 163 if (!m_deferred.isSet()) {
164 // No "progress" event was queued since the previous dispatch, we can 164 // No "progress" event was queued since the previous dispatch, we can
165 // safely stop the timer. 165 // safely stop the timer.
166 return; 166 return;
167 } 167 }
168 168
(...skipping 16 matching lines...) Expand all
185 // over the list of SuspendableObjects to resume them, and any activated JS 185 // over the list of SuspendableObjects to resume them, and any activated JS
186 // event-handler could insert new SuspendableObjects to the list. 186 // event-handler could insert new SuspendableObjects to the list.
187 startOneShot(0, BLINK_FROM_HERE); 187 startOneShot(0, BLINK_FROM_HERE);
188 } 188 }
189 189
190 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) { 190 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) {
191 visitor->trace(m_target); 191 visitor->trace(m_target);
192 } 192 }
193 193
194 } // namespace blink 194 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698