blob: 7afb12d9b0c7a6ff97f45b740d0ba5cdf9e26a59 [file] [log] [blame]
[email protected]e482111a82014-05-30 03:58:591// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
avi246998d82015-12-22 02:39:045#include "build/build_config.h"
[email protected]e482111a82014-05-30 03:58:596#include "ipc/ipc_channel.h"
amistry36182522016-06-27 06:34:427#include "ipc/ipc_channel_mojo.h"
amistry9fdf3202016-06-30 06:56:078#include "mojo/public/cpp/system/message_pipe.h"
[email protected]e482111a82014-05-30 03:58:599
10namespace IPC {
11
sammcbeeed3682016-11-08 23:24:3512#if defined(OS_LINUX)
13
14namespace {
15int g_global_pid = 0;
16}
17
18// static
19void Channel::SetGlobalPid(int pid) {
20 g_global_pid = pid;
21}
22
23// static
24int Channel::GetGlobalPid() {
25 return g_global_pid;
26}
27
28#endif // defined(OS_LINUX)
29
[email protected]e482111a82014-05-30 03:58:5930// static
danakj03de39b22016-04-23 04:21:0931std::unique_ptr<Channel> Channel::CreateClient(
erikchen27aa7d82015-06-16 21:21:0432 const IPC::ChannelHandle& channel_handle,
rockota34707ca2016-07-20 04:28:3233 Listener* listener,
34 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
sammcbeeed3682016-11-08 23:24:3535#if defined(OS_NACL_SFI)
erikchen30dc2812015-09-24 03:26:3836 return Channel::Create(channel_handle, Channel::MODE_CLIENT, listener);
sammcbeeed3682016-11-08 23:24:3537#else
38 DCHECK(channel_handle.is_mojo_channel_handle());
39 return ChannelMojo::Create(
40 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
Hajime Hoshife3ecdc2017-11-28 03:34:1341 Channel::MODE_CLIENT, listener, ipc_task_runner,
42 base::ThreadTaskRunnerHandle::Get());
sammcbeeed3682016-11-08 23:24:3543#endif
[email protected]e482111a82014-05-30 03:58:5944}
45
[email protected]e482111a82014-05-30 03:58:5946// static
danakj03de39b22016-04-23 04:21:0947std::unique_ptr<Channel> Channel::CreateServer(
erikchen27aa7d82015-06-16 21:21:0448 const IPC::ChannelHandle& channel_handle,
rockota34707ca2016-07-20 04:28:3249 Listener* listener,
50 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
sammcbeeed3682016-11-08 23:24:3551#if defined(OS_NACL_SFI)
erikchen30dc2812015-09-24 03:26:3852 return Channel::Create(channel_handle, Channel::MODE_SERVER, listener);
sammcbeeed3682016-11-08 23:24:3553#else
54 DCHECK(channel_handle.is_mojo_channel_handle());
55 return ChannelMojo::Create(
56 mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
Hajime Hoshife3ecdc2017-11-28 03:34:1357 Channel::MODE_SERVER, listener, ipc_task_runner,
58 base::ThreadTaskRunnerHandle::Get());
sammcbeeed3682016-11-08 23:24:3559#endif
[email protected]e482111a82014-05-30 03:58:5960}
61
Chris Watkins2d879af2017-11-30 02:11:5962Channel::~Channel() = default;
[email protected]e482111a82014-05-30 03:58:5963
rockot7c6bf952016-07-14 00:34:1164Channel::AssociatedInterfaceSupport* Channel::GetAssociatedInterfaceSupport() {
65 return nullptr;
66}
67
rockot10188752016-09-08 18:24:5668void Channel::Pause() { NOTREACHED(); }
rockot401fb2c2016-09-06 18:35:5769
70void Channel::Unpause(bool flush) { NOTREACHED(); }
71
72void Channel::Flush() { NOTREACHED(); }
73
erikchen90971902016-04-25 23:45:3174void Channel::WillConnect() {
75 did_start_connect_ = true;
76}
77
[email protected]e482111a82014-05-30 03:58:5978} // namespace IPC