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

Side by Side Diff: content/child/child_thread_impl.cc

Issue 2226403002: Remove Channel token from InProcessChildThreadParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moar-channels
Patch Set: . Created 4 years, 4 months 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
OLDNEW
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 "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 312
313 ChildThreadImpl::Options::Builder::Builder() { 313 ChildThreadImpl::Options::Builder::Builder() {
314 } 314 }
315 315
316 ChildThreadImpl::Options::Builder& 316 ChildThreadImpl::Options::Builder&
317 ChildThreadImpl::Options::Builder::InBrowserProcess( 317 ChildThreadImpl::Options::Builder::InBrowserProcess(
318 const InProcessChildThreadParams& params) { 318 const InProcessChildThreadParams& params) {
319 options_.browser_process_io_runner = params.io_runner(); 319 options_.browser_process_io_runner = params.io_runner();
320 options_.channel_name = params.channel_name(); 320 options_.channel_name = params.channel_name();
321 options_.in_process_ipc_token = params.ipc_token();
322 options_.in_process_application_token = params.application_token(); 321 options_.in_process_application_token = params.application_token();
323 return *this; 322 return *this;
324 } 323 }
325 324
326 ChildThreadImpl::Options::Builder& 325 ChildThreadImpl::Options::Builder&
327 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { 326 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) {
328 options_.use_mojo_channel = use_mojo_channel; 327 options_.use_mojo_channel = use_mojo_channel;
329 return *this; 328 return *this;
330 } 329 }
331 330
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 weak_factory_(this) { 397 weak_factory_(this) {
399 Init(options); 398 Init(options);
400 } 399 }
401 400
402 scoped_refptr<base::SequencedTaskRunner> ChildThreadImpl::GetIOTaskRunner() { 401 scoped_refptr<base::SequencedTaskRunner> ChildThreadImpl::GetIOTaskRunner() {
403 if (IsInBrowserProcess()) 402 if (IsInBrowserProcess())
404 return browser_process_io_runner_; 403 return browser_process_io_runner_;
405 return ChildProcess::current()->io_task_runner(); 404 return ChildProcess::current()->io_task_runner();
406 } 405 }
407 406
408 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel, 407 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
409 const std::string& ipc_token) {
410 bool create_pipe_now = true; 408 bool create_pipe_now = true;
411 if (use_mojo_channel) { 409 if (use_mojo_channel) {
412 VLOG(1) << "Mojo is enabled on child"; 410 VLOG(1) << "Mojo is enabled on child";
413 std::string channel_token; 411 std::string channel_token;
414 mojo::ScopedMessagePipeHandle handle; 412 mojo::ScopedMessagePipeHandle handle;
415 if (!IsInBrowserProcess()) { 413 if (!IsInBrowserProcess()) {
416 channel_token = 414 channel_token =
417 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 415 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
418 switches::kMojoChannelToken); 416 switches::kMojoChannelToken);
419 } else {
420 channel_token = ipc_token;
421 } 417 }
422 418
423 if (!channel_token.empty()) { 419 if (!channel_token.empty()) {
424 // TODO(rockot): Remove all paths which lead to this branch. The Channel 420 // TODO(rockot): Remove all paths which lead to this branch. The Channel
425 // connection should always be established by a shell connection from the 421 // connection should always be established by a shell connection from the
426 // browser. http://crbug.com/623396. 422 // browser. http://crbug.com/623396.
427 handle = mojo::edk::CreateChildMessagePipe(channel_token); 423 handle = mojo::edk::CreateChildMessagePipe(channel_token);
428 } else { 424 } else {
429 DCHECK(mojo_shell_connection_); 425 DCHECK(mojo_shell_connection_);
430 IPC::mojom::ChannelBootstrapPtr bootstrap; 426 IPC::mojom::ChannelBootstrapPtr bootstrap;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 566
571 // Add filters passed here via options. 567 // Add filters passed here via options.
572 for (auto* startup_filter : options.startup_filters) { 568 for (auto* startup_filter : options.startup_filters) {
573 channel_->AddFilter(startup_filter); 569 channel_->AddFilter(startup_filter);
574 } 570 }
575 571
576 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 572 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
577 if (broker && !broker->IsPrivilegedBroker()) 573 if (broker && !broker->IsPrivilegedBroker())
578 broker->RegisterBrokerCommunicationChannel(channel_.get()); 574 broker->RegisterBrokerCommunicationChannel(channel_.get());
579 575
580 ConnectChannel(options.use_mojo_channel, options.in_process_ipc_token); 576 ConnectChannel(options.use_mojo_channel);
581 577
582 // This must always be done after ConnectChannel, because ConnectChannel() may 578 // This must always be done after ConnectChannel, because ConnectChannel() may
583 // add a ConnectionFilter to the connection. 579 // add a ConnectionFilter to the connection.
584 if (options.auto_start_mojo_shell_connection && mojo_shell_connection_) 580 if (options.auto_start_mojo_shell_connection && mojo_shell_connection_)
585 StartMojoShellConnection(); 581 StartMojoShellConnection();
586 582
587 int connection_timeout = kConnectionTimeoutS; 583 int connection_timeout = kConnectionTimeoutS;
588 std::string connection_override = 584 std::string connection_override =
589 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 585 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
590 switches::kIPCConnectionTimeout); 586 switches::kIPCConnectionTimeout);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 void ChildThreadImpl::EnsureConnected() { 856 void ChildThreadImpl::EnsureConnected() {
861 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 857 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
862 base::Process::Current().Terminate(0, false); 858 base::Process::Current().Terminate(0, false);
863 } 859 }
864 860
865 bool ChildThreadImpl::IsInBrowserProcess() const { 861 bool ChildThreadImpl::IsInBrowserProcess() const {
866 return static_cast<bool>(browser_process_io_runner_); 862 return static_cast<bool>(browser_process_io_runner_);
867 } 863 }
868 864
869 } // namespace content 865 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698