| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mojo/mojo_child_connection.h" | 5 #include "content/browser/mojo/mojo_child_connection.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "content/public/common/mojo_shell_connection.h" | 10 #include "content/public/common/mojo_shell_connection.h" |
| 11 #include "mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 12 #include "mojo/public/cpp/system/message_pipe.h" | 12 #include "mojo/public/cpp/system/message_pipe.h" |
| 13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
| 14 #include "services/shell/public/cpp/identity.h" | 14 #include "services/shell/public/cpp/identity.h" |
| 15 #include "services/shell/public/interfaces/shell_client.mojom.h" | 15 #include "services/shell/public/interfaces/shell_client.mojom.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 MojoChildConnection::MojoChildConnection(const std::string& application_name, | 19 MojoChildConnection::MojoChildConnection(const std::string& application_name, |
| 20 const std::string& instance_id) | 20 const std::string& instance_id, |
| 21 const std::string& child_token) |
| 21 : shell_client_token_(mojo::edk::GenerateRandomToken()) { | 22 : shell_client_token_(mojo::edk::GenerateRandomToken()) { |
| 22 mojo::ScopedMessagePipeHandle shell_client_pipe = | 23 mojo::ScopedMessagePipeHandle shell_client_pipe = |
| 23 mojo::edk::CreateParentMessagePipe(shell_client_token_); | 24 mojo::edk::CreateParentMessagePipe(shell_client_token_, child_token); |
| 24 | 25 |
| 25 // Some process types get created before the main message loop. In this case | 26 // Some process types get created before the main message loop. In this case |
| 26 // the shell request pipe will simply be closed, and the child can detect | 27 // the shell request pipe will simply be closed, and the child can detect |
| 27 // this. | 28 // this. |
| 28 if (!MojoShellConnection::Get()) | 29 if (!MojoShellConnection::Get()) |
| 29 return; | 30 return; |
| 30 | 31 |
| 31 shell::mojom::ShellClientPtr client; | 32 shell::mojom::ShellClientPtr client; |
| 32 client.Bind(mojo::InterfacePtrInfo<shell::mojom::ShellClient>( | 33 client.Bind(mojo::InterfacePtrInfo<shell::mojom::ShellClient>( |
| 33 std::move(shell_client_pipe), 0u)); | 34 std::move(shell_client_pipe), 0u)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 MojoChildConnection::~MojoChildConnection() {} | 46 MojoChildConnection::~MojoChildConnection() {} |
| 46 | 47 |
| 47 void MojoChildConnection::SetProcessHandle(base::ProcessHandle handle) { | 48 void MojoChildConnection::SetProcessHandle(base::ProcessHandle handle) { |
| 48 DCHECK(pid_receiver_.is_bound()); | 49 DCHECK(pid_receiver_.is_bound()); |
| 49 pid_receiver_->SetPID(base::GetProcId(handle)); | 50 pid_receiver_->SetPID(base::GetProcId(handle)); |
| 50 pid_receiver_.reset(); | 51 pid_receiver_.reset(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace content | 54 } // namespace content |
| OLD | NEW |