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 "chrome/worker/webworkerclient_proxy.h" | 5 #include "chrome/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 "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/file_system/file_system_dispatcher.h" |
| 11 #include "chrome/common/file_system/webfilesystem_callback_dispatcher.h" |
10 #include "chrome/common/webmessageportchannel_impl.h" | 12 #include "chrome/common/webmessageportchannel_impl.h" |
11 #include "chrome/common/worker_messages.h" | 13 #include "chrome/common/worker_messages.h" |
12 #include "chrome/renderer/webworker_proxy.h" | 14 #include "chrome/renderer/webworker_proxy.h" |
13 #include "chrome/worker/webworker_stub_base.h" | 15 #include "chrome/worker/webworker_stub_base.h" |
14 #include "chrome/worker/worker_thread.h" | 16 #include "chrome/worker/worker_thread.h" |
15 #include "chrome/worker/worker_webapplicationcachehost_impl.h" | 17 #include "chrome/worker/worker_webapplicationcachehost_impl.h" |
16 #include "ipc/ipc_logging.h" | 18 #include "ipc/ipc_logging.h" |
| 19 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebWorker.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebWorker.h" |
20 | 23 |
21 using WebKit::WebApplicationCacheHost; | 24 using WebKit::WebApplicationCacheHost; |
22 using WebKit::WebMessagePortChannel; | 25 using WebKit::WebMessagePortChannel; |
23 using WebKit::WebMessagePortChannelArray; | 26 using WebKit::WebMessagePortChannelArray; |
24 using WebKit::WebString; | 27 using WebKit::WebString; |
25 using WebKit::WebWorker; | 28 using WebKit::WebWorker; |
26 using WebKit::WebWorkerClient; | 29 using WebKit::WebWorkerClient; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 WebKit::WebApplicationCacheHostClient* client) { | 117 WebKit::WebApplicationCacheHostClient* client) { |
115 WorkerWebApplicationCacheHostImpl* host = | 118 WorkerWebApplicationCacheHostImpl* host = |
116 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), | 119 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), |
117 client); | 120 client); |
118 // Remember the id of the instance we create so we have access to that | 121 // Remember the id of the instance we create so we have access to that |
119 // value when creating nested dedicated workers in createWorker. | 122 // value when creating nested dedicated workers in createWorker. |
120 appcache_host_id_ = host->host_id(); | 123 appcache_host_id_ = host->host_id(); |
121 return host; | 124 return host; |
122 } | 125 } |
123 | 126 |
| 127 void WebWorkerClientProxy::openFileSystem( |
| 128 WebKit::WebFileSystem::Type type, |
| 129 long long size, |
| 130 WebKit::WebFileSystemCallbacks* callbacks) { |
| 131 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
| 132 stub_->url().GetOrigin(), static_cast<fileapi::FileSystemType>(type), |
| 133 size, new WebFileSystemCallbackDispatcher(callbacks)); |
| 134 } |
| 135 |
124 bool WebWorkerClientProxy::Send(IPC::Message* message) { | 136 bool WebWorkerClientProxy::Send(IPC::Message* message) { |
125 return WorkerThread::current()->Send(message); | 137 return WorkerThread::current()->Send(message); |
126 } | 138 } |
127 | 139 |
128 void WebWorkerClientProxy::EnsureWorkerContextTerminates() { | 140 void WebWorkerClientProxy::EnsureWorkerContextTerminates() { |
129 // Avoid a worker doing a while(1) from never exiting. | 141 // Avoid a worker doing a while(1) from never exiting. |
130 if (CommandLine::ForCurrentProcess()->HasSwitch( | 142 if (CommandLine::ForCurrentProcess()->HasSwitch( |
131 switches::kWebWorkerShareProcesses)) { | 143 switches::kWebWorkerShareProcesses)) { |
132 // Can't kill the process since there could be workers from other | 144 // Can't kill the process since there could be workers from other |
133 // renderer process. | 145 // renderer process. |
134 NOTIMPLEMENTED(); | 146 NOTIMPLEMENTED(); |
135 return; | 147 return; |
136 } | 148 } |
137 | 149 |
138 // This shuts down the process cleanly from the perspective of the browser | 150 // This shuts down the process cleanly from the perspective of the browser |
139 // process, and avoids the crashed worker infobar from appearing to the new | 151 // process, and avoids the crashed worker infobar from appearing to the new |
140 // page. It's ok to post several of theese, because the first executed task | 152 // page. It's ok to post several of theese, because the first executed task |
141 // will exit the message loop and subsequent ones won't be executed. | 153 // will exit the message loop and subsequent ones won't be executed. |
142 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 154 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
143 kill_process_factory_.NewRunnableMethod( | 155 kill_process_factory_.NewRunnableMethod( |
144 &WebWorkerClientProxy::workerContextDestroyed), | 156 &WebWorkerClientProxy::workerContextDestroyed), |
145 kMaxTimeForRunawayWorkerMs); | 157 kMaxTimeForRunawayWorkerMs); |
146 } | 158 } |
147 | |
OLD | NEW |