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

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: rebase 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
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/in_process_child_thread_params.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 (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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 310
311 ChildThreadImpl::Options::Builder::Builder() { 311 ChildThreadImpl::Options::Builder::Builder() {
312 } 312 }
313 313
314 ChildThreadImpl::Options::Builder& 314 ChildThreadImpl::Options::Builder&
315 ChildThreadImpl::Options::Builder::InBrowserProcess( 315 ChildThreadImpl::Options::Builder::InBrowserProcess(
316 const InProcessChildThreadParams& params) { 316 const InProcessChildThreadParams& params) {
317 options_.browser_process_io_runner = params.io_runner(); 317 options_.browser_process_io_runner = params.io_runner();
318 options_.channel_name = params.channel_name(); 318 options_.channel_name = params.channel_name();
319 options_.in_process_ipc_token = params.ipc_token();
320 options_.in_process_application_token = params.application_token(); 319 options_.in_process_application_token = params.application_token();
321 return *this; 320 return *this;
322 } 321 }
323 322
324 ChildThreadImpl::Options::Builder& 323 ChildThreadImpl::Options::Builder&
325 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { 324 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) {
326 options_.use_mojo_channel = use_mojo_channel; 325 options_.use_mojo_channel = use_mojo_channel;
327 return *this; 326 return *this;
328 } 327 }
329 328
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 weak_factory_(this) { 395 weak_factory_(this) {
397 Init(options); 396 Init(options);
398 } 397 }
399 398
400 scoped_refptr<base::SequencedTaskRunner> ChildThreadImpl::GetIOTaskRunner() { 399 scoped_refptr<base::SequencedTaskRunner> ChildThreadImpl::GetIOTaskRunner() {
401 if (IsInBrowserProcess()) 400 if (IsInBrowserProcess())
402 return browser_process_io_runner_; 401 return browser_process_io_runner_;
403 return ChildProcess::current()->io_task_runner(); 402 return ChildProcess::current()->io_task_runner();
404 } 403 }
405 404
406 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel, 405 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
407 const std::string& ipc_token) {
408 bool create_pipe_now = true; 406 bool create_pipe_now = true;
409 if (use_mojo_channel) { 407 if (use_mojo_channel) {
410 VLOG(1) << "Mojo is enabled on child"; 408 VLOG(1) << "Mojo is enabled on child";
411 std::string channel_token; 409 std::string channel_token;
412 mojo::ScopedMessagePipeHandle handle; 410 mojo::ScopedMessagePipeHandle handle;
413 if (!IsInBrowserProcess()) { 411 if (!IsInBrowserProcess()) {
414 channel_token = 412 channel_token =
415 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 413 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
416 switches::kMojoChannelToken); 414 switches::kMojoChannelToken);
417 } else {
418 channel_token = ipc_token;
419 } 415 }
420 416
421 if (!channel_token.empty()) { 417 if (!channel_token.empty()) {
422 // TODO(rockot): Remove all paths which lead to this branch. The Channel 418 // TODO(rockot): Remove all paths which lead to this branch. The Channel
423 // connection should always be established by a shell connection from the 419 // connection should always be established by a shell connection from the
424 // browser. http://crbug.com/623396. 420 // browser. http://crbug.com/623396.
425 handle = mojo::edk::CreateChildMessagePipe(channel_token); 421 handle = mojo::edk::CreateChildMessagePipe(channel_token);
426 } else { 422 } else {
427 DCHECK(mojo_shell_connection_); 423 DCHECK(mojo_shell_connection_);
428 IPC::mojom::ChannelBootstrapPtr bootstrap; 424 IPC::mojom::ChannelBootstrapPtr bootstrap;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 559
564 // Add filters passed here via options. 560 // Add filters passed here via options.
565 for (auto* startup_filter : options.startup_filters) { 561 for (auto* startup_filter : options.startup_filters) {
566 channel_->AddFilter(startup_filter); 562 channel_->AddFilter(startup_filter);
567 } 563 }
568 564
569 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 565 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
570 if (broker && !broker->IsPrivilegedBroker()) 566 if (broker && !broker->IsPrivilegedBroker())
571 broker->RegisterBrokerCommunicationChannel(channel_.get()); 567 broker->RegisterBrokerCommunicationChannel(channel_.get());
572 568
573 ConnectChannel(options.use_mojo_channel, options.in_process_ipc_token); 569 ConnectChannel(options.use_mojo_channel);
574 570
575 // This must always be done after ConnectChannel, because ConnectChannel() may 571 // This must always be done after ConnectChannel, because ConnectChannel() may
576 // add a ConnectionFilter to the connection. 572 // add a ConnectionFilter to the connection.
577 if (options.auto_start_mojo_shell_connection && mojo_shell_connection_) 573 if (options.auto_start_mojo_shell_connection && mojo_shell_connection_)
578 StartMojoShellConnection(); 574 StartMojoShellConnection();
579 575
580 int connection_timeout = kConnectionTimeoutS; 576 int connection_timeout = kConnectionTimeoutS;
581 std::string connection_override = 577 std::string connection_override =
582 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 578 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
583 switches::kIPCConnectionTimeout); 579 switches::kIPCConnectionTimeout);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 void ChildThreadImpl::EnsureConnected() { 849 void ChildThreadImpl::EnsureConnected() {
854 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 850 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
855 base::Process::Current().Terminate(0, false); 851 base::Process::Current().Terminate(0, false);
856 } 852 }
857 853
858 bool ChildThreadImpl::IsInBrowserProcess() const { 854 bool ChildThreadImpl::IsInBrowserProcess() const {
859 return static_cast<bool>(browser_process_io_runner_); 855 return static_cast<bool>(browser_process_io_runner_);
860 } 856 }
861 857
862 } // namespace content 858 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/in_process_child_thread_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698