1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/task/single_thread_task_runner.h"
6 #include "build/build_config.h"
7 #include "ipc/ipc_channel.h"
8 #include "ipc/ipc_channel_mojo.h"
9 #include "mojo/public/cpp/system/message_pipe.h"
13 #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
20 void Channel::SetGlobalPid(int pid) {
25 int Channel::GetGlobalPid() {
29 #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
32 std::unique_ptr<Channel> Channel::CreateClient(
33 const IPC::ChannelHandle& channel_handle,
35 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
36 #if BUILDFLAG(IS_NACL)
37 return Channel::Create(channel_handle, Channel::MODE_CLIENT, listener);
39 DCHECK(channel_handle.is_mojo_channel_handle());
40 return ChannelMojo::Create(
41 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
42 Channel::MODE_CLIENT, listener, ipc_task_runner,
43 base::SingleThreadTaskRunner::GetCurrentDefault());
48 std::unique_ptr<Channel> Channel::CreateServer(
49 const IPC::ChannelHandle& channel_handle,
51 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
52 #if BUILDFLAG(IS_NACL)
53 return Channel::Create(channel_handle, Channel::MODE_SERVER, listener);
55 DCHECK(channel_handle.is_mojo_channel_handle());
56 return ChannelMojo::Create(
57 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
58 Channel::MODE_SERVER, listener, ipc_task_runner,
59 base::SingleThreadTaskRunner::GetCurrentDefault());
63 Channel::~Channel() = default;
65 Channel::AssociatedInterfaceSupport* Channel::GetAssociatedInterfaceSupport() {
69 void Channel::Pause() { NOTREACHED(); }
71 void Channel::Unpause(bool flush) { NOTREACHED(); }
73 void Channel::Flush() { NOTREACHED(); }
75 void Channel::WillConnect() {
76 did_start_connect_ = true;