OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 10 matching lines...) Expand all Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/workers/WorkerObjectProxy.h" | 31 #include "core/workers/InProcessWorkerObjectProxy.h" |
32 | 32 |
33 #include "bindings/core/v8/SerializedScriptValue.h" | 33 #include "bindings/core/v8/SerializedScriptValue.h" |
34 #include "core/dom/CrossThreadTask.h" | 34 #include "core/dom/CrossThreadTask.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/inspector/ConsoleMessage.h" | 37 #include "core/inspector/ConsoleMessage.h" |
38 #include "core/workers/InProcessWorkerMessagingProxy.h" | 38 #include "core/workers/InProcessWorkerMessagingProxy.h" |
39 #include "wtf/Functional.h" | 39 #include "wtf/Functional.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 PassOwnPtr<WorkerObjectProxy> WorkerObjectProxy::create(InProcessWorkerMessaging
Proxy* messagingProxy) | 43 PassOwnPtr<InProcessWorkerObjectProxy> InProcessWorkerObjectProxy::create(InProc
essWorkerMessagingProxy* messagingProxy) |
44 { | 44 { |
45 ASSERT(messagingProxy); | 45 ASSERT(messagingProxy); |
46 return adoptPtr(new WorkerObjectProxy(messagingProxy)); | 46 return adoptPtr(new InProcessWorkerObjectProxy(messagingProxy)); |
47 } | 47 } |
48 | 48 |
49 void WorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptVal
ue> message, PassOwnPtr<MessagePortChannelArray> channels) | 49 void InProcessWorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<Serialized
ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
50 { | 50 { |
51 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::postMessageToWorkerObject, m_messagingProxy, message,
channels)); | 51 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::postMessageToWorkerObject, m_messagingProxy, message,
channels)); |
52 } | 52 } |
53 | 53 |
54 void WorkerObjectProxy::postTaskToMainExecutionContext(PassOwnPtr<ExecutionConte
xtTask> task) | 54 void InProcessWorkerObjectProxy::postTaskToMainExecutionContext(PassOwnPtr<Execu
tionContextTask> task) |
55 { | 55 { |
56 getExecutionContext()->postTask(BLINK_FROM_HERE, task); | 56 getExecutionContext()->postTask(BLINK_FROM_HERE, task); |
57 } | 57 } |
58 | 58 |
59 void WorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingActivity) | 59 void InProcessWorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingA
ctivity) |
60 { | 60 { |
61 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::confirmMessageFromWorkerObject, m_messagingProxy, has
PendingActivity)); | 61 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::confirmMessageFromWorkerObject, m_messagingProxy, has
PendingActivity)); |
62 } | 62 } |
63 | 63 |
64 void WorkerObjectProxy::reportPendingActivity(bool hasPendingActivity) | 64 void InProcessWorkerObjectProxy::reportPendingActivity(bool hasPendingActivity) |
65 { | 65 { |
66 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportPendingActivity, m_messagingProxy, hasPendingAc
tivity)); | 66 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportPendingActivity, m_messagingProxy, hasPendingAc
tivity)); |
67 } | 67 } |
68 | 68 |
69 void WorkerObjectProxy::reportException(const String& errorMessage, int lineNumb
er, int columnNumber, const String& sourceURL, int exceptionId) | 69 void InProcessWorkerObjectProxy::reportException(const String& errorMessage, int
lineNumber, int columnNumber, const String& sourceURL, int exceptionId) |
70 { | 70 { |
71 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportException, m_messagingProxy, errorMessage, line
Number, columnNumber, sourceURL, exceptionId)); | 71 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportException, m_messagingProxy, errorMessage, line
Number, columnNumber, sourceURL, exceptionId)); |
72 } | 72 } |
73 | 73 |
74 void WorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMessage) | 74 void InProcessWorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMes
sage) |
75 { | 75 { |
76 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportConsoleMessage, m_messagingProxy, consoleMessag
e->source(), consoleMessage->level(), consoleMessage->message(), consoleMessage-
>lineNumber(), consoleMessage->url())); | 76 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::reportConsoleMessage, m_messagingProxy, consoleMessag
e->source(), consoleMessage->level(), consoleMessage->message(), consoleMessage-
>lineNumber(), consoleMessage->url())); |
77 } | 77 } |
78 | 78 |
79 void WorkerObjectProxy::postMessageToPageInspector(const String& message) | 79 void InProcessWorkerObjectProxy::postMessageToPageInspector(const String& messag
e) |
80 { | 80 { |
81 ExecutionContext* context = getExecutionContext(); | 81 ExecutionContext* context = getExecutionContext(); |
82 if (context->isDocument()) | 82 if (context->isDocument()) |
83 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea
dTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, m_messagingPro
xy, message)); | 83 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea
dTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, m_messagingPro
xy, message)); |
84 } | 84 } |
85 | 85 |
86 void WorkerObjectProxy::postWorkerConsoleAgentEnabled() | 86 void InProcessWorkerObjectProxy::postWorkerConsoleAgentEnabled() |
87 { | 87 { |
88 ExecutionContext* context = getExecutionContext(); | 88 ExecutionContext* context = getExecutionContext(); |
89 if (context->isDocument()) | 89 if (context->isDocument()) |
90 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea
dTask(&InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled, m_messaging
Proxy)); | 90 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea
dTask(&InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled, m_messaging
Proxy)); |
91 } | 91 } |
92 | 92 |
93 void WorkerObjectProxy::workerGlobalScopeClosed() | 93 void InProcessWorkerObjectProxy::workerGlobalScopeClosed() |
94 { | 94 { |
95 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::terminateWorkerGlobalScope, m_messagingProxy)); | 95 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::terminateWorkerGlobalScope, m_messagingProxy)); |
96 } | 96 } |
97 | 97 |
98 void WorkerObjectProxy::workerThreadTerminated() | 98 void InProcessWorkerObjectProxy::workerThreadTerminated() |
99 { | 99 { |
100 // This will terminate the MessagingProxy. | 100 // This will terminate the MessagingProxy. |
101 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::workerThreadTerminated, m_messagingProxy)); | 101 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::workerThreadTerminated, m_messagingProxy)); |
102 } | 102 } |
103 | 103 |
104 WorkerObjectProxy::WorkerObjectProxy(InProcessWorkerMessagingProxy* messagingPro
xy) | 104 InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(InProcessWorkerMessagingP
roxy* messagingProxy) |
105 : m_messagingProxy(messagingProxy) | 105 : m_messagingProxy(messagingProxy) |
106 { | 106 { |
107 } | 107 } |
108 | 108 |
109 ExecutionContext* WorkerObjectProxy::getExecutionContext() | 109 ExecutionContext* InProcessWorkerObjectProxy::getExecutionContext() |
110 { | 110 { |
111 ASSERT(m_messagingProxy); | 111 ASSERT(m_messagingProxy); |
112 return m_messagingProxy->getExecutionContext(); | 112 return m_messagingProxy->getExecutionContext(); |
113 } | 113 } |
114 | 114 |
115 } // namespace blink | 115 } // namespace blink |
OLD | NEW |