| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/ppb_nacl_private_impl.h" | 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" |
| 6 | 6 |
| 7 #ifndef DISABLE_NACL | 7 #ifndef DISABLE_NACL |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 36 #include "webkit/plugins/ppapi/host_globals.h" | 36 #include "webkit/plugins/ppapi/host_globals.h" |
| 37 #include "webkit/plugins/ppapi/plugin_module.h" | 37 #include "webkit/plugins/ppapi/plugin_module.h" |
| 38 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 38 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 39 | 39 |
| 40 using content::RenderThread; | 40 using content::RenderThread; |
| 41 using content::RenderView; | 41 using content::RenderView; |
| 42 using webkit::ppapi::HostGlobals; | 42 using webkit::ppapi::HostGlobals; |
| 43 using webkit::ppapi::PluginInstance; | 43 using webkit::ppapi::PluginInstance; |
| 44 using webkit::ppapi::PluginDelegate; | 44 using webkit::ppapi::PluginDelegate; |
| 45 using webkit::ppapi::PluginModule; |
| 45 using WebKit::WebView; | 46 using WebKit::WebView; |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 // This allows us to send requests from background threads. | 50 // This allows us to send requests from background threads. |
| 50 // E.g., to do LaunchSelLdr for helper nexes (which is done synchronously), | 51 // E.g., to do LaunchSelLdr for helper nexes (which is done synchronously), |
| 51 // in a background thread, to avoid jank. | 52 // in a background thread, to avoid jank. |
| 52 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > | 53 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > |
| 53 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; | 54 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; |
| 54 | 55 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 PP_Bool StartPpapiProxy(PP_Instance instance) { | 201 PP_Bool StartPpapiProxy(PP_Instance instance) { |
| 201 if (CommandLine::ForCurrentProcess()->HasSwitch( | 202 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 202 switches::kEnableNaClIPCProxy)) { | 203 switches::kEnableNaClIPCProxy)) { |
| 203 ChannelHandleMap& map = g_channel_handle_map.Get(); | 204 ChannelHandleMap& map = g_channel_handle_map.Get(); |
| 204 ChannelHandleMap::iterator it = map.find(instance); | 205 ChannelHandleMap::iterator it = map.find(instance); |
| 205 if (it == map.end()) | 206 if (it == map.end()) |
| 206 return PP_FALSE; | 207 return PP_FALSE; |
| 207 IPC::ChannelHandle channel_handle = it->second; | 208 IPC::ChannelHandle channel_handle = it->second; |
| 208 map.erase(it); | 209 map.erase(it); |
| 209 | 210 |
| 210 webkit::ppapi::PluginInstance* plugin_instance = | 211 PluginInstance* plugin_instance = |
| 211 content::GetHostGlobals()->GetInstance(instance); | 212 content::GetHostGlobals()->GetInstance(instance); |
| 212 if (!plugin_instance) | 213 if (!plugin_instance) |
| 213 return PP_FALSE; | 214 return PP_FALSE; |
| 214 | 215 |
| 215 WebView* web_view = | 216 WebView* web_view = |
| 216 plugin_instance->container()->element().document().frame()->view(); | 217 plugin_instance->container()->element().document().frame()->view(); |
| 217 RenderView* render_view = content::RenderView::FromWebView(web_view); | 218 RenderView* render_view = content::RenderView::FromWebView(web_view); |
| 218 | 219 |
| 219 webkit::ppapi::PluginModule* plugin_module = plugin_instance->module(); | 220 PluginModule* plugin_module = plugin_instance->module(); |
| 220 | 221 |
| 221 scoped_refptr<SyncMessageStatusReceiver> | 222 scoped_refptr<SyncMessageStatusReceiver> |
| 222 status_receiver(new SyncMessageStatusReceiver()); | 223 status_receiver(new SyncMessageStatusReceiver()); |
| 223 scoped_ptr<OutOfProcessProxy> out_of_process_proxy(new OutOfProcessProxy); | 224 scoped_ptr<OutOfProcessProxy> out_of_process_proxy(new OutOfProcessProxy); |
| 225 // Create a new module for each instance of the NaCl plugin that is using |
| 226 // the IPC based out-of-process proxy. We can't use the existing module, |
| 227 // because it is configured for the in-process NaCl plugin, and we must |
| 228 // keep it that way to allow the page to create other instances. |
| 229 scoped_refptr<PluginModule> nacl_plugin_module( |
| 230 plugin_module->CreateModuleForNaClInstance()); |
| 231 |
| 224 if (out_of_process_proxy->Init( | 232 if (out_of_process_proxy->Init( |
| 225 channel_handle, | 233 channel_handle, |
| 226 plugin_module->pp_module(), | 234 nacl_plugin_module->pp_module(), |
| 227 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 235 PluginModule::GetLocalGetInterfaceFunc(), |
| 228 ppapi::Preferences(render_view->GetWebkitPreferences()), | 236 ppapi::Preferences(render_view->GetWebkitPreferences()), |
| 229 status_receiver.get())) { | 237 status_receiver.get())) { |
| 230 plugin_module->InitAsProxiedNaCl( | 238 nacl_plugin_module->InitAsProxiedNaCl( |
| 231 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), | 239 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), |
| 232 instance); | 240 instance); |
| 233 return PP_TRUE; | 241 return PP_TRUE; |
| 234 } | 242 } |
| 235 } | 243 } |
| 236 | 244 |
| 237 return PP_FALSE; | 245 return PP_FALSE; |
| 238 } | 246 } |
| 239 | 247 |
| 240 int UrandomFD(void) { | 248 int UrandomFD(void) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 &IsPnaclEnabled | 339 &IsPnaclEnabled |
| 332 }; | 340 }; |
| 333 | 341 |
| 334 } // namespace | 342 } // namespace |
| 335 | 343 |
| 336 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 344 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 337 return &nacl_interface; | 345 return &nacl_interface; |
| 338 } | 346 } |
| 339 | 347 |
| 340 #endif // DISABLE_NACL | 348 #endif // DISABLE_NACL |
| OLD | NEW |