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 MOJO_SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ | 5 #ifndef SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ |
6 #define MOJO_SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ | 6 #define SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 #include "mojo/shell/domain_socket/socket_descriptor.h" | 11 #include "shell/domain_socket/socket_descriptor.h" |
12 #include "mojo/shell/domain_socket/unix_domain_server_socket_posix.h" | 12 #include "shell/domain_socket/unix_domain_server_socket_posix.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace shell { | 15 namespace shell { |
16 | 16 |
17 // Asynchronously listens for incoming connections on a unix domain | 17 // Asynchronously listens for incoming connections on a unix domain |
18 // socket at the provided path. Expects the parent directory in the | 18 // socket at the provided path. Expects the parent directory in the |
19 // path to exist. Must be run on an IO thread. | 19 // path to exist. Must be run on an IO thread. |
20 class IncomingConnectionListenerPosix { | 20 class IncomingConnectionListenerPosix { |
21 public: | 21 public: |
22 class Delegate { | 22 class Delegate { |
23 public: | 23 public: |
24 virtual ~Delegate() {} // Abstract base class, so this is safe. | 24 virtual ~Delegate() {} // Abstract base class, so this is safe. |
25 | 25 |
26 // Called when listening has started. rv is from | 26 // Called when listening has started. rv is from |
27 // mojo/shell/domain_socket/net_error_list.h | 27 // shell/domain_socket/net_error_list.h |
28 virtual void OnListening(int rv) = 0; | 28 virtual void OnListening(int rv) = 0; |
29 | 29 |
30 // Called every time an incoming connection is accepted. The delegate | 30 // Called every time an incoming connection is accepted. The delegate |
31 // takes ownership of incoming. | 31 // takes ownership of incoming. |
32 virtual void OnConnection(SocketDescriptor incoming) = 0; | 32 virtual void OnConnection(SocketDescriptor incoming) = 0; |
33 }; | 33 }; |
34 | 34 |
35 IncomingConnectionListenerPosix(const base::FilePath& socket_path, | 35 IncomingConnectionListenerPosix(const base::FilePath& socket_path, |
36 Delegate* delegate); | 36 Delegate* delegate); |
37 virtual ~IncomingConnectionListenerPosix(); | 37 virtual ~IncomingConnectionListenerPosix(); |
(...skipping 25 matching lines...) Expand all Loading... |
63 base::ThreadChecker listen_thread_checker_; | 63 base::ThreadChecker listen_thread_checker_; |
64 | 64 |
65 SocketDescriptor incoming_socket_; | 65 SocketDescriptor incoming_socket_; |
66 | 66 |
67 base::WeakPtrFactory<IncomingConnectionListenerPosix> weak_ptr_factory_; | 67 base::WeakPtrFactory<IncomingConnectionListenerPosix> weak_ptr_factory_; |
68 }; | 68 }; |
69 | 69 |
70 } // namespace shell | 70 } // namespace shell |
71 } // namespace mojo | 71 } // namespace mojo |
72 | 72 |
73 #endif // MOJO_SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ | 73 #endif // SHELL_INCOMING_CONNECTION_LISTENER_POSIX_H_ |
OLD | NEW |