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 NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | 5 #ifndef NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ |
6 #define NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | 6 #define NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/log/net_log.h" | 15 #include "net/log/net_log.h" |
16 #include "net/socket/socket_descriptor.h" | 16 #include "net/socket/socket_descriptor.h" |
17 #include "net/socket/stream_socket.h" | 17 #include "net/socket/stream_socket.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class SocketLibevent; | 21 class SocketPosix; |
22 struct SockaddrStorage; | 22 struct SockaddrStorage; |
23 | 23 |
24 // A client socket that uses unix domain socket as the transport layer. | 24 // A client socket that uses unix domain socket as the transport layer. |
25 class NET_EXPORT UnixDomainClientSocket : public StreamSocket { | 25 class NET_EXPORT UnixDomainClientSocket : public StreamSocket { |
26 public: | 26 public: |
27 // Builds a client socket with |socket_path|. The caller should call Connect() | 27 // Builds a client socket with |socket_path|. The caller should call Connect() |
28 // to connect to a server socket. | 28 // to connect to a server socket. |
29 UnixDomainClientSocket(const std::string& socket_path, | 29 UnixDomainClientSocket(const std::string& socket_path, |
30 bool use_abstract_namespace); | 30 bool use_abstract_namespace); |
31 // Builds a client socket with socket libevent which is already connected. | 31 // Builds a client socket with SocketPosix which is already connected. |
32 // UnixDomainServerSocket uses this after it accepts a connection. | 32 // UnixDomainServerSocket uses this after it accepts a connection. |
33 explicit UnixDomainClientSocket(scoped_ptr<SocketLibevent> socket); | 33 explicit UnixDomainClientSocket(scoped_ptr<SocketPosix> socket); |
34 | 34 |
35 ~UnixDomainClientSocket() override; | 35 ~UnixDomainClientSocket() override; |
36 | 36 |
37 // Fills |address| with |socket_path| and its length. For Android or Linux | 37 // Fills |address| with |socket_path| and its length. For Android or Linux |
38 // platform, this supports abstract namespaces. | 38 // platform, this supports abstract namespaces. |
39 static bool FillAddress(const std::string& socket_path, | 39 static bool FillAddress(const std::string& socket_path, |
40 bool use_abstract_namespace, | 40 bool use_abstract_namespace, |
41 SockaddrStorage* address); | 41 SockaddrStorage* address); |
42 | 42 |
43 // StreamSocket implementation. | 43 // StreamSocket implementation. |
(...skipping 26 matching lines...) Expand all Loading... |
70 int SetSendBufferSize(int32 size) override; | 70 int SetSendBufferSize(int32 size) override; |
71 | 71 |
72 // Releases ownership of underlying SocketDescriptor to caller. | 72 // Releases ownership of underlying SocketDescriptor to caller. |
73 // Internal state is reset so that this object can be used again. | 73 // Internal state is reset so that this object can be used again. |
74 // Socket must be connected in order to release it. | 74 // Socket must be connected in order to release it. |
75 SocketDescriptor ReleaseConnectedSocket(); | 75 SocketDescriptor ReleaseConnectedSocket(); |
76 | 76 |
77 private: | 77 private: |
78 const std::string socket_path_; | 78 const std::string socket_path_; |
79 const bool use_abstract_namespace_; | 79 const bool use_abstract_namespace_; |
80 scoped_ptr<SocketLibevent> socket_; | 80 scoped_ptr<SocketPosix> socket_; |
81 // This net log is just to comply StreamSocket::NetLog(). It throws away | 81 // This net log is just to comply StreamSocket::NetLog(). It throws away |
82 // everything. | 82 // everything. |
83 BoundNetLog net_log_; | 83 BoundNetLog net_log_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(UnixDomainClientSocket); | 85 DISALLOW_COPY_AND_ASSIGN(UnixDomainClientSocket); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace net | 88 } // namespace net |
89 | 89 |
90 #endif // NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | 90 #endif // NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ |
OLD | NEW |