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 "base/macros.h" |
| 13 #include "net/base/net_export.h" |
| 14 #include "net/socket/stream_socket.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 class SocketLibevent; |
| 19 struct SockaddrStorage; |
| 20 |
| 21 // A client socket that uses unix domain socket as the transport layer. |
| 22 class NET_EXPORT UnixDomainClientSocket : public StreamSocket { |
| 23 public: |
| 24 // Builds a client socket with socket_path. The caller should call Connect() |
| 25 // to connect to a server socket. |
| 26 UnixDomainClientSocket(const std::string& socket_path, |
| 27 bool use_abstract_namespace); |
| 28 // Builds a client socket with socket libevent which is already connected. |
| 29 // UnixDomainServerSocket uses this after it accepts a connection. |
| 30 explicit UnixDomainClientSocket(scoped_ptr<SocketLibevent> socket); |
| 31 |
| 32 virtual ~UnixDomainClientSocket(); |
| 33 |
| 34 // Fills |address| with |socket_path| and its length. For Android or Linux |
| 35 // platform, it supports abstract namespace. |
| 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 |