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/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return webkit_forwarding_.get(); | 89 return webkit_forwarding_.get(); |
90 } | 90 } |
91 | 91 |
92 void PpapiThread::PostToWebKitThread(const tracked_objects::Location& from_here, | 92 void PpapiThread::PostToWebKitThread(const tracked_objects::Location& from_here, |
93 const base::Closure& task) { | 93 const base::Closure& task) { |
94 if (!webkit_thread_.get()) | 94 if (!webkit_thread_.get()) |
95 webkit_thread_.reset(new PpapiWebKitThread); | 95 webkit_thread_.reset(new PpapiWebKitThread); |
96 webkit_thread_->PostTask(from_here, task); | 96 webkit_thread_->PostTask(from_here, task); |
97 } | 97 } |
98 | 98 |
| 99 bool PpapiThread::SendToBrowser(IPC::Message* msg) { |
| 100 return Send(msg); |
| 101 } |
| 102 |
99 void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { | 103 void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { |
100 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL)); | 104 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL)); |
101 | 105 |
102 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
103 // Once we lower the token the sandbox is locked down and no new modules | 107 // Once we lower the token the sandbox is locked down and no new modules |
104 // can be loaded. TODO(cpu): consider changing to the loading style of | 108 // can be loaded. TODO(cpu): consider changing to the loading style of |
105 // regular plugins. | 109 // regular plugins. |
106 if (g_target_services) | 110 if (g_target_services) |
107 g_target_services->LowerToken(); | 111 g_target_services->LowerToken(); |
108 #endif | 112 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 184 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
181 DCHECK(is_broker_ == (get_plugin_interface_ == NULL)); | 185 DCHECK(is_broker_ == (get_plugin_interface_ == NULL)); |
182 IPC::ChannelHandle plugin_handle; | 186 IPC::ChannelHandle plugin_handle; |
183 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), | 187 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), |
184 renderer_id); | 188 renderer_id); |
185 | 189 |
186 pp::proxy::ProxyChannel* dispatcher = NULL; | 190 pp::proxy::ProxyChannel* dispatcher = NULL; |
187 bool init_result = false; | 191 bool init_result = false; |
188 if (is_broker_) { | 192 if (is_broker_) { |
189 BrokerProcessDispatcher* broker_dispatcher = | 193 BrokerProcessDispatcher* broker_dispatcher = |
190 new BrokerProcessDispatcher(host_process_handle, connect_instance_func_); | 194 new BrokerProcessDispatcher(host_process_handle, |
191 init_result = broker_dispatcher->InitBrokerWithChannel(this, | 195 connect_instance_func_); |
192 plugin_handle, | 196 init_result = broker_dispatcher->InitBrokerWithChannel(this, |
193 false); | 197 plugin_handle, |
194 dispatcher = broker_dispatcher; | 198 false); |
| 199 dispatcher = broker_dispatcher; |
195 } else { | 200 } else { |
196 PluginProcessDispatcher* plugin_dispatcher = | 201 PluginProcessDispatcher* plugin_dispatcher = |
197 new PluginProcessDispatcher(host_process_handle, get_plugin_interface_); | 202 new PluginProcessDispatcher(host_process_handle, get_plugin_interface_); |
198 init_result = plugin_dispatcher->InitPluginWithChannel(this, | 203 init_result = plugin_dispatcher->InitPluginWithChannel(this, |
199 plugin_handle, | 204 plugin_handle, |
200 false); | 205 false); |
201 dispatcher = plugin_dispatcher; | 206 dispatcher = plugin_dispatcher; |
202 } | 207 } |
203 | 208 |
204 if (!init_result) { | 209 if (!init_result) { |
205 delete dispatcher; | 210 delete dispatcher; |
206 return false; | 211 return false; |
207 } | 212 } |
208 | 213 |
209 handle->name = plugin_handle.name; | 214 handle->name = plugin_handle.name; |
210 #if defined(OS_POSIX) | 215 #if defined(OS_POSIX) |
211 // On POSIX, pass the renderer-side FD. | 216 // On POSIX, pass the renderer-side FD. |
212 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), | 217 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), |
213 true); | 218 true); |
214 #endif | 219 #endif |
215 | 220 |
216 // From here, the dispatcher will manage its own lifetime according to the | 221 // From here, the dispatcher will manage its own lifetime according to the |
217 // lifetime of the attached channel. | 222 // lifetime of the attached channel. |
218 return true; | 223 return true; |
219 } | 224 } |
OLD | NEW |