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

Side by Side Diff: Source/core/workers/WorkerRunLoop.cpp

Issue 298383002: Suspend setTimeout callbacks while dedicated worker execution is paused (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed ASSERT condition Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/inspector-protocol/debugger/suspend-setTimeout-on-pause-in-dedicated-worker-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 RunLoopSetup setup(*this, m_context); 172 RunLoopSetup setup(*this, m_context);
173 return run(m_debuggerMessageQueue, waitMode); 173 return run(m_debuggerMessageQueue, waitMode);
174 } 174 }
175 175
176 MessageQueueWaitResult WorkerRunLoop::run(MessageQueue<blink::WebThread::Task>& queue, WaitMode waitMode) 176 MessageQueueWaitResult WorkerRunLoop::run(MessageQueue<blink::WebThread::Task>& queue, WaitMode waitMode)
177 { 177 {
178 ASSERT(m_context); 178 ASSERT(m_context);
179 ASSERT(m_context->thread()); 179 ASSERT(m_context->thread());
180 ASSERT(m_context->thread()->isCurrentThread()); 180 ASSERT(m_context->thread()->isCurrentThread());
181 181
182 bool isDebuggerQueue = (&queue == &m_debuggerMessageQueue);
182 bool nextTimeoutEventIsIdleWatchdog; 183 bool nextTimeoutEventIsIdleWatchdog;
183 MessageQueueWaitResult result; 184 MessageQueueWaitResult result;
184 OwnPtr<blink::WebThread::Task> task; 185 OwnPtr<blink::WebThread::Task> task;
185 do { 186 do {
186 double absoluteTime = 0.0; 187 double absoluteTime = 0.0;
187 nextTimeoutEventIsIdleWatchdog = false; 188 nextTimeoutEventIsIdleWatchdog = false;
188 if (waitMode == WaitForMessage) { 189 if (waitMode == WaitForMessage) {
189 absoluteTime = m_sharedTimer->isActive() ? m_sharedTimer->fireTime() : MessageQueue<blink::WebThread::Task>::infiniteTime(); 190 absoluteTime = !isDebuggerQueue && m_sharedTimer->isActive() ? m_sha redTimer->fireTime() : MessageQueue<blink::WebThread::Task>::infiniteTime();
190 191
191 // Do a script engine idle notification if the next event is distant enough. 192 // Do a script engine idle notification if the next event is distant enough.
192 const double kMinIdleTimespan = 0.3; // seconds 193 const double kMinIdleTimespan = 0.3; // seconds
193 if (queue.isEmpty() && absoluteTime > currentTime() + kMinIdleTimesp an) { 194 if (queue.isEmpty() && absoluteTime > currentTime() + kMinIdleTimesp an) {
194 bool hasMoreWork = !m_context->idleNotification(); 195 bool hasMoreWork = !m_context->idleNotification();
195 if (hasMoreWork) { 196 if (hasMoreWork) {
196 // Schedule a watchdog, so if there are no events within a p articular time interval 197 // Schedule a watchdog, so if there are no events within a p articular time interval
197 // idle notifications won't stop firing. 198 // idle notifications won't stop firing.
198 const double kWatchdogInterval = 3; // seconds 199 const double kWatchdogInterval = 3; // seconds
199 double nextWatchdogTime = currentTime() + kWatchdogInterval; 200 double nextWatchdogTime = currentTime() + kWatchdogInterval;
(...skipping 18 matching lines...) Expand all
218 case MessageQueueTerminated: 219 case MessageQueueTerminated:
219 break; 220 break;
220 221
221 case MessageQueueMessageReceived: 222 case MessageQueueMessageReceived:
222 InspectorInstrumentation::willProcessTask(m_context); 223 InspectorInstrumentation::willProcessTask(m_context);
223 task->run(); 224 task->run();
224 InspectorInstrumentation::didProcessTask(m_context); 225 InspectorInstrumentation::didProcessTask(m_context);
225 break; 226 break;
226 227
227 case MessageQueueTimeout: 228 case MessageQueueTimeout:
229 ASSERT(!isDebuggerQueue || waitMode != WaitForMessage);
228 if (!m_context->isClosing()) 230 if (!m_context->isClosing())
229 m_sharedTimer->fire(); 231 m_sharedTimer->fire();
230 break; 232 break;
231 } 233 }
232 234
233 return result; 235 return result;
234 } 236 }
235 237
236 void WorkerRunLoop::runCleanupTasks() 238 void WorkerRunLoop::runCleanupTasks()
237 { 239 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 272
271 bool WorkerRunLoop::postDebuggerTask(PassOwnPtr<ExecutionContextTask> task) 273 bool WorkerRunLoop::postDebuggerTask(PassOwnPtr<ExecutionContextTask> task)
272 { 274 {
273 bool posted = m_debuggerMessageQueue.append(WorkerRunLoopTask::create(*this, task)); 275 bool posted = m_debuggerMessageQueue.append(WorkerRunLoopTask::create(*this, task));
274 if (posted) 276 if (posted)
275 postTask(TickleDebuggerQueueTask::create(this)); 277 postTask(TickleDebuggerQueueTask::create(this));
276 return posted; 278 return posted;
277 } 279 }
278 280
279 } // namespace WebCore 281 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/inspector-protocol/debugger/suspend-setTimeout-on-pause-in-dedicated-worker-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698