| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_factory.h" | 5 #include "ipc/ipc_channel_factory.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ipc/unix_domain_socket_util.h" | 9 #include "ipc/unix_domain_socket_util.h" |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // shut down. | 57 // shut down. |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 | 60 |
| 61 file_util::ScopedFD scoped_fd(&new_fd); | 61 file_util::ScopedFD scoped_fd(&new_fd); |
| 62 | 62 |
| 63 // Verify that the IPC channel peer is running as the same user. | 63 // Verify that the IPC channel peer is running as the same user. |
| 64 if (!IsPeerAuthorized(new_fd)) | 64 if (!IsPeerAuthorized(new_fd)) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 ChannelHandle handle("", base::FileDescriptor(*scoped_fd.release(), true)); | 67 ChannelHandle handle(std::string(), |
| 68 base::FileDescriptor(*scoped_fd.release(), true)); |
| 68 delegate_->OnClientConnected(handle); | 69 delegate_->OnClientConnected(handle); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void ChannelFactory::OnFileCanWriteWithoutBlocking(int fd) { | 72 void ChannelFactory::OnFileCanWriteWithoutBlocking(int fd) { |
| 72 NOTREACHED() << "Listen fd should never be writable."; | 73 NOTREACHED() << "Listen fd should never be writable."; |
| 73 } | 74 } |
| 74 | 75 |
| 75 void ChannelFactory::Close() { | 76 void ChannelFactory::Close() { |
| 76 if (listen_fd_ < 0) | 77 if (listen_fd_ < 0) |
| 77 return; | 78 return; |
| 78 if (HANDLE_EINTR(close(listen_fd_)) < 0) | 79 if (HANDLE_EINTR(close(listen_fd_)) < 0) |
| 79 PLOG(ERROR) << "close"; | 80 PLOG(ERROR) << "close"; |
| 80 listen_fd_ = -1; | 81 listen_fd_ = -1; |
| 81 if (unlink(path_.value().c_str()) < 0) | 82 if (unlink(path_.value().c_str()) < 0) |
| 82 PLOG(ERROR) << "unlink"; | 83 PLOG(ERROR) << "unlink"; |
| 83 | 84 |
| 84 // Unregister libevent for the listening socket and close it. | 85 // Unregister libevent for the listening socket and close it. |
| 85 server_listen_connection_watcher_.StopWatchingFileDescriptor(); | 86 server_listen_connection_watcher_.StopWatchingFileDescriptor(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace IPC | 89 } // namespace IPC |
| OLD | NEW |