OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/ipc_channel_nacl.h" | 5 #include "ipc/ipc_channel_nacl.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name | 137 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name |
138 << "\" in " << modestr << " mode"; | 138 << "\" in " << modestr << " mode"; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 ChannelNacl::~ChannelNacl() { | 142 ChannelNacl::~ChannelNacl() { |
143 CleanUp(); | 143 CleanUp(); |
144 Close(); | 144 Close(); |
145 } | 145 } |
146 | 146 |
147 base::ProcessId ChannelNacl::GetPeerPID() const { | |
148 // This shouldn't actually get used in the untrusted side of the proxy, and we | |
149 // don't have the real pid anyway. | |
150 return -1; | |
151 } | |
152 | |
153 bool ChannelNacl::Connect() { | 147 bool ChannelNacl::Connect() { |
154 WillConnect(); | 148 WillConnect(); |
155 | 149 |
156 if (pipe_ == -1) { | 150 if (pipe_ == -1) { |
157 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; | 151 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; |
158 return false; | 152 return false; |
159 } | 153 } |
160 | 154 |
161 // Note that Connect is called on the "Channel" thread (i.e., the same thread | 155 // Note that Connect is called on the "Channel" thread (i.e., the same thread |
162 // where Channel::Send will be called, and the same thread that should receive | 156 // where Channel::Send will be called, and the same thread that should receive |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 302 } |
309 | 303 |
310 // Message sent OK! | 304 // Message sent OK! |
311 DVLOG(2) << "sent message @" << msg.get() << " with type " << msg->type() | 305 DVLOG(2) << "sent message @" << msg.get() << " with type " << msg->type() |
312 << " on fd " << pipe_; | 306 << " on fd " << pipe_; |
313 } | 307 } |
314 return true; | 308 return true; |
315 } | 309 } |
316 | 310 |
317 void ChannelNacl::CallOnChannelConnected() { | 311 void ChannelNacl::CallOnChannelConnected() { |
318 listener()->OnChannelConnected(GetPeerPID()); | 312 listener()->OnChannelConnected(-1); |
319 } | 313 } |
320 | 314 |
321 ChannelNacl::ReadState ChannelNacl::ReadData( | 315 ChannelNacl::ReadState ChannelNacl::ReadData( |
322 char* buffer, | 316 char* buffer, |
323 int buffer_len, | 317 int buffer_len, |
324 int* bytes_read) { | 318 int* bytes_read) { |
325 *bytes_read = 0; | 319 *bytes_read = 0; |
326 if (pipe_ == -1) | 320 if (pipe_ == -1) |
327 return READ_FAILED; | 321 return READ_FAILED; |
328 if (read_queue_.empty()) | 322 if (read_queue_.empty()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // When the input data buffer is empty, the fds should be too. | 365 // When the input data buffer is empty, the fds should be too. |
372 return input_fds_.empty(); | 366 return input_fds_.empty(); |
373 } | 367 } |
374 | 368 |
375 void ChannelNacl::HandleInternalMessage(const Message& msg) { | 369 void ChannelNacl::HandleInternalMessage(const Message& msg) { |
376 // The trusted side IPC::Channel should handle the "hello" handshake; we | 370 // The trusted side IPC::Channel should handle the "hello" handshake; we |
377 // should not receive the "Hello" message. | 371 // should not receive the "Hello" message. |
378 NOTREACHED(); | 372 NOTREACHED(); |
379 } | 373 } |
380 | 374 |
381 base::ProcessId ChannelNacl::GetSenderPID() { | |
382 // The untrusted side of the IPC::Channel should never have to worry about | |
383 // sender's process id. | |
384 return base::kNullProcessId; | |
385 } | |
386 | |
387 // Channel's methods | 375 // Channel's methods |
388 | 376 |
389 // static | 377 // static |
390 std::unique_ptr<Channel> Channel::Create( | 378 std::unique_ptr<Channel> Channel::Create( |
391 const IPC::ChannelHandle& channel_handle, | 379 const IPC::ChannelHandle& channel_handle, |
392 Mode mode, | 380 Mode mode, |
393 Listener* listener) { | 381 Listener* listener) { |
394 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); | 382 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); |
395 } | 383 } |
396 | 384 |
397 } // namespace IPC | 385 } // namespace IPC |
OLD | NEW |