Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / nacl / loader / nacl_trusted_listener.cc
1 // 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
5 #include "components/nacl/loader/nacl_trusted_listener.h"
6
7 #include "base/single_thread_task_runner.h"
8
9 NaClTrustedListener::NaClTrustedListener(
10     const IPC::ChannelHandle& handle,
11     base::SingleThreadTaskRunner* ipc_task_runner)
12     : channel_handle_(handle),
13       channel_proxy_(IPC::ChannelProxy::Create(
14           handle, IPC::Channel::MODE_SERVER, this, ipc_task_runner)) {
15 }
16
17 NaClTrustedListener::~NaClTrustedListener() {
18 }
19
20 IPC::ChannelHandle NaClTrustedListener::TakeClientChannelHandle() {
21   IPC::ChannelHandle handle = channel_handle_;
22 #if defined(OS_POSIX)
23   handle.socket =
24       base::FileDescriptor(channel_proxy_->TakeClientFileDescriptor(), true);
25 #endif
26   return handle;
27 }
28
29 bool NaClTrustedListener::OnMessageReceived(const IPC::Message& msg) {
30   return false;
31 }
32
33 void NaClTrustedListener::OnChannelError() {
34   channel_proxy_->Close();
35 }
36
37 bool NaClTrustedListener::Send(IPC::Message* msg) {
38   return channel_proxy_->Send(msg);
39 }