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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ(PP_PNACL_TRANSLATOR_PROCESS_TYPE, | 377 STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ(PP_PNACL_TRANSLATOR_PROCESS_TYPE, |
378 kPNaClTranslatorProcessType); | 378 kPNaClTranslatorProcessType); |
379 STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ(PP_NUM_NACL_PROCESS_TYPES, | 379 STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ(PP_NUM_NACL_PROCESS_TYPES, |
380 kNumNaClProcessTypes); | 380 kNumNaClProcessTypes); |
381 #undef STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ | 381 #undef STATICALLY_CHECK_NACLAPPPROCESSTYPE_EQ |
382 DCHECK(pp_process_type > PP_UNKNOWN_NACL_PROCESS_TYPE && | 382 DCHECK(pp_process_type > PP_UNKNOWN_NACL_PROCESS_TYPE && |
383 pp_process_type < PP_NUM_NACL_PROCESS_TYPES); | 383 pp_process_type < PP_NUM_NACL_PROCESS_TYPES); |
384 return static_cast<NaClAppProcessType>(pp_process_type); | 384 return static_cast<NaClAppProcessType>(pp_process_type); |
385 } | 385 } |
386 | 386 |
| 387 // A dummy IPC::Listener object with a no-op message handler. We use |
| 388 // this with an IPC::SyncChannel where we only send synchronous |
| 389 // messages and don't need to handle any messages other than sync |
| 390 // replies. |
| 391 class NoOpListener : public IPC::Listener { |
| 392 public: |
| 393 bool OnMessageReceived(const IPC::Message& message) override { return false; } |
| 394 void OnChannelError() override {} |
| 395 }; |
| 396 |
387 // Launch NaCl's sel_ldr process. | 397 // Launch NaCl's sel_ldr process. |
388 void LaunchSelLdr(PP_Instance instance, | 398 void LaunchSelLdr(PP_Instance instance, |
389 PP_Bool main_service_runtime, | 399 PP_Bool main_service_runtime, |
390 const char* alleged_url, | 400 const char* alleged_url, |
391 const PP_NaClFileInfo* nexe_file_info, | 401 const PP_NaClFileInfo* nexe_file_info, |
392 PP_Bool uses_nonsfi_mode, | 402 PP_Bool uses_nonsfi_mode, |
393 PP_NaClAppProcessType pp_process_type, | 403 PP_NaClAppProcessType pp_process_type, |
394 void* imc_handle, | 404 void* imc_handle, |
| 405 scoped_ptr<IPC::SyncChannel>* translator_channel, |
| 406 base::ProcessId* process_id, |
395 PP_CompletionCallback callback) { | 407 PP_CompletionCallback callback) { |
396 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 408 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
397 BelongsToCurrentThread()); | 409 BelongsToCurrentThread()); |
398 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type); | 410 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type); |
399 // Create the manifest service proxy here, so on error case, it will be | 411 // Create the manifest service proxy here, so on error case, it will be |
400 // destructed (without passing it to ManifestServiceChannel). | 412 // destructed (without passing it to ManifestServiceChannel). |
401 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( | 413 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( |
402 new ManifestServiceProxy(instance, process_type)); | 414 new ManifestServiceProxy(instance, process_type)); |
403 | 415 |
404 IPC::Sender* sender = content::RenderThread::Get(); | 416 IPC::Sender* sender = content::RenderThread::Get(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 static_cast<int32_t>(PP_ERROR_FAILED))); | 516 static_cast<int32_t>(PP_ERROR_FAILED))); |
505 return; | 517 return; |
506 } | 518 } |
507 | 519 |
508 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; | 520 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; |
509 instance_info.plugin_pid = launch_result.plugin_pid; | 521 instance_info.plugin_pid = launch_result.plugin_pid; |
510 instance_info.plugin_child_id = launch_result.plugin_child_id; | 522 instance_info.plugin_child_id = launch_result.plugin_child_id; |
511 | 523 |
512 // Don't save instance_info if channel handle is invalid. | 524 // Don't save instance_info if channel handle is invalid. |
513 if (IsValidChannelHandle(instance_info.channel_handle)) { | 525 if (IsValidChannelHandle(instance_info.channel_handle)) { |
514 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); | 526 if (process_type == kPNaClTranslatorProcessType) { |
515 nacl_plugin_instance->instance_info.reset(new InstanceInfo(instance_info)); | 527 // Return an IPC channel which allows communicating with a PNaCl |
| 528 // translator process. |
| 529 *translator_channel = IPC::SyncChannel::Create( |
| 530 instance_info.channel_handle, |
| 531 IPC::Channel::MODE_CLIENT, |
| 532 new NoOpListener, |
| 533 content::RenderThread::Get()->GetIOMessageLoopProxy(), |
| 534 true, |
| 535 content::RenderThread::Get()->GetShutdownEvent()); |
| 536 *process_id = launch_result.plugin_pid; |
| 537 } else { |
| 538 // Save the channel handle for when StartPpapiProxy() is called. |
| 539 NaClPluginInstance* nacl_plugin_instance = |
| 540 GetNaClPluginInstance(instance); |
| 541 nacl_plugin_instance->instance_info.reset( |
| 542 new InstanceInfo(instance_info)); |
| 543 } |
516 } | 544 } |
517 | 545 |
518 *(static_cast<NaClHandle*>(imc_handle)) = | 546 *(static_cast<NaClHandle*>(imc_handle)) = |
519 IPC::PlatformFileForTransitToPlatformFile( | 547 IPC::PlatformFileForTransitToPlatformFile( |
520 launch_result.imc_channel_handle); | 548 launch_result.imc_channel_handle); |
521 | 549 |
522 // Store the crash information shared memory handle. | 550 // Store the crash information shared memory handle. |
523 load_manager->set_crash_info_shmem_handle( | 551 load_manager->set_crash_info_shmem_handle( |
524 launch_result.crash_info_shmem_handle); | 552 launch_result.crash_info_shmem_handle); |
525 | 553 |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 &StreamPexe | 1750 &StreamPexe |
1723 }; | 1751 }; |
1724 | 1752 |
1725 } // namespace | 1753 } // namespace |
1726 | 1754 |
1727 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1755 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1728 return &nacl_interface; | 1756 return &nacl_interface; |
1729 } | 1757 } |
1730 | 1758 |
1731 } // namespace nacl | 1759 } // namespace nacl |
OLD | NEW |