OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return PP_ERROR_FAILED; | 245 return PP_ERROR_FAILED; |
246 // No default case, to catch unhandled Status values. | 246 // No default case, to catch unhandled Status values. |
247 } | 247 } |
248 return PP_ERROR_FAILED; | 248 return PP_ERROR_FAILED; |
249 } | 249 } |
250 | 250 |
251 // Launch NaCl's sel_ldr process. | 251 // Launch NaCl's sel_ldr process. |
252 void LaunchSelLdr(PP_Instance instance, | 252 void LaunchSelLdr(PP_Instance instance, |
253 PP_Bool main_service_runtime, | 253 PP_Bool main_service_runtime, |
254 const char* alleged_url, | 254 const char* alleged_url, |
| 255 const PP_NaClFileInfo* nexe_file_info, |
255 PP_Bool uses_irt, | 256 PP_Bool uses_irt, |
256 PP_Bool uses_ppapi, | 257 PP_Bool uses_ppapi, |
257 PP_Bool uses_nonsfi_mode, | 258 PP_Bool uses_nonsfi_mode, |
258 PP_Bool enable_ppapi_dev, | 259 PP_Bool enable_ppapi_dev, |
259 PP_Bool enable_dyncode_syscalls, | 260 PP_Bool enable_dyncode_syscalls, |
260 PP_Bool enable_exception_handling, | 261 PP_Bool enable_exception_handling, |
261 PP_Bool enable_crash_throttling, | 262 PP_Bool enable_crash_throttling, |
262 const PPP_ManifestService* manifest_service_interface, | 263 const PPP_ManifestService* manifest_service_interface, |
263 void* manifest_service_user_data, | 264 void* manifest_service_user_data, |
264 void* imc_handle, | 265 void* imc_handle, |
(...skipping 13 matching lines...) Expand all Loading... |
278 IPC::Sender* sender = content::RenderThread::Get(); | 279 IPC::Sender* sender = content::RenderThread::Get(); |
279 DCHECK(sender); | 280 DCHECK(sender); |
280 int routing_id = 0; | 281 int routing_id = 0; |
281 // If the nexe uses ppapi APIs, we need a routing ID. | 282 // If the nexe uses ppapi APIs, we need a routing ID. |
282 // To get the routing ID, we must be on the main thread. | 283 // To get the routing ID, we must be on the main thread. |
283 // Some nexes do not use ppapi and launch from the background thread, | 284 // Some nexes do not use ppapi and launch from the background thread, |
284 // so those nexes can skip finding a routing_id. | 285 // so those nexes can skip finding a routing_id. |
285 if (uses_ppapi) { | 286 if (uses_ppapi) { |
286 routing_id = GetRoutingID(instance); | 287 routing_id = GetRoutingID(instance); |
287 if (!routing_id) { | 288 if (!routing_id) { |
| 289 if (nexe_file_info->handle != PP_kInvalidFileHandle) { |
| 290 base::ClosePlatformFile(nexe_file_info->handle); |
| 291 } |
288 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 292 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
289 FROM_HERE, | 293 FROM_HERE, |
290 base::Bind(callback.func, callback.user_data, | 294 base::Bind(callback.func, callback.user_data, |
291 static_cast<int32_t>(PP_ERROR_FAILED))); | 295 static_cast<int32_t>(PP_ERROR_FAILED))); |
292 return; | 296 return; |
293 } | 297 } |
294 } | 298 } |
295 | 299 |
296 InstanceInfo instance_info; | 300 InstanceInfo instance_info; |
297 instance_info.url = GURL(alleged_url); | 301 instance_info.url = GURL(alleged_url); |
298 | 302 |
299 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 303 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
300 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 304 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
301 // it's clearer to developers when they are using 'Dev' inappropriately. We | 305 // it's clearer to developers when they are using 'Dev' inappropriately. We |
302 // must also check on the trusted side of the proxy. | 306 // must also check on the trusted side of the proxy. |
303 if (enable_ppapi_dev) | 307 if (enable_ppapi_dev) |
304 perm_bits |= ppapi::PERMISSION_DEV; | 308 perm_bits |= ppapi::PERMISSION_DEV; |
305 instance_info.permissions = | 309 instance_info.permissions = |
306 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 310 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
307 std::string error_message_string; | 311 std::string error_message_string; |
308 NaClLaunchResult launch_result; | 312 NaClLaunchResult launch_result; |
309 | 313 |
| 314 content::RendererPpapiHost* host = |
| 315 content::RendererPpapiHost::GetForPPInstance(instance); |
310 if (!sender->Send(new NaClHostMsg_LaunchNaCl( | 316 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
311 NaClLaunchParams(instance_info.url.spec(), | 317 NaClLaunchParams( |
312 routing_id, | 318 instance_info.url.spec(), |
313 perm_bits, | 319 host->ShareHandleWithRemote(nexe_file_info->handle, true), |
314 PP_ToBool(uses_irt), | 320 routing_id, |
315 PP_ToBool(uses_nonsfi_mode), | 321 perm_bits, |
316 PP_ToBool(enable_dyncode_syscalls), | 322 PP_ToBool(uses_irt), |
317 PP_ToBool(enable_exception_handling), | 323 PP_ToBool(uses_nonsfi_mode), |
318 PP_ToBool(enable_crash_throttling)), | 324 PP_ToBool(enable_dyncode_syscalls), |
| 325 PP_ToBool(enable_exception_handling), |
| 326 PP_ToBool(enable_crash_throttling)), |
319 &launch_result, | 327 &launch_result, |
320 &error_message_string))) { | 328 &error_message_string))) { |
321 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 329 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
322 FROM_HERE, | 330 FROM_HERE, |
323 base::Bind(callback.func, callback.user_data, | 331 base::Bind(callback.func, callback.user_data, |
324 static_cast<int32_t>(PP_ERROR_FAILED))); | 332 static_cast<int32_t>(PP_ERROR_FAILED))); |
325 return; | 333 return; |
326 } | 334 } |
327 | 335 |
328 if (!error_message_string.empty()) { | 336 if (!error_message_string.empty()) { |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 &LogTranslateTime | 1559 &LogTranslateTime |
1552 }; | 1560 }; |
1553 | 1561 |
1554 } // namespace | 1562 } // namespace |
1555 | 1563 |
1556 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1564 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1557 return &nacl_interface; | 1565 return &nacl_interface; |
1558 } | 1566 } |
1559 | 1567 |
1560 } // namespace nacl | 1568 } // namespace nacl |
OLD | NEW |