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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
31 #include "base/sys_byteorder.h" | 31 #include "base/sys_byteorder.h" |
32 #include "base/threading/sequenced_worker_pool.h" | 32 #include "base/threading/sequenced_worker_pool.h" |
33 #include "base/threading/thread_task_runner_handle.h" | 33 #include "base/threading/thread_task_runner_handle.h" |
34 #include "base/win/windows_version.h" | 34 #include "base/win/windows_version.h" |
35 #include "build/build_config.h" | 35 #include "build/build_config.h" |
36 #include "components/nacl/browser/nacl_browser.h" | 36 #include "components/nacl/browser/nacl_browser.h" |
37 #include "components/nacl/browser/nacl_browser_delegate.h" | 37 #include "components/nacl/browser/nacl_browser_delegate.h" |
38 #include "components/nacl/browser/nacl_host_message_filter.h" | 38 #include "components/nacl/browser/nacl_host_message_filter.h" |
39 #include "components/nacl/common/nacl_cmd_line.h" | 39 #include "components/nacl/common/nacl_cmd_line.h" |
| 40 #include "components/nacl/common/nacl_constants.h" |
40 #include "components/nacl/common/nacl_host_messages.h" | 41 #include "components/nacl/common/nacl_host_messages.h" |
41 #include "components/nacl/common/nacl_messages.h" | 42 #include "components/nacl/common/nacl_messages.h" |
42 #include "components/nacl/common/nacl_process_type.h" | 43 #include "components/nacl/common/nacl_process_type.h" |
43 #include "components/nacl/common/nacl_switches.h" | 44 #include "components/nacl/common/nacl_switches.h" |
44 #include "components/url_formatter/url_formatter.h" | 45 #include "components/url_formatter/url_formatter.h" |
45 #include "content/public/browser/browser_child_process_host.h" | 46 #include "content/public/browser/browser_child_process_host.h" |
46 #include "content/public/browser/browser_ppapi_host.h" | 47 #include "content/public/browser/browser_ppapi_host.h" |
47 #include "content/public/browser/child_process_data.h" | 48 #include "content/public/browser/child_process_data.h" |
48 #include "content/public/browser/plugin_service.h" | 49 #include "content/public/browser/plugin_service.h" |
49 #include "content/public/browser/render_process_host.h" | 50 #include "content/public/browser/render_process_host.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 #if defined(OS_WIN) | 222 #if defined(OS_WIN) |
222 debug_exception_handler_requested_(false), | 223 debug_exception_handler_requested_(false), |
223 #endif | 224 #endif |
224 uses_nonsfi_mode_(uses_nonsfi_mode), | 225 uses_nonsfi_mode_(uses_nonsfi_mode), |
225 enable_debug_stub_(false), | 226 enable_debug_stub_(false), |
226 enable_crash_throttling_(false), | 227 enable_crash_throttling_(false), |
227 off_the_record_(off_the_record), | 228 off_the_record_(off_the_record), |
228 process_type_(process_type), | 229 process_type_(process_type), |
229 profile_directory_(profile_directory), | 230 profile_directory_(profile_directory), |
230 render_view_id_(render_view_id), | 231 render_view_id_(render_view_id), |
231 mojo_child_token_(mojo::edk::GenerateRandomToken()), | |
232 weak_factory_(this) { | 232 weak_factory_(this) { |
233 process_.reset(content::BrowserChildProcessHost::Create( | 233 process_.reset(content::BrowserChildProcessHost::Create( |
234 static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this, | 234 static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this, |
235 mojo_child_token_)); | 235 kNaClLoaderServiceName)); |
236 | 236 |
237 // Set the display name so the user knows what plugin the process is running. | 237 // Set the display name so the user knows what plugin the process is running. |
238 // We aren't on the UI thread so getting the pref locale for language | 238 // We aren't on the UI thread so getting the pref locale for language |
239 // formatting isn't possible, so IDN will be lost, but this is probably OK | 239 // formatting isn't possible, so IDN will be lost, but this is probably OK |
240 // for this use case. | 240 // for this use case. |
241 process_->SetName(url_formatter::FormatUrl(manifest_url_)); | 241 process_->SetName(url_formatter::FormatUrl(manifest_url_)); |
242 | 242 |
243 enable_debug_stub_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 243 enable_debug_stub_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
244 switches::kEnableNaClDebug); | 244 switches::kEnableNaClDebug); |
245 DCHECK(process_type_ != kUnknownNaClProcessType); | 245 DCHECK(process_type_ != kUnknownNaClProcessType); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 base::FilePath script = | 493 base::FilePath script = |
494 command_line.GetSwitchValuePath(switches::kNaClGdbScript); | 494 command_line.GetSwitchValuePath(switches::kNaClGdbScript); |
495 if (!script.empty()) { | 495 if (!script.empty()) { |
496 cmd_line.AppendArg("--command"); | 496 cmd_line.AppendArg("--command"); |
497 cmd_line.AppendArgNative(script.value()); | 497 cmd_line.AppendArgNative(script.value()); |
498 } | 498 } |
499 base::LaunchProcess(cmd_line, base::LaunchOptions()); | 499 base::LaunchProcess(cmd_line, base::LaunchOptions()); |
500 } | 500 } |
501 | 501 |
502 bool NaClProcessHost::LaunchSelLdr() { | 502 bool NaClProcessHost::LaunchSelLdr() { |
503 DCHECK(!mojo_child_token_.empty()); | 503 process_->GetHost()->CreateChannelMojo(); |
504 std::string mojo_channel_token = | |
505 process_->GetHost()->CreateChannelMojo(mojo_child_token_); | |
506 // |mojo_child_token_| is no longer used. | |
507 base::STLClearObject(&mojo_child_token_); | |
508 if (mojo_channel_token.empty()) { | |
509 SendErrorToRenderer("CreateChannelMojo() failed"); | |
510 return false; | |
511 } | |
512 | 504 |
513 // Build command line for nacl. | 505 // Build command line for nacl. |
514 | 506 |
515 #if defined(OS_LINUX) | 507 #if defined(OS_LINUX) |
516 int flags = ChildProcessHost::CHILD_ALLOW_SELF; | 508 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
517 #else | 509 #else |
518 int flags = ChildProcessHost::CHILD_NORMAL; | 510 int flags = ChildProcessHost::CHILD_NORMAL; |
519 #endif | 511 #endif |
520 | 512 |
521 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); | 513 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 551 } |
560 #endif | 552 #endif |
561 | 553 |
562 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); | 554 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); |
563 CopyNaClCommandLineArguments(cmd_line.get()); | 555 CopyNaClCommandLineArguments(cmd_line.get()); |
564 | 556 |
565 cmd_line->AppendSwitchASCII(switches::kProcessType, | 557 cmd_line->AppendSwitchASCII(switches::kProcessType, |
566 (uses_nonsfi_mode_ ? | 558 (uses_nonsfi_mode_ ? |
567 switches::kNaClLoaderNonSfiProcess : | 559 switches::kNaClLoaderNonSfiProcess : |
568 switches::kNaClLoaderProcess)); | 560 switches::kNaClLoaderProcess)); |
569 cmd_line->AppendSwitchASCII(switches::kMojoChannelToken, mojo_channel_token); | |
570 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) | 561 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) |
571 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 562 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
572 | 563 |
573 #if defined(OS_WIN) | 564 #if defined(OS_WIN) |
574 cmd_line->AppendArg(switches::kPrefetchArgumentOther); | 565 cmd_line->AppendArg(switches::kPrefetchArgumentOther); |
575 #endif // defined(OS_WIN) | 566 #endif // defined(OS_WIN) |
576 | 567 |
577 // On Windows we might need to start the broker process to launch a new loader | 568 // On Windows we might need to start the broker process to launch a new loader |
578 #if defined(OS_WIN) | 569 #if defined(OS_WIN) |
579 if (RunningOnWOW64()) { | 570 if (RunningOnWOW64()) { |
580 if (!NaClBrokerService::GetInstance()->LaunchLoader( | 571 if (!NaClBrokerService::GetInstance()->LaunchLoader( |
581 weak_factory_.GetWeakPtr(), mojo_channel_token)) { | 572 weak_factory_.GetWeakPtr(), |
| 573 process_->GetServiceRequestChannelToken())) { |
582 SendErrorToRenderer("broker service did not launch process"); | 574 SendErrorToRenderer("broker service did not launch process"); |
583 return false; | 575 return false; |
584 } | 576 } |
585 return true; | 577 return true; |
586 } | 578 } |
587 #endif | 579 #endif |
588 process_->Launch(new NaClSandboxedProcessLauncherDelegate(), | 580 process_->Launch(new NaClSandboxedProcessLauncherDelegate(), |
589 cmd_line.release(), true); | 581 cmd_line.release(), true); |
590 return true; | 582 return true; |
591 } | 583 } |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 NaClStartDebugExceptionHandlerThread( | 1164 NaClStartDebugExceptionHandlerThread( |
1173 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1165 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
1174 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1166 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1175 weak_factory_.GetWeakPtr())); | 1167 weak_factory_.GetWeakPtr())); |
1176 return true; | 1168 return true; |
1177 } | 1169 } |
1178 } | 1170 } |
1179 #endif | 1171 #endif |
1180 | 1172 |
1181 } // namespace nacl | 1173 } // namespace nacl |
OLD | NEW |