OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/worker/webworkerclient_proxy.h" | 5 #include "content/worker/webworkerclient_proxy.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "content/common/content_switches.h" | 9 #include "content/common/content_switches.h" |
10 #include "content/common/file_system/file_system_dispatcher.h" | 10 #include "content/common/file_system/file_system_dispatcher.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 using WebKit::WebWorkerClient; | 36 using WebKit::WebWorkerClient; |
37 | 37 |
38 // How long to wait for worker to finish after it's been told to terminate. | 38 // How long to wait for worker to finish after it's been told to terminate. |
39 #define kMaxTimeForRunawayWorkerMs 3000 | 39 #define kMaxTimeForRunawayWorkerMs 3000 |
40 | 40 |
41 WebWorkerClientProxy::WebWorkerClientProxy(int route_id, | 41 WebWorkerClientProxy::WebWorkerClientProxy(int route_id, |
42 WebWorkerStubBase* stub) | 42 WebWorkerStubBase* stub) |
43 : route_id_(route_id), | 43 : route_id_(route_id), |
44 appcache_host_id_(0), | 44 appcache_host_id_(0), |
45 stub_(stub), | 45 stub_(stub), |
46 ALLOW_THIS_IN_INITIALIZER_LIST(kill_process_factory_(this)) { | 46 ALLOW_THIS_IN_INITIALIZER_LIST(kill_process_factory_(this)), |
47 devtools_delegate_(0) { | |
jam
2011/05/25 17:50:12
nit: chrome style is to use NULL for pointers
yurys
2011/05/26 09:11:49
Done.
| |
47 } | 48 } |
48 | 49 |
49 WebWorkerClientProxy::~WebWorkerClientProxy() { | 50 WebWorkerClientProxy::~WebWorkerClientProxy() { |
50 } | 51 } |
51 | 52 |
52 void WebWorkerClientProxy::postMessageToWorkerObject( | 53 void WebWorkerClientProxy::postMessageToWorkerObject( |
53 const WebString& message, | 54 const WebString& message, |
54 const WebMessagePortChannelArray& channels) { | 55 const WebMessagePortChannelArray& channels) { |
55 std::vector<int> message_port_ids(channels.size()); | 56 std::vector<int> message_port_ids(channels.size()); |
56 std::vector<int> routing_ids(channels.size()); | 57 std::vector<int> routing_ids(channels.size()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 void WebWorkerClientProxy::openFileSystem( | 167 void WebWorkerClientProxy::openFileSystem( |
167 WebKit::WebFileSystem::Type type, | 168 WebKit::WebFileSystem::Type type, |
168 long long size, | 169 long long size, |
169 bool create, | 170 bool create, |
170 WebKit::WebFileSystemCallbacks* callbacks) { | 171 WebKit::WebFileSystemCallbacks* callbacks) { |
171 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( | 172 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
172 stub_->url().GetOrigin(), static_cast<fileapi::FileSystemType>(type), | 173 stub_->url().GetOrigin(), static_cast<fileapi::FileSystemType>(type), |
173 size, create, new WebFileSystemCallbackDispatcher(callbacks)); | 174 size, create, new WebFileSystemCallbackDispatcher(callbacks)); |
174 } | 175 } |
175 | 176 |
177 void WebWorkerClientProxy::dispatchDevToolsMessage(const WebString& message) { | |
178 if (devtools_delegate_) | |
179 devtools_delegate_->SendDevToolsMessage(message); | |
180 } | |
181 | |
182 void WebWorkerClientProxy::set_devtools_delegate(DevToolsDelegate* delegate) { | |
jam
2011/05/25 17:50:12
note: chrome style is to put simple getters/setter
yurys
2011/05/26 09:11:49
Done.
| |
183 devtools_delegate_ = delegate; | |
184 } | |
185 | |
176 bool WebWorkerClientProxy::Send(IPC::Message* message) { | 186 bool WebWorkerClientProxy::Send(IPC::Message* message) { |
177 return WorkerThread::current()->Send(message); | 187 return WorkerThread::current()->Send(message); |
178 } | 188 } |
179 | 189 |
180 void WebWorkerClientProxy::EnsureWorkerContextTerminates() { | 190 void WebWorkerClientProxy::EnsureWorkerContextTerminates() { |
181 // Avoid a worker doing a while(1) from never exiting. | 191 // Avoid a worker doing a while(1) from never exiting. |
182 if (CommandLine::ForCurrentProcess()->HasSwitch( | 192 if (CommandLine::ForCurrentProcess()->HasSwitch( |
183 switches::kWebWorkerShareProcesses)) { | 193 switches::kWebWorkerShareProcesses)) { |
184 // Can't kill the process since there could be workers from other | 194 // Can't kill the process since there could be workers from other |
185 // renderer process. | 195 // renderer process. |
186 NOTIMPLEMENTED(); | 196 NOTIMPLEMENTED(); |
187 return; | 197 return; |
188 } | 198 } |
189 | 199 |
190 // This shuts down the process cleanly from the perspective of the browser | 200 // This shuts down the process cleanly from the perspective of the browser |
191 // process, and avoids the crashed worker infobar from appearing to the new | 201 // process, and avoids the crashed worker infobar from appearing to the new |
192 // page. It's ok to post several of theese, because the first executed task | 202 // page. It's ok to post several of theese, because the first executed task |
193 // will exit the message loop and subsequent ones won't be executed. | 203 // will exit the message loop and subsequent ones won't be executed. |
194 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 204 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
195 kill_process_factory_.NewRunnableMethod( | 205 kill_process_factory_.NewRunnableMethod( |
196 &WebWorkerClientProxy::workerContextDestroyed), | 206 &WebWorkerClientProxy::workerContextDestroyed), |
197 kMaxTimeForRunawayWorkerMs); | 207 kMaxTimeForRunawayWorkerMs); |
198 } | 208 } |
OLD | NEW |