| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return PP_ERROR_FAILED; | 289 return PP_ERROR_FAILED; |
| 290 // No default case, to catch unhandled Status values. | 290 // No default case, to catch unhandled Status values. |
| 291 } | 291 } |
| 292 return PP_ERROR_FAILED; | 292 return PP_ERROR_FAILED; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Launch NaCl's sel_ldr process. | 295 // Launch NaCl's sel_ldr process. |
| 296 void LaunchSelLdr(PP_Instance instance, | 296 void LaunchSelLdr(PP_Instance instance, |
| 297 PP_Bool main_service_runtime, | 297 PP_Bool main_service_runtime, |
| 298 const char* alleged_url, | 298 const char* alleged_url, |
| 299 const PP_NaClFileInfo* nexe_file_info, |
| 299 PP_Bool uses_irt, | 300 PP_Bool uses_irt, |
| 300 PP_Bool uses_ppapi, | 301 PP_Bool uses_ppapi, |
| 301 PP_Bool uses_nonsfi_mode, | 302 PP_Bool uses_nonsfi_mode, |
| 302 PP_Bool enable_ppapi_dev, | 303 PP_Bool enable_ppapi_dev, |
| 303 PP_Bool enable_dyncode_syscalls, | 304 PP_Bool enable_dyncode_syscalls, |
| 304 PP_Bool enable_exception_handling, | 305 PP_Bool enable_exception_handling, |
| 305 PP_Bool enable_crash_throttling, | 306 PP_Bool enable_crash_throttling, |
| 306 const PPP_ManifestService* manifest_service_interface, | 307 const PPP_ManifestService* manifest_service_interface, |
| 307 void* manifest_service_user_data, | 308 void* manifest_service_user_data, |
| 308 void* imc_handle, | 309 void* imc_handle, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 323 IPC::Sender* sender = content::RenderThread::Get(); | 324 IPC::Sender* sender = content::RenderThread::Get(); |
| 324 DCHECK(sender); | 325 DCHECK(sender); |
| 325 int routing_id = 0; | 326 int routing_id = 0; |
| 326 // If the nexe uses ppapi APIs, we need a routing ID. | 327 // If the nexe uses ppapi APIs, we need a routing ID. |
| 327 // To get the routing ID, we must be on the main thread. | 328 // To get the routing ID, we must be on the main thread. |
| 328 // Some nexes do not use ppapi and launch from the background thread, | 329 // Some nexes do not use ppapi and launch from the background thread, |
| 329 // so those nexes can skip finding a routing_id. | 330 // so those nexes can skip finding a routing_id. |
| 330 if (uses_ppapi) { | 331 if (uses_ppapi) { |
| 331 routing_id = GetRoutingID(instance); | 332 routing_id = GetRoutingID(instance); |
| 332 if (!routing_id) { | 333 if (!routing_id) { |
| 334 if (nexe_file_info->handle != PP_kInvalidFileHandle) { |
| 335 base::ClosePlatformFile(nexe_file_info->handle); |
| 336 } |
| 333 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 337 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 334 FROM_HERE, | 338 FROM_HERE, |
| 335 base::Bind(callback.func, callback.user_data, | 339 base::Bind(callback.func, callback.user_data, |
| 336 static_cast<int32_t>(PP_ERROR_FAILED))); | 340 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 337 return; | 341 return; |
| 338 } | 342 } |
| 339 } | 343 } |
| 340 | 344 |
| 341 InstanceInfo instance_info; | 345 InstanceInfo instance_info; |
| 342 instance_info.url = GURL(alleged_url); | 346 instance_info.url = GURL(alleged_url); |
| 343 | 347 |
| 344 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 348 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
| 345 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 349 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
| 346 // it's clearer to developers when they are using 'Dev' inappropriately. We | 350 // it's clearer to developers when they are using 'Dev' inappropriately. We |
| 347 // must also check on the trusted side of the proxy. | 351 // must also check on the trusted side of the proxy. |
| 348 if (enable_ppapi_dev) | 352 if (enable_ppapi_dev) |
| 349 perm_bits |= ppapi::PERMISSION_DEV; | 353 perm_bits |= ppapi::PERMISSION_DEV; |
| 350 instance_info.permissions = | 354 instance_info.permissions = |
| 351 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 355 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 352 std::string error_message_string; | 356 std::string error_message_string; |
| 353 NaClLaunchResult launch_result; | 357 NaClLaunchResult launch_result; |
| 354 | 358 |
| 359 content::RendererPpapiHost* host = |
| 360 content::RendererPpapiHost::GetForPPInstance(instance); |
| 355 if (!sender->Send(new NaClHostMsg_LaunchNaCl( | 361 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
| 356 NaClLaunchParams(instance_info.url.spec(), | 362 NaClLaunchParams( |
| 357 routing_id, | 363 instance_info.url.spec(), |
| 358 perm_bits, | 364 host->ShareHandleWithRemote(nexe_file_info->handle, true), |
| 359 PP_ToBool(uses_irt), | 365 routing_id, |
| 360 PP_ToBool(uses_nonsfi_mode), | 366 perm_bits, |
| 361 PP_ToBool(enable_dyncode_syscalls), | 367 PP_ToBool(uses_irt), |
| 362 PP_ToBool(enable_exception_handling), | 368 PP_ToBool(uses_nonsfi_mode), |
| 363 PP_ToBool(enable_crash_throttling)), | 369 PP_ToBool(enable_dyncode_syscalls), |
| 370 PP_ToBool(enable_exception_handling), |
| 371 PP_ToBool(enable_crash_throttling)), |
| 364 &launch_result, | 372 &launch_result, |
| 365 &error_message_string))) { | 373 &error_message_string))) { |
| 366 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 374 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 367 FROM_HERE, | 375 FROM_HERE, |
| 368 base::Bind(callback.func, callback.user_data, | 376 base::Bind(callback.func, callback.user_data, |
| 369 static_cast<int32_t>(PP_ERROR_FAILED))); | 377 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 370 return; | 378 return; |
| 371 } | 379 } |
| 372 | 380 |
| 373 if (!error_message_string.empty()) { | 381 if (!error_message_string.empty()) { |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 &LogTranslateTime | 1634 &LogTranslateTime |
| 1627 }; | 1635 }; |
| 1628 | 1636 |
| 1629 } // namespace | 1637 } // namespace |
| 1630 | 1638 |
| 1631 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1639 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
| 1632 return &nacl_interface; | 1640 return &nacl_interface; |
| 1633 } | 1641 } |
| 1634 | 1642 |
| 1635 } // namespace nacl | 1643 } // namespace nacl |
| OLD | NEW |