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/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "net/base/completion_callback.h" | |
| 14 #include "net/base/net_export.h" | |
| 15 #include "net/base/net_log.h" | |
| 16 #include "net/socket/stream_socket.h" | |
| 17 | |
| 18 namespace net { | |
| 19 | |
| 20 class SocketLibevent; | |
| 21 struct SockaddrStorage; | |
| 22 | |
| 23 // A client socket that uses unix domain socket as the transport layer. | |
| 24 class NET_EXPORT UnixDomainClientSocket : public StreamSocket { | |
| 25 public: | |
| 26 // Builds a client socket with socket_path. The caller should call Connect() | |
|
mmenke
2014/07/23 18:52:40
nit: |socket_path|
byungchul
2014/07/23 22:27:11
Done.
| |
| 27 // to connect to a server socket. | |
| 28 UnixDomainClientSocket(const std::string& socket_path, | |
| 29 bool use_abstract_namespace); | |
| 30 // Builds a client socket with socket libevent which is already connected. | |
| 31 // UnixDomainServerSocket uses this after it accepts a connection. | |
| 32 explicit UnixDomainClientSocket(scoped_ptr<SocketLibevent> socket); | |
| 33 | |
| 34 virtual ~UnixDomainClientSocket(); | |
| 35 | |
| 36 // Fills |address| with |socket_path| and its length. For Android or Linux | |
| 37 // platform, this supports abstract namespaces. | |
| 38 static bool FillAddress(const std::string& socket_path, | |
| 39 bool use_abstract_namespace, | |
| 40 SockaddrStorage* address); | |
| 41 | |
| 42 // StreamSocket implementation. | |
| 43 virtual int Connect(const CompletionCallback& callback) OVERRIDE; | |
| 44 virtual void Disconnect() OVERRIDE; | |
| 45 virtual bool IsConnected() const OVERRIDE; | |
| 46 virtual bool IsConnectedAndIdle() const OVERRIDE; | |
| 47 virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE; | |
| 48 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | |
| 49 virtual const BoundNetLog& NetLog() const OVERRIDE; | |
| 50 virtual void SetSubresourceSpeculation() OVERRIDE; | |
| 51 virtual void SetOmniboxSpeculation() OVERRIDE; | |
| 52 virtual bool WasEverUsed() const OVERRIDE; | |
| 53 virtual bool UsingTCPFastOpen() const OVERRIDE; | |
| 54 virtual bool WasNpnNegotiated() const OVERRIDE; | |
| 55 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; | |
| 56 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | |
| 57 | |
| 58 // Socket implementation. | |
| 59 virtual int Read(IOBuffer* buf, int buf_len, | |
| 60 const CompletionCallback& callback) OVERRIDE; | |
| 61 virtual int Write(IOBuffer* buf, int buf_len, | |
| 62 const CompletionCallback& callback) OVERRIDE; | |
| 63 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; | |
| 64 virtual int SetSendBufferSize(int32 size) OVERRIDE; | |
| 65 | |
| 66 private: | |
| 67 const std::string socket_path_; | |
| 68 const bool use_abstract_namespace_; | |
| 69 scoped_ptr<SocketLibevent> socket_; | |
| 70 // This net log is just to comply StreamSocket::NetLog(). It throws away | |
| 71 // everything. | |
| 72 BoundNetLog net_log_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(UnixDomainClientSocket); | |
| 75 }; | |
| 76 | |
| 77 } // namespace net | |
| 78 | |
| 79 #endif // NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_ | |
| OLD | NEW |