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/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 509 } |
510 | 510 |
511 // Start getting the IRT open asynchronously while we launch the NaCl process. | 511 // Start getting the IRT open asynchronously while we launch the NaCl process. |
512 // We'll make sure this actually finished in StartWithLaunchedProcess, below. | 512 // We'll make sure this actually finished in StartWithLaunchedProcess, below. |
513 if (!NaClBrowser::GetInstance()->EnsureIrtAvailable()) { | 513 if (!NaClBrowser::GetInstance()->EnsureIrtAvailable()) { |
514 DLOG(ERROR) << "Cannot launch NaCl process after IRT file open failed"; | 514 DLOG(ERROR) << "Cannot launch NaCl process after IRT file open failed"; |
515 delete this; | 515 delete this; |
516 return; | 516 return; |
517 } | 517 } |
518 | 518 |
| 519 ppapi_channel_name_ = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 520 |
519 // Rather than creating a socket pair in the renderer, and passing | 521 // Rather than creating a socket pair in the renderer, and passing |
520 // one side through the browser to sel_ldr, socket pairs are created | 522 // one side through the browser to sel_ldr, socket pairs are created |
521 // in the browser and then passed to the renderer and sel_ldr. | 523 // in the browser and then passed to the renderer and sel_ldr. |
522 // | 524 // |
523 // This is mainly for the benefit of Windows, where sockets cannot | 525 // This is mainly for the benefit of Windows, where sockets cannot |
524 // be passed in messages, but are copied via DuplicateHandle(). | 526 // be passed in messages, but are copied via DuplicateHandle(). |
525 // This means the sandboxed renderer cannot send handles to the | 527 // This means the sandboxed renderer cannot send handles to the |
526 // browser process. | 528 // browser process. |
527 | 529 |
528 for (int i = 0; i < socket_count; i++) { | 530 for (int i = 0; i < socket_count; i++) { |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 } | 942 } |
941 #else | 943 #else |
942 // We use pid as process handle on Posix | 944 // We use pid as process handle on Posix |
943 nacl_process_handle = data.handle; | 945 nacl_process_handle = data.handle; |
944 #endif | 946 #endif |
945 | 947 |
946 // Get the pid of the NaCl process | 948 // Get the pid of the NaCl process |
947 base::ProcessId nacl_process_id = base::GetProcId(data.handle); | 949 base::ProcessId nacl_process_id = base::GetProcId(data.handle); |
948 | 950 |
949 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( | 951 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( |
950 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id); | 952 reply_msg_, handles_for_renderer, ppapi_channel_name_, |
| 953 nacl_process_handle, nacl_process_id); |
951 chrome_render_message_filter_->Send(reply_msg_); | 954 chrome_render_message_filter_->Send(reply_msg_); |
952 chrome_render_message_filter_ = NULL; | 955 chrome_render_message_filter_ = NULL; |
953 reply_msg_ = NULL; | 956 reply_msg_ = NULL; |
954 internal_->sockets_for_renderer.clear(); | 957 internal_->sockets_for_renderer.clear(); |
955 return true; | 958 return true; |
956 } | 959 } |
957 | 960 |
958 bool NaClProcessHost::StartNaClExecution() { | 961 bool NaClProcessHost::StartNaClExecution() { |
959 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 962 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
960 | 963 |
961 nacl::NaClStartParams params; | 964 nacl::NaClStartParams params; |
| 965 params.ppapi_channel_name = ppapi_channel_name_; |
962 params.validation_cache_key = nacl_browser->GetValidatorCacheKey(); | 966 params.validation_cache_key = nacl_browser->GetValidatorCacheKey(); |
963 params.version = chrome::VersionInfo().CreateVersionString(); | 967 params.version = chrome::VersionInfo().CreateVersionString(); |
964 params.enable_exception_handling = enable_exception_handling_; | 968 params.enable_exception_handling = enable_exception_handling_; |
965 | 969 |
966 base::PlatformFile irt_file = nacl_browser->IrtFile(); | 970 base::PlatformFile irt_file = nacl_browser->IrtFile(); |
967 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); | 971 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); |
968 | 972 |
969 const ChildProcessData& data = process_->GetData(); | 973 const ChildProcessData& data = process_->GetData(); |
970 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { | 974 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { |
971 if (!ShareHandleToSelLdr(data.handle, | 975 if (!ShareHandleToSelLdr(data.handle, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 } | 1049 } |
1046 | 1050 |
1047 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, | 1051 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, |
1048 bool* result) { | 1052 bool* result) { |
1049 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature); | 1053 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature); |
1050 } | 1054 } |
1051 | 1055 |
1052 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { | 1056 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { |
1053 NaClBrowser::GetInstance()->SetKnownToValidate(signature); | 1057 NaClBrowser::GetInstance()->SetKnownToValidate(signature); |
1054 } | 1058 } |
OLD | NEW |