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 toDocument(getExecutionContext())->postInspectorTask(BLINK_FROM_HERE, create CrossThreadTask(&::blink::ThreadedWorkletMessagingProxy::postMessageToPageInspec tor, crossThreadUnretained(m_messagingProxy), message)); | |
majidvp
2016/09/14 20:06:31
nit: Are we confident this will always be a Docume
ikilpatrick
2016/09/14 21:54:51
Done.
| |
39 } | |
40 | |
41 void ThreadedWorkletObjectProxy::didCloseWorkerGlobalScope() | |
42 { | |
43 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&::bl ink::ThreadedWorkletMessagingProxy::terminateGlobalScope, crossThreadUnretained( m_messagingProxy))); | |
44 } | |
45 | |
46 void ThreadedWorkletObjectProxy::didTerminateWorkerThread() | |
47 { | |
48 // This will terminate the MessagingProxy. | |
49 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&Thre adedWorkletMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messa gingProxy))); | |
50 } | |
51 | |
52 ThreadedWorkletObjectProxy::ThreadedWorkletObjectProxy(ThreadedWorkletMessagingP roxy* messagingProxy) | |
53 : m_messagingProxy(messagingProxy) | |
54 { | |
55 } | |
56 | |
57 ExecutionContext* ThreadedWorkletObjectProxy::getExecutionContext() const | |
58 { | |
59 DCHECK(m_messagingProxy); | |
60 return m_messagingProxy->getExecutionContext(); | |
61 } | |
62 | |
63 } // namespace blink | |
OLD | NEW |