Chromium Code Reviews| 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. This allows the built-in NaCl plugin | |
| 227 // to create additional instances. | |
|
dmichael (off chromium)
2012/09/04 21:21:33
Could you elaborate more as to why new instances c
bbudge
2012/09/05 19:15:48
Done.
| |
| 228 scoped_refptr<PluginModule> nacl_plugin_module( | |
| 229 plugin_module->CreateModuleForNaClInstance()); | |
| 230 | |
| 224 if (out_of_process_proxy->Init( | 231 if (out_of_process_proxy->Init( |
| 225 channel_handle, | 232 channel_handle, |
| 226 plugin_module->pp_module(), | 233 nacl_plugin_module->pp_module(), |
| 227 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 234 PluginModule::GetLocalGetInterfaceFunc(), |
| 228 ppapi::Preferences(render_view->GetWebkitPreferences()), | 235 ppapi::Preferences(render_view->GetWebkitPreferences()), |
| 229 status_receiver.get())) { | 236 status_receiver.get())) { |
| 230 plugin_module->InitAsProxiedNaCl( | 237 nacl_plugin_module->InitAsProxiedNaCl( |
| 231 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), | 238 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), |
| 232 instance); | 239 instance); |
| 233 return PP_TRUE; | 240 return PP_TRUE; |
| 234 } | 241 } |
| 235 } | 242 } |
| 236 | 243 |
| 237 return PP_FALSE; | 244 return PP_FALSE; |
| 238 } | 245 } |
| 239 | 246 |
| 240 int UrandomFD(void) { | 247 int UrandomFD(void) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 &IsPnaclEnabled | 338 &IsPnaclEnabled |
| 332 }; | 339 }; |
| 333 | 340 |
| 334 } // namespace | 341 } // namespace |
| 335 | 342 |
| 336 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 343 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 337 return &nacl_interface; | 344 return &nacl_interface; |
| 338 } | 345 } |
| 339 | 346 |
| 340 #endif // DISABLE_NACL | 347 #endif // DISABLE_NACL |
| OLD | NEW |