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

Side by Side Diff: webkit/api/src/WebWorkerImpl.h

Issue 337057: Move webworker{client}_impl.{h,cc} into webkit/api/src (Closed)
Patch Set: mulitple workers per process comment fixed Created 11 years, 1 month 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
« no previous file with comments | « webkit/api/src/WebWorkerClientImpl.cpp ('k') | webkit/api/src/WebWorkerImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 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 #ifndef WebWorkerImpl_h
32 #define WebWorkerImpl_h
33
34 #include "WebWorker.h"
35
36 #if ENABLE(WORKERS)
37
38 #include "ScriptExecutionContext.h"
39 #include "WorkerLoaderProxy.h"
40 #include "WorkerObjectProxy.h"
41 #include <wtf/PassOwnPtr.h>
42 #include <wtf/RefPtr.h>
43
44 namespace WebCore {
45 class WorkerThread;
46 }
47
48 namespace WebKit {
49 class WebView;
50
51 // This class is used by the worker process code to talk to the WebCore::Worker
52 // implementation. It can't use it directly since it uses WebKit types, so this
53 // class converts the data types. When the WebCore::Worker object wants to call
54 // WebCore::WorkerObjectProxy, this class will conver to Chrome data types first
55 // and then call the supplied WebWorkerClient.
56 class WebWorkerImpl : public WebCore::WorkerObjectProxy
57 , public WebCore::WorkerLoaderProxy
58 , public WebWorker {
59 public:
60 explicit WebWorkerImpl(WebWorkerClient* client);
61
62 // WebCore::WorkerObjectProxy methods:
63 virtual void postMessageToWorkerObject(
64 PassRefPtr<WebCore::SerializedScriptValue>,
65 PassOwnPtr<WebCore::MessagePortChannelArray>);
66 virtual void postExceptionToWorkerObject(
67 const WebCore::String&, int, const WebCore::String&);
68 virtual void postConsoleMessageToWorkerObject(
69 WebCore::MessageDestination, WebCore::MessageSource, WebCore::MessageType,
70 WebCore::MessageLevel, const WebCore::String&, int, const WebCore::String&);
71 virtual void confirmMessageFromWorkerObject(bool);
72 virtual void reportPendingActivity(bool);
73 virtual void workerContextDestroyed();
74
75 // WebCore::WorkerLoaderProxy methods:
76 virtual void postTaskToLoader(PassRefPtr<WebCore::ScriptExecutionContext::Task>);
77 virtual void postTaskForModeToWorkerContext(
78 PassRefPtr<WebCore::ScriptExecutionContext::Task>, const WebCore::String& mode);
79
80 // WebWorker methods:
81 virtual void startWorkerContext(const WebURL&, const WebString&, const WebString&);
82 virtual void terminateWorkerContext();
83 virtual void postMessageToWorkerContext(const WebString&, const WebMessagePortChannelArray&);
84 virtual void workerObjectDestroyed();
85 virtual void clientDestroyed();
86
87 WebWorkerClient* client() {return m_client;}
88
89 // Executes the given task on the main thread.
90 static void dispatchTaskToMainThread(PassRefPtr<WebCore::ScriptExecutionContext::Task>);
91
92 private:
93 virtual ~WebWorkerImpl();
94
95 // Tasks that are run on the worker thread.
96 static void postMessageToWorkerContextTask(
97 WebCore::ScriptExecutionContext* context,
98 WebWorkerImpl* thisPtr,
99 const WebCore::String& message,
100 PassOwnPtr<WebCore::MessagePortChannelArray> channels);
101
102 // Function used to invoke tasks on the main thread.
103 static void invokeTaskMethod(void*);
104
105 // Tasks that are run on the main thread.
106 static void postMessageTask(
107 WebCore::ScriptExecutionContext* context,
108 WebWorkerImpl* thisPtr,
109 WebCore::String message,
110 PassOwnPtr<WebCore::MessagePortChannelArray> channels);
111 static void postExceptionTask(
112 WebCore::ScriptExecutionContext* context,
113 WebWorkerImpl* thisPtr,
114 const WebCore::String& message,
115 int lineNumber,
116 const WebCore::String& sourceURL);
117 static void postConsoleMessageTask(
118 WebCore::ScriptExecutionContext* context,
119 WebWorkerImpl* thisPtr,
120 int destination,
121 int source,
122 int type,
123 int level,
124 const WebCore::String& message,
125 int lineNumber,
126 const WebCore::String& sourceURL);
127 static void confirmMessageTask(
128 WebCore::ScriptExecutionContext* context,
129 WebWorkerImpl* thisPtr,
130 bool hasPendingActivity);
131 static void reportPendingActivityTask(
132 WebCore::ScriptExecutionContext* context,
133 WebWorkerImpl* thisPtr,
134 bool hasPendingActivity);
135 static void workerContextDestroyedTask(
136 WebCore::ScriptExecutionContext* context,
137 WebWorkerImpl* thisPtr);
138
139 WebWorkerClient* m_client;
140
141 // 'shadow page' - created to proxy loading requests from the worker.
142 RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument;
143 WebView* m_webView;
144 bool m_askedToTerminate;
145
146 RefPtr<WebCore::WorkerThread> m_workerThread;
147 };
148
149 } // namespace WebKit
150
151 #endif // ENABLE(WORKERS)
152
153 #endif
OLDNEW
« no previous file with comments | « webkit/api/src/WebWorkerClientImpl.cpp ('k') | webkit/api/src/WebWorkerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698