| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (!host) | 63 if (!host) |
| 64 return 0; | 64 return 0; |
| 65 return host->GetRoutingIDForWidget(instance); | 65 return host->GetRoutingIDForWidget(instance); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Launch NaCl's sel_ldr process. | 68 // Launch NaCl's sel_ldr process. |
| 69 PP_NaClResult LaunchSelLdr(PP_Instance instance, | 69 PP_NaClResult LaunchSelLdr(PP_Instance instance, |
| 70 const char* alleged_url, | 70 const char* alleged_url, |
| 71 PP_Bool uses_ppapi, | 71 PP_Bool uses_ppapi, |
| 72 PP_Bool enable_ppapi_dev, | 72 PP_Bool enable_ppapi_dev, |
| 73 int socket_count, | 73 void* imc_handle) { |
| 74 void* imc_handles) { | 74 nacl::FileDescriptor result_socket; |
| 75 std::vector<nacl::FileDescriptor> sockets; | |
| 76 IPC::Sender* sender = content::RenderThread::Get(); | 75 IPC::Sender* sender = content::RenderThread::Get(); |
| 77 if (sender == NULL) | 76 if (sender == NULL) |
| 78 sender = g_background_thread_sender.Pointer()->get(); | 77 sender = g_background_thread_sender.Pointer()->get(); |
| 79 | 78 |
| 80 int routing_id = 0; | 79 int routing_id = 0; |
| 81 // If the nexe uses ppapi APIs, we need a routing ID. | 80 // If the nexe uses ppapi APIs, we need a routing ID. |
| 82 // To get the routing ID, we must be on the main thread. | 81 // To get the routing ID, we must be on the main thread. |
| 83 // Some nexes do not use ppapi and launch from the background thread, | 82 // Some nexes do not use ppapi and launch from the background thread, |
| 84 // so those nexes can skip finding a routing_id. | 83 // so those nexes can skip finding a routing_id. |
| 85 if (uses_ppapi) { | 84 if (uses_ppapi) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 // must also check on the trusted side of the proxy. | 96 // must also check on the trusted side of the proxy. |
| 98 if (enable_ppapi_dev) | 97 if (enable_ppapi_dev) |
| 99 perm_bits |= ppapi::PERMISSION_DEV; | 98 perm_bits |= ppapi::PERMISSION_DEV; |
| 100 instance_info.permissions = | 99 instance_info.permissions = |
| 101 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 100 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 102 | 101 |
| 103 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( | 102 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( |
| 104 instance_info.url, | 103 instance_info.url, |
| 105 routing_id, | 104 routing_id, |
| 106 perm_bits, | 105 perm_bits, |
| 107 socket_count, &sockets, | 106 &result_socket, |
| 108 &instance_info.channel_handle, | 107 &instance_info.channel_handle, |
| 109 &instance_info.plugin_pid, | 108 &instance_info.plugin_pid, |
| 110 &instance_info.plugin_child_id))) { | 109 &instance_info.plugin_child_id))) { |
| 111 return PP_NACL_FAILED; | 110 return PP_NACL_FAILED; |
| 112 } | 111 } |
| 113 | 112 |
| 114 // Don't save instance_info if channel handle is invalid. | 113 // Don't save instance_info if channel handle is invalid. |
| 115 bool invalid_handle = instance_info.channel_handle.name.empty(); | 114 bool invalid_handle = instance_info.channel_handle.name.empty(); |
| 116 #if defined(OS_POSIX) | 115 #if defined(OS_POSIX) |
| 117 if (!invalid_handle) | 116 if (!invalid_handle) |
| 118 invalid_handle = (instance_info.channel_handle.socket.fd == -1); | 117 invalid_handle = (instance_info.channel_handle.socket.fd == -1); |
| 119 #endif | 118 #endif |
| 120 if (!invalid_handle) | 119 if (!invalid_handle) |
| 121 g_instance_info.Get()[instance] = instance_info; | 120 g_instance_info.Get()[instance] = instance_info; |
| 122 | 121 |
| 123 CHECK(static_cast<int>(sockets.size()) == socket_count); | 122 *(static_cast<nacl::Handle*>(imc_handle)) = |
| 124 for (int i = 0; i < socket_count; i++) { | 123 nacl::ToNativeHandle(result_socket); |
| 125 static_cast<nacl::Handle*>(imc_handles)[i] = | |
| 126 nacl::ToNativeHandle(sockets[i]); | |
| 127 } | |
| 128 | 124 |
| 129 return PP_NACL_OK; | 125 return PP_NACL_OK; |
| 130 } | 126 } |
| 131 | 127 |
| 132 PP_NaClResult StartPpapiProxy(PP_Instance instance) { | 128 PP_NaClResult StartPpapiProxy(PP_Instance instance) { |
| 133 if (CommandLine::ForCurrentProcess()->HasSwitch( | 129 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 134 switches::kEnableNaClSRPCProxy)) | 130 switches::kEnableNaClSRPCProxy)) |
| 135 return PP_NACL_USE_SRPC; | 131 return PP_NACL_USE_SRPC; |
| 136 | 132 |
| 137 InstanceInfoMap& map = g_instance_info.Get(); | 133 InstanceInfoMap& map = g_instance_info.Get(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 &ReportNaClError | 277 &ReportNaClError |
| 282 }; | 278 }; |
| 283 | 279 |
| 284 } // namespace | 280 } // namespace |
| 285 | 281 |
| 286 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 282 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 287 return &nacl_interface; | 283 return &nacl_interface; |
| 288 } | 284 } |
| 289 | 285 |
| 290 #endif // DISABLE_NACL | 286 #endif // DISABLE_NACL |
| OLD | NEW |