Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | |
| 6 #define NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 #include "net/socket/stream_socket.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 class SocketLibevent; | |
| 18 struct SockaddrStorage; | |
| 19 | |
| 20 // A client socket that uses unix domain socket as the transport layer. | |
| 21 class NET_EXPORT UnixDomainClientSocket : public StreamSocket { | |
| 22 public: | |
| 23 // Builds a client socket with socket_path. The caller should call Connect() | |
| 24 // to connect to server sockect. | |
|
mmenke
2014/06/26 15:36:11
nit: "to a server socket" (+to, -c)
byungchul
2014/06/26 18:09:24
Done.
| |
| 25 UnixDomainClientSocket(const std::string& socket_path, | |
| 26 bool use_abstract_namespace); | |
| 27 // Builds a client socket with socket libevent which is already connected. | |
| 28 // UnixDomainServerSocket uses this after it accepts a connection. | |
| 29 explicit UnixDomainClientSocket(scoped_ptr<SocketLibevent> socket); | |
| 30 | |
| 31 virtual ~UnixDomainClientSocket(); | |
| 32 | |
| 33 // Fills |sock_addr| with |socket_path|. For Android or Linux platform, it | |
| 34 // supports abstract namespace. |socket_addr_len| is in/out parameter as | |
| 35 // POSIX socket interfaces. | |
|
mmenke
2014/06/26 15:36:11
This comment is wrong.
byungchul
2014/06/26 18:09:24
Done.
| |
| 36 static bool FillAddress(const std::string& socket_path, | |
| 37 bool use_abstract_namespace, | |
| 38 SockaddrStorage* address); | |
| 39 | |
| 40 // StreamSocket implementation. | |
| 41 virtual int Connect(const CompletionCallback& callback) OVERRIDE; | |
| 42 virtual void Disconnect() OVERRIDE; | |
| 43 virtual bool IsConnected() const OVERRIDE; | |
| 44 virtual bool IsConnectedAndIdle() const OVERRIDE; | |
| 45 virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE; | |
| 46 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | |
| 47 virtual const BoundNetLog& NetLog() const OVERRIDE; | |
| 48 virtual void SetSubresourceSpeculation() OVERRIDE; | |
| 49 virtual void SetOmniboxSpeculation() OVERRIDE; | |
| 50 virtual bool WasEverUsed() const OVERRIDE; | |
| 51 virtual bool UsingTCPFastOpen() const OVERRIDE; | |
| 52 virtual bool WasNpnNegotiated() const OVERRIDE; | |
| 53 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; | |
| 54 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | |
| 55 | |
| 56 // Socket implementation. | |
| 57 virtual int Read(IOBuffer* buf, int buf_len, | |
| 58 const CompletionCallback& callback) OVERRIDE; | |
| 59 virtual int Write(IOBuffer* buf, int buf_len, | |
| 60 const CompletionCallback& callback) OVERRIDE; | |
| 61 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; | |
| 62 virtual int SetSendBufferSize(int32 size) OVERRIDE; | |
| 63 | |
| 64 private: | |
| 65 const std::string socket_path_; | |
| 66 const bool use_abstract_namespace_; | |
| 67 scoped_ptr<SocketLibevent> socket_; | |
| 68 BoundNetLog netlog_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(UnixDomainClientSocket); | |
| 71 }; | |
| 72 | |
| 73 } // namespace net | |
| 74 | |
| 75 #endif // NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | |
| OLD | NEW |