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

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

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 reserv ed. 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right reserv ed.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 m_deferred.clear(); 112 m_deferred.clear();
113 stop(); 113 stop();
114 } 114 }
115 115
116 m_hasDispatchedProgressProgressEvent = false; 116 m_hasDispatchedProgressProgressEvent = false;
117 if (state == m_target->readyState()) { 117 if (state == m_target->readyState()) {
118 // We don't dispatch the event when an event handler associated with 118 // We don't dispatch the event when an event handler associated with
119 // the previously dispatched event changes the readyState (e.g. when 119 // the previously dispatched event changes the readyState (e.g. when
120 // the event handler calls xhr.abort()). In such cases a 120 // the event handler calls xhr.abort()). In such cases a
121 // readystatechange should have been already dispatched if necessary. 121 // readystatechange should have been already dispatched if necessary.
122 InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionCont ext(), m_target, m_target->isAsync());
122 m_target->dispatchEvent(event); 123 m_target->dispatchEvent(event);
123 } 124 }
124 } 125 }
125 126
126 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(RawPtr<E vent> progressEvent) 127 void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(RawPtr<E vent> progressEvent)
127 { 128 {
128 XMLHttpRequest::State state = m_target->readyState(); 129 XMLHttpRequest::State state = m_target->readyState();
129 if (m_target->readyState() == XMLHttpRequest::LOADING && m_hasDispatchedProg ressProgressEvent) { 130 if (m_target->readyState() == XMLHttpRequest::LOADING && m_hasDispatchedProg ressProgressEvent) {
130 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect orXhrReadyStateChangeEvent::data(m_target->getExecutionContext(), m_target)); 131 TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", Inspect orXhrReadyStateChangeEvent::data(m_target->getExecutionContext(), m_target));
132 InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionCont ext(), m_target, m_target->isAsync());
131 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)) ; 133 m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)) ;
132 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::d ata()); 134 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::d ata());
133 } 135 }
134 136
135 if (m_target->readyState() != state) 137 if (m_target->readyState() != state)
136 return; 138 return;
137 139
138 m_hasDispatchedProgressProgressEvent = true; 140 m_hasDispatchedProgressProgressEvent = true;
141 InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext( ), m_target, m_target->isAsync());
139 m_target->dispatchEvent(progressEvent); 142 m_target->dispatchEvent(progressEvent);
140 } 143 }
141 144
142 void XMLHttpRequestProgressEventThrottle::fired() 145 void XMLHttpRequestProgressEventThrottle::fired()
143 { 146 {
144 if (!m_deferred.isSet()) { 147 if (!m_deferred.isSet()) {
145 // No "progress" event was queued since the previous dispatch, we can 148 // No "progress" event was queued since the previous dispatch, we can
146 // safely stop the timer. 149 // safely stop the timer.
147 return; 150 return;
148 } 151 }
(...skipping 19 matching lines...) Expand all
168 // event-handler could insert new active DOM objects to the list. 171 // event-handler could insert new active DOM objects to the list.
169 startOneShot(0, BLINK_FROM_HERE); 172 startOneShot(0, BLINK_FROM_HERE);
170 } 173 }
171 174
172 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle) 175 DEFINE_TRACE(XMLHttpRequestProgressEventThrottle)
173 { 176 {
174 visitor->trace(m_target); 177 visitor->trace(m_target);
175 } 178 }
176 179
177 } // namespace blink 180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698