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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "components/nacl/common/nacl_switches.h" | 42 #include "components/nacl/common/nacl_switches.h" |
43 #include "components/url_formatter/url_formatter.h" | 43 #include "components/url_formatter/url_formatter.h" |
44 #include "content/public/browser/browser_child_process_host.h" | 44 #include "content/public/browser/browser_child_process_host.h" |
45 #include "content/public/browser/browser_ppapi_host.h" | 45 #include "content/public/browser/browser_ppapi_host.h" |
46 #include "content/public/browser/child_process_data.h" | 46 #include "content/public/browser/child_process_data.h" |
47 #include "content/public/browser/plugin_service.h" | 47 #include "content/public/browser/plugin_service.h" |
48 #include "content/public/browser/render_process_host.h" | 48 #include "content/public/browser/render_process_host.h" |
49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
50 #include "content/public/common/child_process_host.h" | 50 #include "content/public/common/child_process_host.h" |
51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
| 52 #include "content/public/common/mojo_channel_switches.h" |
52 #include "content/public/common/process_type.h" | 53 #include "content/public/common/process_type.h" |
53 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 54 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
54 #include "ipc/ipc_channel.h" | 55 #include "ipc/ipc_channel.h" |
55 #include "ipc/ipc_switches.h" | 56 #include "ipc/ipc_switches.h" |
| 57 #include "mojo/edk/embedder/embedder.h" |
56 #include "net/socket/socket_descriptor.h" | 58 #include "net/socket/socket_descriptor.h" |
57 #include "ppapi/host/host_factory.h" | 59 #include "ppapi/host/host_factory.h" |
58 #include "ppapi/host/ppapi_host.h" | 60 #include "ppapi/host/ppapi_host.h" |
59 #include "ppapi/proxy/ppapi_messages.h" | 61 #include "ppapi/proxy/ppapi_messages.h" |
60 #include "ppapi/shared_impl/ppapi_constants.h" | 62 #include "ppapi/shared_impl/ppapi_constants.h" |
61 #include "ppapi/shared_impl/ppapi_nacl_plugin_args.h" | 63 #include "ppapi/shared_impl/ppapi_nacl_plugin_args.h" |
62 | 64 |
63 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
64 | 66 |
65 #include <arpa/inet.h> | 67 #include <arpa/inet.h> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 #if defined(OS_WIN) | 302 #if defined(OS_WIN) |
301 debug_exception_handler_requested_(false), | 303 debug_exception_handler_requested_(false), |
302 #endif | 304 #endif |
303 uses_nonsfi_mode_(uses_nonsfi_mode), | 305 uses_nonsfi_mode_(uses_nonsfi_mode), |
304 enable_debug_stub_(false), | 306 enable_debug_stub_(false), |
305 enable_crash_throttling_(false), | 307 enable_crash_throttling_(false), |
306 off_the_record_(off_the_record), | 308 off_the_record_(off_the_record), |
307 process_type_(process_type), | 309 process_type_(process_type), |
308 profile_directory_(profile_directory), | 310 profile_directory_(profile_directory), |
309 render_view_id_(render_view_id), | 311 render_view_id_(render_view_id), |
| 312 mojo_child_token_(mojo::edk::GenerateRandomToken()), |
310 weak_factory_(this) { | 313 weak_factory_(this) { |
311 process_.reset(content::BrowserChildProcessHost::Create( | 314 process_.reset(content::BrowserChildProcessHost::Create( |
312 static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this)); | 315 static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this, |
| 316 mojo_child_token_)); |
313 | 317 |
314 // Set the display name so the user knows what plugin the process is running. | 318 // Set the display name so the user knows what plugin the process is running. |
315 // We aren't on the UI thread so getting the pref locale for language | 319 // We aren't on the UI thread so getting the pref locale for language |
316 // formatting isn't possible, so IDN will be lost, but this is probably OK | 320 // formatting isn't possible, so IDN will be lost, but this is probably OK |
317 // for this use case. | 321 // for this use case. |
318 process_->SetName(url_formatter::FormatUrl(manifest_url_)); | 322 process_->SetName(url_formatter::FormatUrl(manifest_url_)); |
319 | 323 |
320 enable_debug_stub_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 324 enable_debug_stub_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
321 switches::kEnableNaClDebug); | 325 switches::kEnableNaClDebug); |
322 DCHECK(process_type_ != kUnknownNaClProcessType); | 326 DCHECK(process_type_ != kUnknownNaClProcessType); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 base::FilePath script = | 574 base::FilePath script = |
571 command_line.GetSwitchValuePath(switches::kNaClGdbScript); | 575 command_line.GetSwitchValuePath(switches::kNaClGdbScript); |
572 if (!script.empty()) { | 576 if (!script.empty()) { |
573 cmd_line.AppendArg("--command"); | 577 cmd_line.AppendArg("--command"); |
574 cmd_line.AppendArgNative(script.value()); | 578 cmd_line.AppendArgNative(script.value()); |
575 } | 579 } |
576 base::LaunchProcess(cmd_line, base::LaunchOptions()); | 580 base::LaunchProcess(cmd_line, base::LaunchOptions()); |
577 } | 581 } |
578 | 582 |
579 bool NaClProcessHost::LaunchSelLdr() { | 583 bool NaClProcessHost::LaunchSelLdr() { |
580 std::string channel_id = process_->GetHost()->CreateChannel(); | 584 DCHECK(!mojo_child_token_.empty()); |
581 if (channel_id.empty()) { | 585 std::string mojo_channel_token = |
582 SendErrorToRenderer("CreateChannel() failed"); | 586 process_->GetHost()->CreateChannelMojo(mojo_child_token_); |
| 587 // |mojo_child_token_| is no longer used. |
| 588 mojo_child_token_.clear(); |
| 589 mojo_child_token_.shrink_to_fit(); |
| 590 if (mojo_channel_token.empty()) { |
| 591 SendErrorToRenderer("CreateChannelMojo() failed"); |
583 return false; | 592 return false; |
584 } | 593 } |
585 | 594 |
586 // Build command line for nacl. | 595 // Build command line for nacl. |
587 | 596 |
588 #if defined(OS_LINUX) | 597 #if defined(OS_LINUX) |
589 int flags = ChildProcessHost::CHILD_ALLOW_SELF; | 598 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
590 #else | 599 #else |
591 int flags = ChildProcessHost::CHILD_NORMAL; | 600 int flags = ChildProcessHost::CHILD_NORMAL; |
592 #endif | 601 #endif |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 641 } |
633 #endif | 642 #endif |
634 | 643 |
635 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); | 644 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); |
636 CopyNaClCommandLineArguments(cmd_line.get()); | 645 CopyNaClCommandLineArguments(cmd_line.get()); |
637 | 646 |
638 cmd_line->AppendSwitchASCII(switches::kProcessType, | 647 cmd_line->AppendSwitchASCII(switches::kProcessType, |
639 (uses_nonsfi_mode_ ? | 648 (uses_nonsfi_mode_ ? |
640 switches::kNaClLoaderNonSfiProcess : | 649 switches::kNaClLoaderNonSfiProcess : |
641 switches::kNaClLoaderProcess)); | 650 switches::kNaClLoaderProcess)); |
642 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 651 cmd_line->AppendSwitchASCII(switches::kMojoChannelToken, mojo_channel_token); |
643 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) | 652 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) |
644 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 653 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
645 | 654 |
646 #if defined(OS_WIN) | 655 #if defined(OS_WIN) |
647 cmd_line->AppendArg(switches::kPrefetchArgumentOther); | 656 cmd_line->AppendArg(switches::kPrefetchArgumentOther); |
648 #endif // defined(OS_WIN) | 657 #endif // defined(OS_WIN) |
649 | 658 |
650 // On Windows we might need to start the broker process to launch a new loader | 659 // On Windows we might need to start the broker process to launch a new loader |
651 #if defined(OS_WIN) | 660 #if defined(OS_WIN) |
652 if (RunningOnWOW64()) { | 661 if (RunningOnWOW64()) { |
653 if (!NaClBrokerService::GetInstance()->LaunchLoader( | 662 if (!NaClBrokerService::GetInstance()->LaunchLoader( |
654 weak_factory_.GetWeakPtr(), channel_id)) { | 663 weak_factory_.GetWeakPtr(), mojo_channel_token)) { |
655 SendErrorToRenderer("broker service did not launch process"); | 664 SendErrorToRenderer("broker service did not launch process"); |
656 return false; | 665 return false; |
657 } | 666 } |
658 return true; | 667 return true; |
659 } | 668 } |
660 #endif | 669 #endif |
661 process_->Launch( | 670 process_->Launch( |
662 new NaClSandboxedProcessLauncherDelegate(process_->GetHost()), | 671 new NaClSandboxedProcessLauncherDelegate(process_->GetHost()), |
663 cmd_line.release(), | 672 cmd_line.release(), |
664 true); | 673 true); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 NaClStartDebugExceptionHandlerThread( | 1299 NaClStartDebugExceptionHandlerThread( |
1291 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1300 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
1292 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1301 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1293 weak_factory_.GetWeakPtr())); | 1302 weak_factory_.GetWeakPtr())); |
1294 return true; | 1303 return true; |
1295 } | 1304 } |
1296 } | 1305 } |
1297 #endif | 1306 #endif |
1298 | 1307 |
1299 } // namespace nacl | 1308 } // namespace nacl |
OLD | NEW |