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

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMTimer.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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 DOMTimer::DOMTimer(ExecutionContext* context, ScheduledAction* action, int inter val, bool singleShot, int timeoutID) 69 DOMTimer::DOMTimer(ExecutionContext* context, ScheduledAction* action, int inter val, bool singleShot, int timeoutID)
70 : SuspendableTimer(context) 70 : SuspendableTimer(context)
71 , m_timeoutID(timeoutID) 71 , m_timeoutID(timeoutID)
72 , m_nestingLevel(context->timers()->timerNestingLevel() + 1) 72 , m_nestingLevel(context->timers()->timerNestingLevel() + 1)
73 , m_action(action) 73 , m_action(action)
74 { 74 {
75 ASSERT(timeoutID > 0); 75 ASSERT(timeoutID > 0);
76 if (shouldForwardUserGesture(interval, m_nestingLevel)) 76 if (shouldForwardUserGesture(interval, m_nestingLevel))
77 m_userGestureToken = UserGestureIndicator::currentToken(); 77 m_userGestureToken = UserGestureIndicator::currentToken();
78 78
79 InspectorInstrumentation::asyncTaskScheduled(context, singleShot ? "setTimeo ut" : "setInterval", this, !singleShot);
80
79 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise cond); 81 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise cond);
80 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest ingLevel) 82 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest ingLevel)
81 intervalMilliseconds = minimumInterval; 83 intervalMilliseconds = minimumInterval;
82 if (singleShot) 84 if (singleShot)
83 startOneShot(intervalMilliseconds, BLINK_FROM_HERE); 85 startOneShot(intervalMilliseconds, BLINK_FROM_HERE);
84 else 86 else
85 startRepeating(intervalMilliseconds, BLINK_FROM_HERE); 87 startRepeating(intervalMilliseconds, BLINK_FROM_HERE);
86 } 88 }
87 89
88 DOMTimer::~DOMTimer() 90 DOMTimer::~DOMTimer()
(...skipping 11 matching lines...) Expand all
100 { 102 {
101 ExecutionContext* context = getExecutionContext(); 103 ExecutionContext* context = getExecutionContext();
102 ASSERT(context); 104 ASSERT(context);
103 context->timers()->setTimerNestingLevel(m_nestingLevel); 105 context->timers()->setTimerNestingLevel(m_nestingLevel);
104 ASSERT(!context->activeDOMObjectsAreSuspended()); 106 ASSERT(!context->activeDOMObjectsAreSuspended());
105 // Only the first execution of a multi-shot timer should get an affirmative user gesture indicator. 107 // Only the first execution of a multi-shot timer should get an affirmative user gesture indicator.
106 UserGestureIndicator gestureIndicator(m_userGestureToken.release()); 108 UserGestureIndicator gestureIndicator(m_userGestureToken.release());
107 109
108 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", InspectorTimerFireEve nt::data(context, m_timeoutID)); 110 TRACE_EVENT1("devtools.timeline", "TimerFire", "data", InspectorTimerFireEve nt::data(context, m_timeoutID));
109 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi mer(context, m_timeoutID); 111 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi mer(context, m_timeoutID);
112 InspectorInstrumentation::AsyncTask asyncTask(context, this);
110 113
111 // Simple case for non-one-shot timers. 114 // Simple case for non-one-shot timers.
112 if (isActive()) { 115 if (isActive()) {
113 if (repeatInterval() && repeatInterval() < minimumInterval) { 116 if (repeatInterval() && repeatInterval() < minimumInterval) {
114 m_nestingLevel++; 117 m_nestingLevel++;
115 if (m_nestingLevel >= maxTimerNestingLevel) 118 if (m_nestingLevel >= maxTimerNestingLevel)
116 augmentRepeatInterval(minimumInterval - repeatInterval()); 119 augmentRepeatInterval(minimumInterval - repeatInterval());
117 } 120 }
118 121
119 // No access to member variables after this point, it can delete the tim er. 122 // No access to member variables after this point, it can delete the tim er.
(...skipping 14 matching lines...) Expand all
134 InspectorInstrumentation::didFireTimer(cookie); 137 InspectorInstrumentation::didFireTimer(cookie);
135 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 138 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
136 139
137 // ExecutionContext might be already gone when we executed action->execute() . 140 // ExecutionContext might be already gone when we executed action->execute() .
138 if (getExecutionContext()) 141 if (getExecutionContext())
139 getExecutionContext()->timers()->setTimerNestingLevel(0); 142 getExecutionContext()->timers()->setTimerNestingLevel(0);
140 } 143 }
141 144
142 void DOMTimer::stop() 145 void DOMTimer::stop()
143 { 146 {
147 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this);
144 SuspendableTimer::stop(); 148 SuspendableTimer::stop();
145 // Need to release JS objects potentially protected by ScheduledAction 149 // Need to release JS objects potentially protected by ScheduledAction
146 // because they can form circular references back to the ExecutionContext 150 // because they can form circular references back to the ExecutionContext
147 // which will cause a memory leak. 151 // which will cause a memory leak.
148 m_action.clear(); 152 m_action.clear();
149 } 153 }
150 154
151 WebTaskRunner* DOMTimer::timerTaskRunner() const 155 WebTaskRunner* DOMTimer::timerTaskRunner() const
152 { 156 {
153 return getExecutionContext()->timers()->timerTaskRunner(); 157 return getExecutionContext()->timers()->timerTaskRunner();
154 } 158 }
155 159
156 DEFINE_TRACE(DOMTimer) 160 DEFINE_TRACE(DOMTimer)
157 { 161 {
158 visitor->trace(m_action); 162 visitor->trace(m_action);
159 SuspendableTimer::trace(visitor); 163 SuspendableTimer::trace(visitor);
160 } 164 }
161 165
162 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReader.cpp ('k') | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698