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 #ifndef CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ | 5 #ifndef CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ |
6 #define CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ | 6 #define CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "ipc/ipc_channel_handle.h" | 10 #include "ipc/ipc_channel_handle.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // responsibility to create an IPC::Channel for the handle, or else close | 23 // responsibility to create an IPC::Channel for the handle, or else close |
24 // the file descriptor contained therein. | 24 // the file descriptor contained therein. |
25 virtual void OnClientConnected(const IPC::ChannelHandle& handle) = 0; | 25 virtual void OnClientConnected(const IPC::ChannelHandle& handle) = 0; |
26 | 26 |
27 // Called when an error occurs and the channel is closed. | 27 // Called when an error occurs and the channel is closed. |
28 virtual void OnListenError() = 0; | 28 virtual void OnListenError() = 0; |
29 }; | 29 }; |
30 | 30 |
31 UnixDomainSocketAcceptor(const base::FilePath& path, Delegate* delegate); | 31 UnixDomainSocketAcceptor(const base::FilePath& path, Delegate* delegate); |
32 | 32 |
33 virtual ~UnixDomainSocketAcceptor(); | 33 ~UnixDomainSocketAcceptor() override; |
34 | 34 |
35 // Call this to start listening on the socket. | 35 // Call this to start listening on the socket. |
36 bool Listen(); | 36 bool Listen(); |
37 | 37 |
38 // Close and unlink the socket, and stop accepting connections. | 38 // Close and unlink the socket, and stop accepting connections. |
39 void Close(); | 39 void Close(); |
40 | 40 |
41 private: | 41 private: |
42 bool CreateSocket(); | 42 bool CreateSocket(); |
43 virtual void OnFileCanReadWithoutBlocking(int fd) override; | 43 void OnFileCanReadWithoutBlocking(int fd) override; |
44 virtual void OnFileCanWriteWithoutBlocking(int fd) override; | 44 void OnFileCanWriteWithoutBlocking(int fd) override; |
45 | 45 |
46 base::MessageLoopForIO::FileDescriptorWatcher | 46 base::MessageLoopForIO::FileDescriptorWatcher |
47 server_listen_connection_watcher_; | 47 server_listen_connection_watcher_; |
48 base::FilePath path_; | 48 base::FilePath path_; |
49 Delegate* delegate_; | 49 Delegate* delegate_; |
50 int listen_fd_; | 50 int listen_fd_; |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketAcceptor); | 52 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketAcceptor); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace apps | 55 } // namespace apps |
56 | 56 |
57 #endif // CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ | 57 #endif // CHROME_BROWSER_APPS_APP_SHIM_UNIX_DOMAIN_SOCKET_ACCEPTOR_H_ |
OLD | NEW |