| 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 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // This allows us to send requests from background threads. | 38 // This allows us to send requests from background threads. |
| 39 // E.g., to do LaunchSelLdr for helper nexes (which is done synchronously), | 39 // E.g., to do LaunchSelLdr for helper nexes (which is done synchronously), |
| 40 // in a background thread, to avoid jank. | 40 // in a background thread, to avoid jank. |
| 41 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > | 41 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > |
| 42 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; | 42 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; |
| 43 | 43 |
| 44 struct InstanceInfo { | 44 struct InstanceInfo { |
| 45 InstanceInfo() : plugin_child_id(0) {} | 45 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} |
| 46 GURL url; | 46 GURL url; |
| 47 ppapi::PpapiPermissions permissions; | 47 ppapi::PpapiPermissions permissions; |
| 48 base::ProcessId plugin_pid; |
| 48 int plugin_child_id; | 49 int plugin_child_id; |
| 49 IPC::ChannelHandle channel_handle; | 50 IPC::ChannelHandle channel_handle; |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap; | 53 typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap; |
| 53 | 54 |
| 54 base::LazyInstance<InstanceInfoMap> g_instance_info = | 55 base::LazyInstance<InstanceInfoMap> g_instance_info = |
| 55 LAZY_INSTANCE_INITIALIZER; | 56 LAZY_INSTANCE_INITIALIZER; |
| 56 | 57 |
| 57 static int GetRoutingID(PP_Instance instance) { | 58 static int GetRoutingID(PP_Instance instance) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 perm_bits |= ppapi::PERMISSION_DEV; | 99 perm_bits |= ppapi::PERMISSION_DEV; |
| 99 instance_info.permissions = | 100 instance_info.permissions = |
| 100 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 101 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 101 | 102 |
| 102 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( | 103 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( |
| 103 instance_info.url, | 104 instance_info.url, |
| 104 routing_id, | 105 routing_id, |
| 105 perm_bits, | 106 perm_bits, |
| 106 socket_count, &sockets, | 107 socket_count, &sockets, |
| 107 &instance_info.channel_handle, | 108 &instance_info.channel_handle, |
| 109 &instance_info.plugin_pid, |
| 108 &instance_info.plugin_child_id))) { | 110 &instance_info.plugin_child_id))) { |
| 109 return PP_NACL_FAILED; | 111 return PP_NACL_FAILED; |
| 110 } | 112 } |
| 111 | 113 |
| 112 // Don't save instance_info if channel handle is invalid. | 114 // Don't save instance_info if channel handle is invalid. |
| 113 bool invalid_handle = instance_info.channel_handle.name.empty(); | 115 bool invalid_handle = instance_info.channel_handle.name.empty(); |
| 114 #if defined(OS_POSIX) | 116 #if defined(OS_POSIX) |
| 115 if (!invalid_handle) | 117 if (!invalid_handle) |
| 116 invalid_handle = (instance_info.channel_handle.socket.fd == -1); | 118 invalid_handle = (instance_info.channel_handle.socket.fd == -1); |
| 117 #endif | 119 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 scoped_refptr<webkit::ppapi::PluginModule> nacl_plugin_module( | 154 scoped_refptr<webkit::ppapi::PluginModule> nacl_plugin_module( |
| 153 plugin_module->CreateModuleForNaClInstance()); | 155 plugin_module->CreateModuleForNaClInstance()); |
| 154 | 156 |
| 155 content::RendererPpapiHost* renderer_ppapi_host = | 157 content::RendererPpapiHost* renderer_ppapi_host = |
| 156 content::RendererPpapiHost::CreateExternalPluginModule( | 158 content::RendererPpapiHost::CreateExternalPluginModule( |
| 157 nacl_plugin_module, | 159 nacl_plugin_module, |
| 158 plugin_instance, | 160 plugin_instance, |
| 159 FilePath().AppendASCII(instance_info.url.spec()), | 161 FilePath().AppendASCII(instance_info.url.spec()), |
| 160 instance_info.permissions, | 162 instance_info.permissions, |
| 161 instance_info.channel_handle, | 163 instance_info.channel_handle, |
| 164 instance_info.plugin_pid, |
| 162 instance_info.plugin_child_id); | 165 instance_info.plugin_child_id); |
| 163 if (!renderer_ppapi_host) | 166 if (!renderer_ppapi_host) |
| 164 return PP_NACL_ERROR_MODULE; | 167 return PP_NACL_ERROR_MODULE; |
| 165 | 168 |
| 166 // Finally, switch the instance to the proxy. | 169 // Finally, switch the instance to the proxy. |
| 167 return nacl_plugin_module->InitAsProxiedNaCl(plugin_instance); | 170 return nacl_plugin_module->InitAsProxiedNaCl(plugin_instance); |
| 168 } | 171 } |
| 169 | 172 |
| 170 int UrandomFD(void) { | 173 int UrandomFD(void) { |
| 171 #if defined(OS_POSIX) | 174 #if defined(OS_POSIX) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 &ReportNaClError | 281 &ReportNaClError |
| 279 }; | 282 }; |
| 280 | 283 |
| 281 } // namespace | 284 } // namespace |
| 282 | 285 |
| 283 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 286 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 284 return &nacl_interface; | 287 return &nacl_interface; |
| 285 } | 288 } |
| 286 | 289 |
| 287 #endif // DISABLE_NACL | 290 #endif // DISABLE_NACL |
| OLD | NEW |