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

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 1460713002: Revert of Bind Application in renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/mojo/mojo_shell_client_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/i18n/icu_util.h" 10 #include "base/i18n/icu_util.h"
(...skipping 30 matching lines...) Expand all
41 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 41 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
42 #include "content/common/child_process_sandbox_support_impl_linux.h" 42 #include "content/common/child_process_sandbox_support_impl_linux.h"
43 #endif 43 #endif
44 44
45 #if defined(OS_POSIX) 45 #if defined(OS_POSIX)
46 #include "base/posix/global_descriptors.h" 46 #include "base/posix/global_descriptors.h"
47 #include "content/browser/file_descriptor_info_impl.h" 47 #include "content/browser/file_descriptor_info_impl.h"
48 #include "gin/v8_initializer.h" 48 #include "gin/v8_initializer.h"
49 #endif 49 #endif
50 50
51 #if defined(MOJO_SHELL_CLIENT)
52 #include "base/thread_task_runner_handle.h"
53 #include "content/public/common/mojo_shell_connection.h"
54 #include "mojo/application/public/cpp/application_impl.h"
55 #include "mojo/converters/network/network_type_converters.h"
56 #include "mojo/shell/application_manager.mojom.h"
57 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
58 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h"
59 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
60 #endif
61
51 namespace content { 62 namespace content {
52 63
53 namespace { 64 namespace {
54 65
55 typedef base::Callback<void(bool, 66 typedef base::Callback<void(bool,
56 #if defined(OS_ANDROID) 67 #if defined(OS_ANDROID)
57 base::ScopedFD, 68 base::ScopedFD,
58 #endif 69 #endif
59 base::Process)> NotifyCallback; 70 base::Process)> NotifyCallback;
60 71
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 bool background) { 326 bool background) {
316 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); 327 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
317 if (process.CanBackgroundProcesses()) { 328 if (process.CanBackgroundProcesses()) {
318 process.SetProcessBackgrounded(background); 329 process.SetProcessBackgrounded(background);
319 } 330 }
320 #if defined(OS_ANDROID) 331 #if defined(OS_ANDROID)
321 SetChildProcessInForeground(process.Handle(), !background); 332 SetChildProcessInForeground(process.Handle(), !background);
322 #endif 333 #endif
323 } 334 }
324 335
336 #if defined(MOJO_SHELL_CLIENT)
337 void DidCreateChannel(mojo::embedder::ChannelInfo* info) {}
338 #endif
339
325 } // namespace 340 } // namespace
326 341
327 ChildProcessLauncher::ChildProcessLauncher( 342 ChildProcessLauncher::ChildProcessLauncher(
328 SandboxedProcessLauncherDelegate* delegate, 343 SandboxedProcessLauncherDelegate* delegate,
329 base::CommandLine* cmd_line, 344 base::CommandLine* cmd_line,
330 int child_process_id, 345 int child_process_id,
331 Client* client, 346 Client* client,
332 bool terminate_on_shutdown) 347 bool terminate_on_shutdown)
333 : client_(client), 348 : client_(client),
334 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION), 349 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION),
(...skipping 23 matching lines...) Expand all
358 base::Passed(&process_))); 373 base::Passed(&process_)));
359 } 374 }
360 } 375 }
361 376
362 void ChildProcessLauncher::Launch( 377 void ChildProcessLauncher::Launch(
363 SandboxedProcessLauncherDelegate* delegate, 378 SandboxedProcessLauncherDelegate* delegate,
364 base::CommandLine* cmd_line, 379 base::CommandLine* cmd_line,
365 int child_process_id) { 380 int child_process_id) {
366 DCHECK(CalledOnValidThread()); 381 DCHECK(CalledOnValidThread());
367 382
383 #if defined(MOJO_SHELL_CLIENT)
384 CreateMojoShellChannel(cmd_line, child_process_id);
385 #endif
386
368 #if defined(OS_ANDROID) 387 #if defined(OS_ANDROID)
369 // Android only supports renderer, sandboxed utility and gpu. 388 // Android only supports renderer, sandboxed utility and gpu.
370 std::string process_type = 389 std::string process_type =
371 cmd_line->GetSwitchValueASCII(switches::kProcessType); 390 cmd_line->GetSwitchValueASCII(switches::kProcessType);
372 CHECK(process_type == switches::kGpuProcess || 391 CHECK(process_type == switches::kGpuProcess ||
373 process_type == switches::kRendererProcess || 392 process_type == switches::kRendererProcess ||
374 #if defined(ENABLE_PLUGINS) 393 #if defined(ENABLE_PLUGINS)
375 process_type == switches::kPpapiPluginProcess || 394 process_type == switches::kPpapiPluginProcess ||
376 #endif 395 #endif
377 process_type == switches::kUtilityProcess) 396 process_type == switches::kUtilityProcess)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 516 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841
498 // is fixed. 517 // is fixed.
499 tracked_objects::ScopedTracker tracking_profile3( 518 tracked_objects::ScopedTracker tracking_profile3(
500 FROM_HERE_WITH_EXPLICIT_FUNCTION( 519 FROM_HERE_WITH_EXPLICIT_FUNCTION(
501 "465841 ChildProcessLauncher::Context::Notify::ProcessFailed")); 520 "465841 ChildProcessLauncher::Context::Notify::ProcessFailed"));
502 termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED; 521 termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED;
503 client_->OnProcessLaunchFailed(); 522 client_->OnProcessLaunchFailed();
504 } 523 }
505 } 524 }
506 525
526 #if defined(MOJO_SHELL_CLIENT)
527 void ChildProcessLauncher::CreateMojoShellChannel(
528 base::CommandLine* command_line,
529 int child_process_id) {
530 // Some process types get created before the main message loop.
531 if (!MojoShellConnection::Get())
532 return;
533
534 // Create the channel to be shared with the target process.
535 mojo::embedder::HandlePassingInformation handle_passing_info;
536 mojo::embedder::PlatformChannelPair platform_channel_pair;
537
538 // Give one end to the shell so that it can create an instance.
539 mojo::embedder::ScopedPlatformHandle platform_channel =
540 platform_channel_pair.PassServerHandle();
541 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel(
542 platform_channel.Pass(), base::Bind(&DidCreateChannel),
543 base::ThreadTaskRunnerHandle::Get()));
544 mojo::shell::mojom::ApplicationManagerPtr application_manager;
545 MojoShellConnection::Get()->GetApplication()->ConnectToService(
546 mojo::URLRequest::From(std::string("mojo:shell")),
547 &application_manager);
548 // The content of the URL/qualifier we pass is actually meaningless, it's only
549 // important that they're unique per process.
550 // TODO(beng): We need to specify a restrictive CapabilityFilter here that
551 // matches the needs of the target process. Figure out where that
552 // specification is best determined (not here, this is a common
553 // chokepoint for all process types) and how to wire it through.
554 // http://crbug.com/555393
555 application_manager->CreateInstanceForHandle(
556 mojo::ScopedHandle(mojo::Handle(handle.release().value())),
557 "exe:chrome_renderer", // See above about how this string is meaningless.
558 base::IntToString(child_process_id));
559
560 // Put the other end on the command line used to launch the target.
561 platform_channel_pair.PrepareToPassClientHandleToChildProcess(
562 command_line, &handle_passing_info);
563 }
564 #endif // defined(MOJO_SHELL_CLIENT)
565
507 bool ChildProcessLauncher::IsStarting() { 566 bool ChildProcessLauncher::IsStarting() {
508 // TODO(crbug.com/469248): This fails in some tests. 567 // TODO(crbug.com/469248): This fails in some tests.
509 // DCHECK(CalledOnValidThread()); 568 // DCHECK(CalledOnValidThread());
510 return starting_; 569 return starting_;
511 } 570 }
512 571
513 const base::Process& ChildProcessLauncher::GetProcess() const { 572 const base::Process& ChildProcessLauncher::GetProcess() const {
514 // TODO(crbug.com/469248): This fails in some tests. 573 // TODO(crbug.com/469248): This fails in some tests.
515 // DCHECK(CalledOnValidThread()); 574 // DCHECK(CalledOnValidThread());
516 return process_; 575 return process_;
(...skipping 27 matching lines...) Expand all
544 } 603 }
545 604
546 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 605 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
547 Client* client) { 606 Client* client) {
548 Client* ret = client_; 607 Client* ret = client_;
549 client_ = client; 608 client_ = client;
550 return ret; 609 return ret;
551 } 610 }
552 611
553 } // namespace content 612 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/mojo/mojo_shell_client_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698