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

Side by Side Diff: WebCore/dom/WorkerRunLoop.cpp

Issue 28077: WebKit side of merge from r41149 to r41181. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/WebKit/
Patch Set: Created 11 years, 10 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 | « WebCore/dom/WorkerRunLoop.h ('k') | WebCore/html/HTMLElement.h » ('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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 : m_mode(mode) 91 : m_mode(mode)
92 , m_defaultMode(mode == WorkerRunLoop::defaultMode()) 92 , m_defaultMode(mode == WorkerRunLoop::defaultMode())
93 { 93 {
94 } 94 }
95 95
96 bool isDefaultMode() const 96 bool isDefaultMode() const
97 { 97 {
98 return m_defaultMode; 98 return m_defaultMode;
99 } 99 }
100 100
101 bool operator()(PassRefPtr<WorkerRunLoop::Task> task) 101 bool operator()(PassRefPtr<WorkerRunLoop::Task> task) const
102 { 102 {
103 return m_defaultMode || m_mode == task->mode(); 103 return m_defaultMode || m_mode == task->mode();
104 } 104 }
105 105
106 private: 106 private:
107 String m_mode; 107 String m_mode;
108 bool m_defaultMode; 108 bool m_defaultMode;
109 }; 109 };
110 110
111 WorkerRunLoop::WorkerRunLoop() 111 WorkerRunLoop::WorkerRunLoop()
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 157
158 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const St ring& mode) 158 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const St ring& mode)
159 { 159 {
160 RunLoopSetup setup(*this); 160 RunLoopSetup setup(*this);
161 ModePredicate modePredicate(mode); 161 ModePredicate modePredicate(mode);
162 MessageQueueWaitResult result = runInMode(context, modePredicate); 162 MessageQueueWaitResult result = runInMode(context, modePredicate);
163 return result; 163 return result;
164 } 164 }
165 165
166 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, ModePred icate& predicate) 166 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const Mo dePredicate& predicate)
167 { 167 {
168 ASSERT(context); 168 ASSERT(context);
169 ASSERT(context->thread()); 169 ASSERT(context->thread());
170 ASSERT(context->thread()->threadID() == currentThread()); 170 ASSERT(context->thread()->threadID() == currentThread());
171 171
172 double absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive( )) ? m_sharedTimer->fireTime() : MessageQueue<RefPtr<Task> >::infiniteTime();
172 RefPtr<Task> task; 173 RefPtr<Task> task;
173 MessageQueueWaitResult result; 174 MessageQueueWaitResult result = m_messageQueue.waitForMessageFilteredWithTim eout(task, predicate, absoluteTime);
174 if (predicate.isDefaultMode()) {
175 if (m_sharedTimer->isActive())
176 result = m_messageQueue.waitForMessageTimed(task, m_sharedTimer->fir eTime());
177 else
178 result = m_messageQueue.waitForMessage(task) ? MessageQueueMessageRe ceived : MessageQueueTerminated;
179 } else
180 result = m_messageQueue.waitForMessageFiltered(task, predicate);
181 175
182 switch (result) { 176 switch (result) {
183 case MessageQueueTerminated: 177 case MessageQueueTerminated:
184 break; 178 break;
185 179
186 case MessageQueueMessageReceived: 180 case MessageQueueMessageReceived:
187 task->performTask(context); 181 task->performTask(context);
188 break; 182 break;
189 183
190 case MessageQueueTimeout: 184 case MessageQueueTimeout:
(...skipping 15 matching lines...) Expand all
206 } 200 }
207 201
208 void WorkerRunLoop::postTaskForMode(PassRefPtr<ScriptExecutionContext::Task> tas k, const String& mode) 202 void WorkerRunLoop::postTaskForMode(PassRefPtr<ScriptExecutionContext::Task> tas k, const String& mode)
209 { 203 {
210 m_messageQueue.append(Task::create(task, mode.copy())); 204 m_messageQueue.append(Task::create(task, mode.copy()));
211 } 205 }
212 206
213 } // namespace WebCore 207 } // namespace WebCore
214 208
215 #endif // ENABLE(WORKERS) 209 #endif // ENABLE(WORKERS)
OLDNEW
« no previous file with comments | « WebCore/dom/WorkerRunLoop.h ('k') | WebCore/html/HTMLElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698