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

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

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 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 | « Source/core/workers/WorkerRunLoop.h ('k') | Source/core/workers/WorkerScriptLoader.cpp » ('j') | 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/workers/WorkerRunLoop.h" 32 #include "core/workers/WorkerRunLoop.h"
33 33
34 #include "bindings/v8/WorkerScriptController.h" 34 #include "bindings/v8/WorkerScriptController.h"
35 #include "core/dom/ScriptExecutionContext.h" 35 #include "core/dom/ScriptExecutionContext.h"
36 #include "core/platform/SharedTimer.h" 36 #include "core/platform/SharedTimer.h"
37 #include "core/platform/ThreadGlobalData.h" 37 #include "core/platform/ThreadGlobalData.h"
38 #include "core/platform/ThreadTimers.h" 38 #include "core/platform/ThreadTimers.h"
39 #include "core/workers/WorkerContext.h" 39 #include "core/workers/WorkerGlobalScope.h"
40 #include "core/workers/WorkerThread.h" 40 #include "core/workers/WorkerThread.h"
41 #include <wtf/CurrentTime.h> 41 #include <wtf/CurrentTime.h>
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class WorkerSharedTimer : public SharedTimer { 45 class WorkerSharedTimer : public SharedTimer {
46 public: 46 public:
47 WorkerSharedTimer() 47 WorkerSharedTimer()
48 : m_sharedTimerFunction(0) 48 : m_sharedTimerFunction(0)
49 , m_nextFireTime(0) 49 , m_nextFireTime(0)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ~RunLoopSetup() 120 ~RunLoopSetup()
121 { 121 {
122 m_runLoop.m_nestedCount--; 122 m_runLoop.m_nestedCount--;
123 if (!m_runLoop.m_nestedCount) 123 if (!m_runLoop.m_nestedCount)
124 threadGlobalData().threadTimers().setSharedTimer(0); 124 threadGlobalData().threadTimers().setSharedTimer(0);
125 } 125 }
126 private: 126 private:
127 WorkerRunLoop& m_runLoop; 127 WorkerRunLoop& m_runLoop;
128 }; 128 };
129 129
130 void WorkerRunLoop::run(WorkerContext* context) 130 void WorkerRunLoop::run(WorkerGlobalScope* context)
131 { 131 {
132 RunLoopSetup setup(*this); 132 RunLoopSetup setup(*this);
133 ModePredicate modePredicate(defaultMode()); 133 ModePredicate modePredicate(defaultMode());
134 MessageQueueWaitResult result; 134 MessageQueueWaitResult result;
135 do { 135 do {
136 result = runInMode(context, modePredicate, WaitForMessage); 136 result = runInMode(context, modePredicate, WaitForMessage);
137 } while (result != MessageQueueTerminated); 137 } while (result != MessageQueueTerminated);
138 runCleanupTasks(context); 138 runCleanupTasks(context);
139 } 139 }
140 140
141 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const St ring& mode, WaitMode waitMode) 141 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons t String& mode, WaitMode waitMode)
142 { 142 {
143 RunLoopSetup setup(*this); 143 RunLoopSetup setup(*this);
144 ModePredicate modePredicate(mode); 144 ModePredicate modePredicate(mode);
145 MessageQueueWaitResult result = runInMode(context, modePredicate, waitMode); 145 MessageQueueWaitResult result = runInMode(context, modePredicate, waitMode);
146 return result; 146 return result;
147 } 147 }
148 148
149 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const Mo dePredicate& predicate, WaitMode waitMode) 149 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons t ModePredicate& predicate, WaitMode waitMode)
150 { 150 {
151 ASSERT(context); 151 ASSERT(context);
152 ASSERT(context->thread()); 152 ASSERT(context->thread());
153 ASSERT(context->thread()->isCurrentThread()); 153 ASSERT(context->thread()->isCurrentThread());
154 154
155 double absoluteTime = 0.0; 155 double absoluteTime = 0.0;
156 if (waitMode == WaitForMessage) { 156 if (waitMode == WaitForMessage) {
157 absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime(); 157 absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime();
158 if (m_messageQueue.isEmpty()) { 158 if (m_messageQueue.isEmpty()) {
159 idleNotification(absoluteTime - currentTime()); 159 idleNotification(absoluteTime - currentTime());
(...skipping 16 matching lines...) Expand all
176 176
177 case MessageQueueTimeout: 177 case MessageQueueTimeout:
178 if (!context->isClosing() && currentTime() >= m_sharedTimer->fireTime()) 178 if (!context->isClosing() && currentTime() >= m_sharedTimer->fireTime())
179 m_sharedTimer->fire(); 179 m_sharedTimer->fire();
180 break; 180 break;
181 } 181 }
182 182
183 return result; 183 return result;
184 } 184 }
185 185
186 void WorkerRunLoop::runCleanupTasks(WorkerContext* context) 186 void WorkerRunLoop::runCleanupTasks(WorkerGlobalScope* context)
187 { 187 {
188 ASSERT(context); 188 ASSERT(context);
189 ASSERT(context->thread()); 189 ASSERT(context->thread());
190 ASSERT(context->thread()->isCurrentThread()); 190 ASSERT(context->thread()->isCurrentThread());
191 ASSERT(m_messageQueue.killed()); 191 ASSERT(m_messageQueue.killed());
192 192
193 while (true) { 193 while (true) {
194 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.tryGetMessageIgnoringK illed(); 194 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.tryGetMessageIgnoringK illed();
195 if (!task) 195 if (!task)
196 return; 196 return;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 m_nextIdleNotificationTime = now + m_currentIdleIntervalInSeconds; 236 m_nextIdleNotificationTime = now + m_currentIdleIntervalInSeconds;
237 } 237 }
238 238
239 PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExe cutionContext::Task> task, const String& mode) 239 PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExe cutionContext::Task> task, const String& mode)
240 { 240 {
241 return adoptPtr(new Task(task, mode)); 241 return adoptPtr(new Task(task, mode));
242 } 242 }
243 243
244 void WorkerRunLoop::Task::performTask(const WorkerRunLoop& runLoop, ScriptExecut ionContext* context) 244 void WorkerRunLoop::Task::performTask(const WorkerRunLoop& runLoop, ScriptExecut ionContext* context)
245 { 245 {
246 WorkerContext* workerContext = static_cast<WorkerContext *>(context); 246 WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(conte xt);
247 if ((!workerContext->isClosing() && !runLoop.terminated()) || m_task->isClea nupTask()) 247 if ((!workerGlobalScope->isClosing() && !runLoop.terminated()) || m_task->is CleanupTask())
248 m_task->performTask(context); 248 m_task->performTask(context);
249 } 249 }
250 250
251 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S tring& mode) 251 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S tring& mode)
252 : m_task(task) 252 : m_task(task)
253 , m_mode(mode.isolatedCopy()) 253 , m_mode(mode.isolatedCopy())
254 { 254 {
255 } 255 }
256 256
257 } // namespace WebCore 257 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerRunLoop.h ('k') | Source/core/workers/WorkerScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698