| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/workers/ThreadedWorkletObjectProxy.h" | |
| 6 | |
| 7 #include "bindings/core/v8/SerializedScriptValue.h" | |
| 8 #include "bindings/core/v8/SourceLocation.h" | |
| 9 #include "core/dom/Document.h" | |
| 10 #include "core/dom/ExecutionContext.h" | |
| 11 #include "core/dom/ExecutionContextTask.h" | |
| 12 #include "core/inspector/ConsoleMessage.h" | |
| 13 #include "core/workers/ThreadedWorkletMessagingProxy.h" | |
| 14 #include "wtf/Functional.h" | |
| 15 #include "wtf/PtrUtil.h" | |
| 16 #include <memory> | |
| 17 | |
| 18 namespace blink { | |
| 19 | |
| 20 std::unique_ptr<ThreadedWorkletObjectProxy> ThreadedWorkletObjectProxy::create(T
hreadedWorkletMessagingProxy* messagingProxy) | |
| 21 { | |
| 22 DCHECK(messagingProxy); | |
| 23 return wrapUnique(new ThreadedWorkletObjectProxy(messagingProxy)); | |
| 24 } | |
| 25 | |
| 26 void ThreadedWorkletObjectProxy::postTaskToMainExecutionContext(std::unique_ptr<
ExecutionContextTask> task) | |
| 27 { | |
| 28 getExecutionContext()->postTask(BLINK_FROM_HERE, std::move(task)); | |
| 29 } | |
| 30 | |
| 31 void ThreadedWorkletObjectProxy::reportConsoleMessage(MessageSource source, Mess
ageLevel level, const String& message, SourceLocation* location) | |
| 32 { | |
| 33 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&::bl
ink::ThreadedWorkletMessagingProxy::reportConsoleMessage, crossThreadUnretained(
m_messagingProxy), source, level, message, passed(location->clone()))); | |
| 34 } | |
| 35 | |
| 36 void ThreadedWorkletObjectProxy::postMessageToPageInspector(const String& messag
e) | |
| 37 { | |
| 38 DCHECK(getExecutionContext()->isDocument()); | |
| 39 toDocument(getExecutionContext())->postInspectorTask(BLINK_FROM_HERE, create
CrossThreadTask(&::blink::ThreadedWorkletMessagingProxy::postMessageToPageInspec
tor, crossThreadUnretained(m_messagingProxy), message)); | |
| 40 } | |
| 41 | |
| 42 void ThreadedWorkletObjectProxy::didCloseWorkerGlobalScope() | |
| 43 { | |
| 44 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&::bl
ink::ThreadedWorkletMessagingProxy::terminateGlobalScope, crossThreadUnretained(
m_messagingProxy))); | |
| 45 } | |
| 46 | |
| 47 void ThreadedWorkletObjectProxy::didTerminateWorkerThread() | |
| 48 { | |
| 49 // This will terminate the MessagingProxy. | |
| 50 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&Thre
adedWorkletMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messa
gingProxy))); | |
| 51 } | |
| 52 | |
| 53 ThreadedWorkletObjectProxy::ThreadedWorkletObjectProxy(ThreadedWorkletMessagingP
roxy* messagingProxy) | |
| 54 : m_messagingProxy(messagingProxy) | |
| 55 { | |
| 56 } | |
| 57 | |
| 58 ExecutionContext* ThreadedWorkletObjectProxy::getExecutionContext() const | |
| 59 { | |
| 60 DCHECK(m_messagingProxy); | |
| 61 return m_messagingProxy->getExecutionContext(); | |
| 62 } | |
| 63 | |
| 64 } // namespace blink | |
| OLD | NEW |