summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_nacl.cc
blob: 683353edcde2b05b569ea54523fbc5a4ead4b082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ipc/ipc_channel_nacl.h"

#include "base/file_util.h"
#include "base/logging.h"

// This file is currently a stub to get us linking.
// TODO(brettw) implement this.

namespace IPC {

Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle,
                         Mode mode,
                         Listener* listener)
    : ChannelReader(listener) {
}

Channel::ChannelImpl::~ChannelImpl() {
  Close();
}

bool Channel::ChannelImpl::Connect() {
  NOTIMPLEMENTED();
  return false;
}

void Channel::ChannelImpl::Close() {
  NOTIMPLEMENTED();
}

bool Channel::ChannelImpl::Send(Message* message) {
  NOTIMPLEMENTED();
}

int Channel::ChannelImpl::GetClientFileDescriptor() const {
  NOTIMPLEMENTED();
  return -1;
}

int Channel::ChannelImpl::TakeClientFileDescriptor() {
  NOTIMPLEMENTED();
  return -1;
}

bool Channel::ChannelImpl::AcceptsConnections() const {
  NOTIMPLEMENTED();
  return false;
}

bool Channel::ChannelImpl::HasAcceptedConnection() const {
  NOTIMPLEMENTED();
  return false;
}

bool Channel::ChannelImpl::GetClientEuid(uid_t* client_euid) const {
  NOTIMPLEMENTED();
  return false;
}

void Channel::ChannelImpl::ResetToAcceptingConnectionState() {
  NOTIMPLEMENTED();
}

Channel::ChannelImpl::ReadState
    Channel::ChannelImpl::ReadData(char* buffer,
                                   int buffer_len,
                                   int* bytes_read) {
  return Channel::ChannelImpl::ReadState();
}

bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) {
  return false;
}

bool Channel::ChannelImpl::DidEmptyInputBuffers() {
  return false;
}

void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) {
}

// static
bool Channel::ChannelImpl::IsNamedServerInitialized(
    const std::string& channel_id) {
  return false;  //file_util::PathExists(FilePath(channel_id));
}

//------------------------------------------------------------------------------
// Channel's methods simply call through to ChannelImpl.

Channel::Channel(const IPC::ChannelHandle& channel_handle,
                 Mode mode,
                 Listener* listener)
    : channel_impl_(new ChannelImpl(channel_handle, mode, listener)) {
}

Channel::~Channel() {
  delete channel_impl_;
}

bool Channel::Connect() {
  return channel_impl_->Connect();
}

void Channel::Close() {
  channel_impl_->Close();
}

void Channel::set_listener(Listener* listener) {
  channel_impl_->set_listener(listener);
}

bool Channel::Send(Message* message) {
  return channel_impl_->Send(message);
}

int Channel::GetClientFileDescriptor() const {
  return channel_impl_->GetClientFileDescriptor();
}

int Channel::TakeClientFileDescriptor() {
  return channel_impl_->TakeClientFileDescriptor();
}

bool Channel::AcceptsConnections() const {
  return channel_impl_->AcceptsConnections();
}

bool Channel::HasAcceptedConnection() const {
  return channel_impl_->HasAcceptedConnection();
}

bool Channel::GetClientEuid(uid_t* client_euid) const {
  return channel_impl_->GetClientEuid(client_euid);
}

void Channel::ResetToAcceptingConnectionState() {
  channel_impl_->ResetToAcceptingConnectionState();
}

base::ProcessId Channel::peer_pid() const { return 0; }

// static
bool Channel::IsNamedServerInitialized(const std::string& channel_id) {
  return ChannelImpl::IsNamedServerInitialized(channel_id);
}

// static
std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) {
  // A random name is sufficient validation on posix systems, so we don't need
  // an additional shared secret.
  std::string id = prefix;
  if (!id.empty())
    id.append(".");

  return id.append(GenerateUniqueRandomChannelID());
}

}  // namespace IPC