Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 1094653003: Refactor NaClProcessHost. Reduce chances to leak the resource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 void* imc_handle, 378 void* imc_handle,
379 PP_CompletionCallback callback) { 379 PP_CompletionCallback callback) {
380 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> 380 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->
381 BelongsToCurrentThread()); 381 BelongsToCurrentThread());
382 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type); 382 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type);
383 // Create the manifest service proxy here, so on error case, it will be 383 // Create the manifest service proxy here, so on error case, it will be
384 // destructed (without passing it to ManifestServiceChannel). 384 // destructed (without passing it to ManifestServiceChannel).
385 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( 385 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy(
386 new ManifestServiceProxy(instance, process_type)); 386 new ManifestServiceProxy(instance, process_type));
387 387
388 FileDescriptor result_socket;
389 IPC::Sender* sender = content::RenderThread::Get(); 388 IPC::Sender* sender = content::RenderThread::Get();
390 DCHECK(sender); 389 DCHECK(sender);
391 int routing_id = GetRoutingID(instance); 390 int routing_id = GetRoutingID(instance);
392 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 391 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
393 DCHECK(load_manager); 392 DCHECK(load_manager);
394 content::PepperPluginInstance* plugin_instance = 393 content::PepperPluginInstance* plugin_instance =
395 content::PepperPluginInstance::Get(instance); 394 content::PepperPluginInstance::Get(instance);
396 DCHECK(plugin_instance); 395 DCHECK(plugin_instance);
397 if (!routing_id || !load_manager || !plugin_instance) { 396 if (!routing_id || !load_manager || !plugin_instance) {
398 if (nexe_file_info->handle != PP_kInvalidFileHandle) { 397 if (nexe_file_info->handle != PP_kInvalidFileHandle) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, 474 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH,
476 "ServiceRuntime: failed to start", 475 "ServiceRuntime: failed to start",
477 error_message_string); 476 error_message_string);
478 } 477 }
479 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( 478 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
480 FROM_HERE, 479 FROM_HERE,
481 base::Bind(callback.func, callback.user_data, 480 base::Bind(callback.func, callback.user_data,
482 static_cast<int32_t>(PP_ERROR_FAILED))); 481 static_cast<int32_t>(PP_ERROR_FAILED)));
483 return; 482 return;
484 } 483 }
485 result_socket = launch_result.imc_channel_handle; 484
486 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; 485 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle;
487 instance_info.plugin_pid = launch_result.plugin_pid; 486 instance_info.plugin_pid = launch_result.plugin_pid;
488 instance_info.plugin_child_id = launch_result.plugin_child_id; 487 instance_info.plugin_child_id = launch_result.plugin_child_id;
489 488
490 // Don't save instance_info if channel handle is invalid. 489 // Don't save instance_info if channel handle is invalid.
491 if (IsValidChannelHandle(instance_info.channel_handle)) { 490 if (IsValidChannelHandle(instance_info.channel_handle)) {
492 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance); 491 NaClPluginInstance* nacl_plugin_instance = GetNaClPluginInstance(instance);
493 nacl_plugin_instance->instance_info.reset(new InstanceInfo(instance_info)); 492 nacl_plugin_instance->instance_info.reset(new InstanceInfo(instance_info));
494 } 493 }
495 494
496 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); 495 *(static_cast<NaClHandle*>(imc_handle)) =
496 IPC::PlatformFileForTransitToPlatformFile(
497 launch_result.imc_channel_handle);
497 498
498 // Store the crash information shared memory handle. 499 // Store the crash information shared memory handle.
499 load_manager->set_crash_info_shmem_handle( 500 load_manager->set_crash_info_shmem_handle(
500 launch_result.crash_info_shmem_handle); 501 launch_result.crash_info_shmem_handle);
501 502
502 // Create the trusted plugin channel. 503 // Create the trusted plugin channel.
503 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { 504 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) {
504 bool report_exit_status = PP_ToBool(main_service_runtime); 505 bool report_exit_status = PP_ToBool(main_service_runtime);
505 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel( 506 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel(
506 new TrustedPluginChannel( 507 new TrustedPluginChannel(
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 &StreamPexe 1728 &StreamPexe
1728 }; 1729 };
1729 1730
1730 } // namespace 1731 } // namespace
1731 1732
1732 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1733 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1733 return &nacl_interface; 1734 return &nacl_interface;
1734 } 1735 }
1735 1736
1736 } // namespace nacl 1737 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698