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 std::string mojo_channel_token = |
581 if (channel_id.empty()) { | 585 process_->GetHost()->CreateChannelMojo(mojo_child_token_); |
582 SendErrorToRenderer("CreateChannel() failed"); | 586 if (mojo_channel_token.empty()) { |
| 587 SendErrorToRenderer("CreateChannelMojo() failed"); |
583 return false; | 588 return false; |
584 } | 589 } |
585 | 590 |
586 // Build command line for nacl. | 591 // Build command line for nacl. |
587 | 592 |
588 #if defined(OS_LINUX) | 593 #if defined(OS_LINUX) |
589 int flags = ChildProcessHost::CHILD_ALLOW_SELF; | 594 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
590 #else | 595 #else |
591 int flags = ChildProcessHost::CHILD_NORMAL; | 596 int flags = ChildProcessHost::CHILD_NORMAL; |
592 #endif | 597 #endif |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 637 } |
633 #endif | 638 #endif |
634 | 639 |
635 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); | 640 std::unique_ptr<base::CommandLine> cmd_line(new base::CommandLine(exe_path)); |
636 CopyNaClCommandLineArguments(cmd_line.get()); | 641 CopyNaClCommandLineArguments(cmd_line.get()); |
637 | 642 |
638 cmd_line->AppendSwitchASCII(switches::kProcessType, | 643 cmd_line->AppendSwitchASCII(switches::kProcessType, |
639 (uses_nonsfi_mode_ ? | 644 (uses_nonsfi_mode_ ? |
640 switches::kNaClLoaderNonSfiProcess : | 645 switches::kNaClLoaderNonSfiProcess : |
641 switches::kNaClLoaderProcess)); | 646 switches::kNaClLoaderProcess)); |
642 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 647 cmd_line->AppendSwitchASCII(switches::kMojoChannelToken, mojo_channel_token); |
643 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) | 648 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) |
644 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 649 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
645 | 650 |
646 #if defined(OS_WIN) | 651 #if defined(OS_WIN) |
647 cmd_line->AppendArg(switches::kPrefetchArgumentOther); | 652 cmd_line->AppendArg(switches::kPrefetchArgumentOther); |
648 #endif // defined(OS_WIN) | 653 #endif // defined(OS_WIN) |
649 | 654 |
650 // On Windows we might need to start the broker process to launch a new loader | 655 // On Windows we might need to start the broker process to launch a new loader |
651 #if defined(OS_WIN) | 656 #if defined(OS_WIN) |
652 if (RunningOnWOW64()) { | 657 if (RunningOnWOW64()) { |
653 if (!NaClBrokerService::GetInstance()->LaunchLoader( | 658 if (!NaClBrokerService::GetInstance()->LaunchLoader( |
654 weak_factory_.GetWeakPtr(), channel_id)) { | 659 weak_factory_.GetWeakPtr(), mojo_channel_token)) { |
655 SendErrorToRenderer("broker service did not launch process"); | 660 SendErrorToRenderer("broker service did not launch process"); |
656 return false; | 661 return false; |
657 } | 662 } |
658 return true; | 663 return true; |
659 } | 664 } |
660 #endif | 665 #endif |
661 process_->Launch( | 666 process_->Launch( |
662 new NaClSandboxedProcessLauncherDelegate(process_->GetHost()), | 667 new NaClSandboxedProcessLauncherDelegate(process_->GetHost()), |
663 cmd_line.release(), | 668 cmd_line.release(), |
664 true); | 669 true); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 NaClStartDebugExceptionHandlerThread( | 1295 NaClStartDebugExceptionHandlerThread( |
1291 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1296 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
1292 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1297 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1293 weak_factory_.GetWeakPtr())); | 1298 weak_factory_.GetWeakPtr())); |
1294 return true; | 1299 return true; |
1295 } | 1300 } |
1296 } | 1301 } |
1297 #endif | 1302 #endif |
1298 | 1303 |
1299 } // namespace nacl | 1304 } // namespace nacl |
OLD | NEW |