| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h" | 5 #include "chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ipc/unix_domain_socket_util.h" | 10 #include "ipc/unix_domain_socket_util.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 base::MessageLoopForIO::WATCH_READ, | 41 base::MessageLoopForIO::WATCH_READ, |
| 42 &server_listen_connection_watcher_, | 42 &server_listen_connection_watcher_, |
| 43 this); | 43 this); |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Called by libevent when we can read from the fd without blocking. | 47 // Called by libevent when we can read from the fd without blocking. |
| 48 void UnixDomainSocketAcceptor::OnFileCanReadWithoutBlocking(int fd) { | 48 void UnixDomainSocketAcceptor::OnFileCanReadWithoutBlocking(int fd) { |
| 49 DCHECK(fd == listen_fd_); | 49 DCHECK(fd == listen_fd_); |
| 50 int new_fd = -1; | 50 int new_fd = -1; |
| 51 if (!IPC::ServerAcceptConnection(listen_fd_, &new_fd)) { | 51 if (!IPC::ServerOnConnect(listen_fd_, &new_fd)) { |
| 52 Close(); | 52 Close(); |
| 53 delegate_->OnListenError(); | 53 delegate_->OnListenError(); |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 base::ScopedFD scoped_fd(new_fd); | 56 base::ScopedFD scoped_fd(new_fd); |
| 57 | 57 |
| 58 if (!scoped_fd.is_valid()) { | 58 if (!scoped_fd.is_valid()) { |
| 59 // The accept() failed, but not in such a way that the factory needs to be | 59 // The accept() failed, but not in such a way that the factory needs to be |
| 60 // shut down. | 60 // shut down. |
| 61 return; | 61 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 81 PLOG(ERROR) << "close"; | 81 PLOG(ERROR) << "close"; |
| 82 listen_fd_ = -1; | 82 listen_fd_ = -1; |
| 83 if (unlink(path_.value().c_str()) < 0) | 83 if (unlink(path_.value().c_str()) < 0) |
| 84 PLOG(ERROR) << "unlink"; | 84 PLOG(ERROR) << "unlink"; |
| 85 | 85 |
| 86 // Unregister libevent for the listening socket and close it. | 86 // Unregister libevent for the listening socket and close it. |
| 87 server_listen_connection_watcher_.StopWatchingFileDescriptor(); | 87 server_listen_connection_watcher_.StopWatchingFileDescriptor(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace apps | 90 } // namespace apps |
| OLD | NEW |