OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #if ENABLE(WORKERS) | 7 #if ENABLE(WORKERS) |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 | 10 |
11 #include "DedicatedWorkerThread.h" | 11 #include "DedicatedWorkerThread.h" |
12 #include "Frame.h" | 12 #include "Frame.h" |
13 #include "FrameLoaderClient.h" | 13 #include "FrameLoaderClient.h" |
14 #include "GenericWorkerTask.h" | 14 #include "GenericWorkerTask.h" |
15 #include "MessagePort.h" | 15 #include "MessagePort.h" |
16 #include "MessagePortChannel.h" | 16 #include "MessagePortChannel.h" |
17 #include "ScriptExecutionContext.h" | 17 #include "ScriptExecutionContext.h" |
18 #include "WorkerContextExecutionProxy.h" | 18 #include "WorkerContextExecutionProxy.h" |
19 #include "WorkerMessagingProxy.h" | 19 #include "WorkerMessagingProxy.h" |
20 #include "Worker.h" | 20 #include "Worker.h" |
21 #include "WorkerContext.h" | 21 #include "WorkerContext.h" |
22 #include <wtf/Threading.h> | 22 #include <wtf/Threading.h> |
23 | 23 |
24 #undef LOG | 24 #undef LOG |
25 | 25 |
26 #include "webkit/glue/webworkerclient_impl.h" | 26 #include "webkit/glue/webworkerclient_impl.h" |
27 | 27 |
28 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 29 #include "webkit/api/public/WebFrameClient.h" |
29 #include "webkit/api/public/WebKit.h" | 30 #include "webkit/api/public/WebKit.h" |
30 #include "webkit/api/public/WebKitClient.h" | 31 #include "webkit/api/public/WebKitClient.h" |
31 #include "webkit/api/public/WebMessagePortChannel.h" | 32 #include "webkit/api/public/WebMessagePortChannel.h" |
32 #include "webkit/api/public/WebString.h" | 33 #include "webkit/api/public/WebString.h" |
33 #include "webkit/api/public/WebURL.h" | 34 #include "webkit/api/public/WebURL.h" |
34 #include "webkit/api/public/WebWorker.h" | 35 #include "webkit/api/public/WebWorker.h" |
35 #include "webkit/api/src/PlatformMessagePortChannel.h" | 36 #include "webkit/api/src/PlatformMessagePortChannel.h" |
36 #include "webkit/glue/glue_util.h" | 37 #include "webkit/glue/glue_util.h" |
37 #include "webkit/glue/webframeloaderclient_impl.h" | 38 #include "webkit/glue/webframeloaderclient_impl.h" |
38 #include "webkit/glue/webframe_impl.h" | 39 #include "webkit/glue/webframe_impl.h" |
39 #include "webkit/glue/webview_delegate.h" | 40 #include "webkit/glue/webview_delegate.h" |
40 #include "webkit/glue/webview_impl.h" | 41 #include "webkit/glue/webview_impl.h" |
41 #include "webkit/glue/webworker_impl.h" | 42 #include "webkit/glue/webworker_impl.h" |
42 | 43 |
| 44 using WebKit::WebFrameClient; |
43 using WebKit::WebMessagePortChannel; | 45 using WebKit::WebMessagePortChannel; |
44 using WebKit::WebMessagePortChannelArray; | 46 using WebKit::WebMessagePortChannelArray; |
45 using WebKit::WebString; | 47 using WebKit::WebString; |
46 using WebKit::WebWorker; | 48 using WebKit::WebWorker; |
47 using WebKit::WebWorkerClient; | 49 using WebKit::WebWorkerClient; |
48 | 50 |
49 // When WebKit creates a WorkerContextProxy object, we check if we're in the | 51 // When WebKit creates a WorkerContextProxy object, we check if we're in the |
50 // renderer or worker process. If the latter, then we just use | 52 // renderer or worker process. If the latter, then we just use |
51 // WebCore::WorkerMessagingProxy. | 53 // WebCore::WorkerMessagingProxy. |
52 // | 54 // |
53 // If we're in the renderer process, then we need use the glue provided | 55 // If we're in the renderer process, then we need use the glue provided |
54 // WebWorker object to talk to the worker process over IPC. The worker process | 56 // WebWorker object to talk to the worker process over IPC. The worker process |
55 // talks to WebCore::Worker* using WorkerObjectProxy, which we implement on | 57 // talks to WebCore::Worker* using WorkerObjectProxy, which we implement on |
56 // WebWorkerClientImpl. | 58 // WebWorkerClientImpl. |
57 // | 59 // |
58 // Note that if we're running each worker in a separate process, then nested | 60 // Note that if we're running each worker in a separate process, then nested |
59 // workers end up using the same codepath as the renderer process. | 61 // workers end up using the same codepath as the renderer process. |
60 WebCore::WorkerContextProxy* WebCore::WorkerContextProxy::create( | 62 WebCore::WorkerContextProxy* WebCore::WorkerContextProxy::create( |
61 WebCore::Worker* worker) { | 63 WebCore::Worker* worker) { |
62 if (!worker->scriptExecutionContext()->isDocument() && | 64 if (!worker->scriptExecutionContext()->isDocument() && |
63 CommandLine::ForCurrentProcess()->HasSwitch( | 65 CommandLine::ForCurrentProcess()->HasSwitch( |
64 L"web-worker-share-processes")) { | 66 L"web-worker-share-processes")) { |
65 return new WebCore::WorkerMessagingProxy(worker); | 67 return new WebCore::WorkerMessagingProxy(worker); |
66 } | 68 } |
67 | 69 |
68 WebWorker* webworker = NULL; | 70 WebWorker* webworker = NULL; |
69 WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker); | 71 WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker); |
70 | 72 |
71 if (worker->scriptExecutionContext()->isDocument()) { | 73 if (worker->scriptExecutionContext()->isDocument()) { |
72 // Get to the RenderView, so that we can tell the browser to create a | |
73 // worker process if necessary. | |
74 WebCore::Document* document = static_cast<WebCore::Document*>( | 74 WebCore::Document* document = static_cast<WebCore::Document*>( |
75 worker->scriptExecutionContext()); | 75 worker->scriptExecutionContext()); |
76 WebFrameLoaderClient* frame_loader_client = | 76 WebFrameImpl* webframe = WebFrameImpl::FromFrame(document->frame()); |
77 static_cast<WebFrameLoaderClient*>( | 77 webworker = webframe->client()->createWorker(webframe, proxy); |
78 document->frame()->loader()->client()); | |
79 WebViewDelegate* webview_delegate = | |
80 frame_loader_client->webframe()->GetWebViewImpl()->delegate(); | |
81 webworker = webview_delegate->CreateWebWorker(proxy); | |
82 } else { | 78 } else { |
83 WebCore::WorkerContextExecutionProxy* current_context = | 79 WebCore::WorkerContextExecutionProxy* current_context = |
84 WebCore::WorkerContextExecutionProxy::retrieve(); | 80 WebCore::WorkerContextExecutionProxy::retrieve(); |
85 if (!current_context) { | 81 if (!current_context) { |
86 NOTREACHED(); | 82 NOTREACHED(); |
87 return NULL; | 83 return NULL; |
88 } | 84 } |
89 | 85 |
90 WebCore::DedicatedWorkerThread* thread = | 86 WebCore::DedicatedWorkerThread* thread = |
91 static_cast<WebCore::DedicatedWorkerThread*>( | 87 static_cast<WebCore::DedicatedWorkerThread*>( |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 392 } |
397 | 393 |
398 void WebWorkerClientImpl::ReportPendingActivityTask( | 394 void WebWorkerClientImpl::ReportPendingActivityTask( |
399 WebCore::ScriptExecutionContext* context, | 395 WebCore::ScriptExecutionContext* context, |
400 WebWorkerClientImpl* this_ptr, | 396 WebWorkerClientImpl* this_ptr, |
401 bool has_pending_activity) { | 397 bool has_pending_activity) { |
402 this_ptr->worker_context_had_pending_activity_ = has_pending_activity; | 398 this_ptr->worker_context_had_pending_activity_ = has_pending_activity; |
403 } | 399 } |
404 | 400 |
405 #endif | 401 #endif |
OLD | NEW |