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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/ScriptedIdleTaskController.h" 5 #include "core/dom/ScriptedIdleTaskController.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/dom/IdleRequestCallback.h" 8 #include "core/dom/IdleRequestCallback.h"
9 #include "core/dom/IdleRequestOptions.h" 9 #include "core/dom/IdleRequestOptions.h"
10 #include "core/inspector/InspectorTraceEvents.h" 10 #include "core/inspector/InspectorTraceEvents.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 // Just drop callbacks called while suspended, these will be reposted on the idle task queue when we are resumed. 119 // Just drop callbacks called while suspended, these will be reposted on the idle task queue when we are resumed.
120 return; 120 return;
121 } 121 }
122 122
123 runCallback(id, deadlineSeconds, callbackType); 123 runCallback(id, deadlineSeconds, callbackType);
124 } 124 }
125 125
126 void ScriptedIdleTaskController::runCallback(CallbackId id, double deadlineSecon ds, IdleDeadline::CallbackType callbackType) 126 void ScriptedIdleTaskController::runCallback(CallbackId id, double deadlineSecon ds, IdleDeadline::CallbackType callbackType)
127 { 127 {
128 ASSERT(!m_suspended); 128 DCHECK(!m_suspended);
129 auto callback = m_callbacks.take(id); 129 auto callback = m_callbacks.take(id);
130 if (!callback) 130 if (!callback)
131 return; 131 return;
132 132
133 double allottedTimeMillis = std::max((deadlineSeconds - monotonicallyIncreas ingTime()) * 1000, 0.0); 133 double allottedTimeMillis = std::max((deadlineSeconds - monotonicallyIncreas ingTime()) * 1000, 0.0);
134 134
135 DEFINE_STATIC_LOCAL(CustomCountHistogram, idleCallbackDeadlineHistogram, ("W ebCore.ScriptedIdleTaskController.IdleCallbackDeadline", 0, 50, 50)); 135 DEFINE_STATIC_LOCAL(CustomCountHistogram, idleCallbackDeadlineHistogram, ("W ebCore.ScriptedIdleTaskController.IdleCallbackDeadline", 0, 50, 50));
136 idleCallbackDeadlineHistogram.count(allottedTimeMillis); 136 idleCallbackDeadlineHistogram.count(allottedTimeMillis);
137 137
138 TRACE_EVENT1("devtools.timeline", "FireIdleCallback", 138 TRACE_EVENT1("devtools.timeline", "FireIdleCallback",
(...skipping 11 matching lines...) Expand all
150 m_callbacks.clear(); 150 m_callbacks.clear();
151 } 151 }
152 152
153 void ScriptedIdleTaskController::suspend() 153 void ScriptedIdleTaskController::suspend()
154 { 154 {
155 m_suspended = true; 155 m_suspended = true;
156 } 156 }
157 157
158 void ScriptedIdleTaskController::resume() 158 void ScriptedIdleTaskController::resume()
159 { 159 {
160 ASSERT(m_suspended); 160 DCHECK(m_suspended);
161 m_suspended = false; 161 m_suspended = false;
162 162
163 // Run any pending timeouts. 163 // Run any pending timeouts.
164 Vector<CallbackId> pendingTimeouts; 164 Vector<CallbackId> pendingTimeouts;
165 m_pendingTimeouts.swap(pendingTimeouts); 165 m_pendingTimeouts.swap(pendingTimeouts);
166 for (auto& id : pendingTimeouts) 166 for (auto& id : pendingTimeouts)
167 runCallback(id, monotonicallyIncreasingTime(), IdleDeadline::CallbackTyp e::CalledByTimeout); 167 runCallback(id, monotonicallyIncreasingTime(), IdleDeadline::CallbackTyp e::CalledByTimeout);
168 168
169 // Repost idle tasks for any remaining callbacks. 169 // Repost idle tasks for any remaining callbacks.
170 for (auto& callback : m_callbacks) { 170 for (auto& callback : m_callbacks) {
171 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal: :IdleRequestCallbackWrapper::create(callback.key, this); 171 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal: :IdleRequestCallbackWrapper::create(callback.key, this);
172 m_scheduler->postIdleTask(BLINK_FROM_HERE, WTF::bind<double>(&internal:: IdleRequestCallbackWrapper::idleTaskFired, callbackWrapper)); 172 m_scheduler->postIdleTask(BLINK_FROM_HERE, WTF::bind<double>(&internal:: IdleRequestCallbackWrapper::idleTaskFired, callbackWrapper));
173 } 173 }
174 } 174 }
175 175
176 } // namespace blink 176 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698