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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkerObjectProxy.cpp

Issue 1897193002: Worker: Rename worker components to clarify what they work for (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "core/workers/WorkerObjectProxy.h"
32
33 #include "bindings/core/v8/SerializedScriptValue.h"
34 #include "core/dom/CrossThreadTask.h"
35 #include "core/dom/Document.h"
36 #include "core/dom/ExecutionContext.h"
37 #include "core/inspector/ConsoleMessage.h"
38 #include "core/workers/InProcessWorkerMessagingProxy.h"
39 #include "wtf/Functional.h"
40
41 namespace blink {
42
43 PassOwnPtr<WorkerObjectProxy> WorkerObjectProxy::create(InProcessWorkerMessaging Proxy* messagingProxy)
44 {
45 ASSERT(messagingProxy);
46 return adoptPtr(new WorkerObjectProxy(messagingProxy));
47 }
48
49 void WorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptVal ue> message, PassOwnPtr<MessagePortChannelArray> channels)
50 {
51 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::postMessageToWorkerObject, m_messagingProxy, message, channels));
52 }
53
54 void WorkerObjectProxy::postTaskToMainExecutionContext(PassOwnPtr<ExecutionConte xtTask> task)
55 {
56 getExecutionContext()->postTask(BLINK_FROM_HERE, task);
57 }
58
59 void WorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingActivity)
60 {
61 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::confirmMessageFromWorkerObject, m_messagingProxy, has PendingActivity));
62 }
63
64 void WorkerObjectProxy::reportPendingActivity(bool hasPendingActivity)
65 {
66 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportPendingActivity, m_messagingProxy, hasPendingAc tivity));
67 }
68
69 void WorkerObjectProxy::reportException(const String& errorMessage, int lineNumb er, int columnNumber, const String& sourceURL, int exceptionId)
70 {
71 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportException, m_messagingProxy, errorMessage, line Number, columnNumber, sourceURL, exceptionId));
72 }
73
74 void WorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMessage)
75 {
76 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportConsoleMessage, m_messagingProxy, consoleMessag e->source(), consoleMessage->level(), consoleMessage->message(), consoleMessage- >lineNumber(), consoleMessage->url()));
77 }
78
79 void WorkerObjectProxy::postMessageToPageInspector(const String& message)
80 {
81 ExecutionContext* context = getExecutionContext();
82 if (context->isDocument())
83 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, m_messagingPro xy, message));
84 }
85
86 void WorkerObjectProxy::postWorkerConsoleAgentEnabled()
87 {
88 ExecutionContext* context = getExecutionContext();
89 if (context->isDocument())
90 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled, m_messaging Proxy));
91 }
92
93 void WorkerObjectProxy::workerGlobalScopeClosed()
94 {
95 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::terminateWorkerGlobalScope, m_messagingProxy));
96 }
97
98 void WorkerObjectProxy::workerThreadTerminated()
99 {
100 // This will terminate the MessagingProxy.
101 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::workerThreadTerminated, m_messagingProxy));
102 }
103
104 WorkerObjectProxy::WorkerObjectProxy(InProcessWorkerMessagingProxy* messagingPro xy)
105 : m_messagingProxy(messagingProxy)
106 {
107 }
108
109 ExecutionContext* WorkerObjectProxy::getExecutionContext()
110 {
111 ASSERT(m_messagingProxy);
112 return m_messagingProxy->getExecutionContext();
113 }
114
115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerObjectProxy.h ('k') | third_party/WebKit/Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698