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
3 // found in the LICENSE file.
5 #include "ppapi/proxy/proxy_channel.h"
7 #include "ipc/ipc_platform_file.h"
8 #include "ipc/ipc_test_sink.h"
13 ProxyChannel::ProxyChannel()
18 ProxyChannel::~ProxyChannel() {
19 DVLOG(1) << "ProxyChannel::~ProxyChannel()";
22 bool ProxyChannel::InitWithChannel(Delegate
* delegate
,
23 const IPC::ChannelHandle
& channel_handle
,
26 IPC::Channel::Mode mode
= is_client
? IPC::Channel::MODE_CLIENT
27 : IPC::Channel::MODE_SERVER
;
28 channel_
.reset(new IPC::SyncChannel(channel_handle
, mode
, this,
29 delegate
->GetIPCMessageLoop(), true,
30 delegate
->GetShutdownEvent()));
34 void ProxyChannel::InitWithTestSink(IPC::TestSink
* test_sink
) {
36 test_sink_
= test_sink
;
39 void ProxyChannel::OnChannelError() {
43 #if defined(OS_POSIX) && !defined(OS_NACL)
44 int ProxyChannel::TakeRendererFD() {
46 return channel()->TakeClientFileDescriptor();
50 IPC::PlatformFileForTransit
ProxyChannel::ShareHandleWithRemote(
51 base::PlatformFile handle
,
52 bool should_close_source
) {
53 return delegate_
->ShareHandleWithRemote(handle
, *channel_
,
57 bool ProxyChannel::Send(IPC::Message
* msg
) {
59 return test_sink_
->Send(msg
);
61 return channel_
->Send(msg
);
63 // Remote side crashed, drop this message.