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

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

Issue 1018863002: compositor-worker: Introduce CompositorWorker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 9 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/WorkerMessagingProxy.h ('k') | Source/core/workers/WorkerThread.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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Worker.terminate() could be called from JS before the thread was crea ted. 118 // Worker.terminate() could be called from JS before the thread was crea ted.
119 return; 119 return;
120 } 120 }
121 Document* document = toDocument(m_executionContext.get()); 121 Document* document = toDocument(m_executionContext.get());
122 SecurityOrigin* starterOrigin = document->securityOrigin(); 122 SecurityOrigin* starterOrigin = document->securityOrigin();
123 123
124 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, document->co ntentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->de precatedHeaderType(), starterOrigin, m_workerClients.release()); 124 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, document->co ntentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->de precatedHeaderType(), starterOrigin, m_workerClients.release());
125 double originTime = document->loader() ? document->loader()->timing().refere nceMonotonicTime() : monotonicallyIncreasingTime(); 125 double originTime = document->loader() ? document->loader()->timing().refere nceMonotonicTime() : monotonicallyIncreasingTime();
126 126
127 m_loaderProxy = WorkerLoaderProxy::create(this); 127 m_loaderProxy = WorkerLoaderProxy::create(this);
128 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(m_loade rProxy, *m_workerObjectProxy.get(), originTime, startupData.release()); 128 RefPtr<WorkerThread> thread = createWorkerThread(originTime, startupData.rel ease());
129 thread->start(); 129 thread->start();
130 workerThreadCreated(thread); 130 workerThreadCreated(thread);
131 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work erThread.get(), scriptURL); 131 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work erThread.get(), scriptURL);
132 } 132 }
133 133
134 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript Value> message, PassOwnPtr<MessagePortChannelArray> channels) 134 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript Value> message, PassOwnPtr<MessagePortChannelArray> channels)
135 { 135 {
136 if (!m_workerObject || m_askedToTerminate) 136 if (!m_workerObject || m_askedToTerminate)
137 return; 137 return;
138 138
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 Document* document = toDocument(m_executionContext.get()); 192 Document* document = toDocument(m_executionContext.get());
193 LocalFrame* frame = document->frame(); 193 LocalFrame* frame = document->frame();
194 if (!frame) 194 if (!frame)
195 return; 195 return;
196 196
197 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(s ource, level, message, sourceURL, lineNumber); 197 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(s ource, level, message, sourceURL, lineNumber);
198 consoleMessage->setWorkerGlobalScopeProxy(this); 198 consoleMessage->setWorkerGlobalScopeProxy(this);
199 frame->console().addMessage(consoleMessage.release()); 199 frame->console().addMessage(consoleMessage.release());
200 } 200 }
201 201
202 void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<DedicatedWorkerThread> workerThread) 202 void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<WorkerThread> workerTh read)
203 { 203 {
204 ASSERT(!m_askedToTerminate); 204 ASSERT(!m_askedToTerminate);
205 m_workerThread = workerThread; 205 m_workerThread = workerThread;
206 206
207 ASSERT(!m_unconfirmedMessageCount); 207 ASSERT(!m_unconfirmedMessageCount);
208 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); 208 m_unconfirmedMessageCount = m_queuedEarlyTasks.size();
209 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe nding activity. 209 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe nding activity.
210 210
211 for (auto& earlyTasks : m_queuedEarlyTasks) 211 for (auto& earlyTasks : m_queuedEarlyTasks)
212 m_workerThread->postTask(FROM_HERE, earlyTasks.release()); 212 m_workerThread->postTask(FROM_HERE, earlyTasks.release());
213 m_queuedEarlyTasks.clear(); 213 m_queuedEarlyTasks.clear();
214 } 214 }
215 215
216 PassRefPtr<WorkerThread> WorkerMessagingProxy::createWorkerThread(double originT ime, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData)
217 {
218 return DedicatedWorkerThread::create(loaderProxy(), workerObjectProxy(), ori ginTime, startupData);
219 }
220
216 void WorkerMessagingProxy::workerObjectDestroyed() 221 void WorkerMessagingProxy::workerObjectDestroyed()
217 { 222 {
218 m_workerObject = nullptr; 223 m_workerObject = nullptr;
219 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD estroyedInternal, AllowCrossThreadAccess(this))); 224 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD estroyedInternal, AllowCrossThreadAccess(this)));
220 } 225 }
221 226
222 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work erMessagingProxy* proxy) 227 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work erMessagingProxy* proxy)
223 { 228 {
224 proxy->m_mayBeDestroyed = true; 229 proxy->m_mayBeDestroyed = true;
225 if (proxy->m_workerThread) 230 if (proxy->m_workerThread)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 304
300 // FIXME: This need to be revisited when we support nested worker one day 305 // FIXME: This need to be revisited when we support nested worker one day
301 ASSERT(m_executionContext->isDocument()); 306 ASSERT(m_executionContext->isDocument());
302 Document* document = toDocument(m_executionContext.get()); 307 Document* document = toDocument(m_executionContext.get());
303 LocalFrame* frame = document->frame(); 308 LocalFrame* frame = document->frame();
304 if (frame) 309 if (frame)
305 frame->console().adoptWorkerMessagesAfterTermination(this); 310 frame->console().adoptWorkerMessagesAfterTermination(this);
306 } 311 }
307 312
308 } // namespace blink 313 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerMessagingProxy.h ('k') | Source/core/workers/WorkerThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698