| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/frame/Console.h" | 36 #include "core/frame/Console.h" |
| 37 #include "core/frame/FrameConsole.h" | 37 #include "core/frame/FrameConsole.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/frame/csp/ContentSecurityPolicy.h" | 40 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 41 #include "core/inspector/ConsoleMessage.h" | 41 #include "core/inspector/ConsoleMessage.h" |
| 42 #include "core/inspector/ScriptCallStack.h" | 42 #include "core/inspector/ScriptCallStack.h" |
| 43 #include "core/inspector/WorkerDebuggerAgent.h" | 43 #include "core/inspector/WorkerDebuggerAgent.h" |
| 44 #include "core/loader/DocumentLoadTiming.h" | 44 #include "core/loader/DocumentLoadTiming.h" |
| 45 #include "core/loader/DocumentLoader.h" | 45 #include "core/loader/DocumentLoader.h" |
| 46 #include "core/workers/DedicatedWorkerThread.h" | 46 #include "core/workers/InProcessWorkerBase.h" |
| 47 #include "core/workers/Worker.h" | |
| 48 #include "core/workers/WorkerClients.h" | 47 #include "core/workers/WorkerClients.h" |
| 49 #include "core/workers/WorkerInspectorProxy.h" | 48 #include "core/workers/WorkerInspectorProxy.h" |
| 50 #include "core/workers/WorkerObjectProxy.h" | 49 #include "core/workers/WorkerObjectProxy.h" |
| 51 #include "core/workers/WorkerThreadStartupData.h" | 50 #include "core/workers/WorkerThreadStartupData.h" |
| 52 #include "platform/heap/Handle.h" | 51 #include "platform/heap/Handle.h" |
| 53 #include "wtf/Functional.h" | 52 #include "wtf/Functional.h" |
| 54 #include "wtf/MainThread.h" | 53 #include "wtf/MainThread.h" |
| 55 | 54 |
| 56 namespace blink { | 55 namespace blink { |
| 57 | 56 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 78 globalScope->dispatchEvent(MessageEvent::create(ports.release(), m_messa
ge)); | 77 globalScope->dispatchEvent(MessageEvent::create(ports.release(), m_messa
ge)); |
| 79 m_workerObjectProxy.confirmMessageFromWorkerObject(scriptContext->hasPen
dingActivity()); | 78 m_workerObjectProxy.confirmMessageFromWorkerObject(scriptContext->hasPen
dingActivity()); |
| 80 } | 79 } |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 RefPtr<SerializedScriptValue> m_message; | 82 RefPtr<SerializedScriptValue> m_message; |
| 84 OwnPtr<MessagePortChannelArray> m_channels; | 83 OwnPtr<MessagePortChannelArray> m_channels; |
| 85 WorkerObjectProxy& m_workerObjectProxy; | 84 WorkerObjectProxy& m_workerObjectProxy; |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject, PassOwnPtrWillB
eRawPtr<WorkerClients> workerClients) | 87 WorkerMessagingProxy::WorkerMessagingProxy(InProcessWorkerBase* workerObject, Pa
ssOwnPtrWillBeRawPtr<WorkerClients> workerClients) |
| 89 : m_executionContext(workerObject->executionContext()) | 88 : m_executionContext(workerObject->executionContext()) |
| 90 , m_workerObjectProxy(WorkerObjectProxy::create(m_executionContext.get(), th
is)) | 89 , m_workerObjectProxy(WorkerObjectProxy::create(m_executionContext.get(), th
is)) |
| 91 , m_workerObject(workerObject) | 90 , m_workerObject(workerObject) |
| 92 , m_mayBeDestroyed(false) | 91 , m_mayBeDestroyed(false) |
| 93 , m_unconfirmedMessageCount(0) | 92 , m_unconfirmedMessageCount(0) |
| 94 , m_workerThreadHadPendingActivity(false) | 93 , m_workerThreadHadPendingActivity(false) |
| 95 , m_askedToTerminate(false) | 94 , m_askedToTerminate(false) |
| 96 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 95 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
| 97 , m_workerClients(workerClients) | 96 , m_workerClients(workerClients) |
| 98 { | 97 { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 207 |
| 209 ASSERT(!m_unconfirmedMessageCount); | 208 ASSERT(!m_unconfirmedMessageCount); |
| 210 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); | 209 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); |
| 211 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. | 210 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. |
| 212 | 211 |
| 213 for (auto& earlyTasks : m_queuedEarlyTasks) | 212 for (auto& earlyTasks : m_queuedEarlyTasks) |
| 214 m_workerThread->postTask(FROM_HERE, earlyTasks.release()); | 213 m_workerThread->postTask(FROM_HERE, earlyTasks.release()); |
| 215 m_queuedEarlyTasks.clear(); | 214 m_queuedEarlyTasks.clear(); |
| 216 } | 215 } |
| 217 | 216 |
| 218 PassRefPtr<WorkerThread> WorkerMessagingProxy::createWorkerThread(double originT
ime, PassOwnPtr<WorkerThreadStartupData> startupData) | |
| 219 { | |
| 220 return DedicatedWorkerThread::create(loaderProxy(), workerObjectProxy(), ori
ginTime, startupData); | |
| 221 } | |
| 222 | |
| 223 void WorkerMessagingProxy::workerObjectDestroyed() | 217 void WorkerMessagingProxy::workerObjectDestroyed() |
| 224 { | 218 { |
| 225 m_workerObject = nullptr; | 219 m_workerObject = nullptr; |
| 226 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); | 220 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); |
| 227 } | 221 } |
| 228 | 222 |
| 229 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work
erMessagingProxy* proxy) | 223 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work
erMessagingProxy* proxy) |
| 230 { | 224 { |
| 231 proxy->m_mayBeDestroyed = true; | 225 proxy->m_mayBeDestroyed = true; |
| 232 if (proxy->m_workerThread) | 226 if (proxy->m_workerThread) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 300 |
| 307 // FIXME: This need to be revisited when we support nested worker one day | 301 // FIXME: This need to be revisited when we support nested worker one day |
| 308 ASSERT(m_executionContext->isDocument()); | 302 ASSERT(m_executionContext->isDocument()); |
| 309 Document* document = toDocument(m_executionContext.get()); | 303 Document* document = toDocument(m_executionContext.get()); |
| 310 LocalFrame* frame = document->frame(); | 304 LocalFrame* frame = document->frame(); |
| 311 if (frame) | 305 if (frame) |
| 312 frame->console().adoptWorkerMessagesAfterTermination(this); | 306 frame->console().adoptWorkerMessagesAfterTermination(this); |
| 313 } | 307 } |
| 314 | 308 |
| 315 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |