Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / socket / unix_domain_client_socket_posix.h
blob81f2bdfbef5a88da3197e62f917756ea9a254037
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.
5 #ifndef NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_
6 #define NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_
8 #include <string>
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"
18 namespace net {
20 class SocketLibevent;
21 struct SockaddrStorage;
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()
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);
34 virtual ~UnixDomainClientSocket();
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);
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;
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;
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_;
74 DISALLOW_COPY_AND_ASSIGN(UnixDomainClientSocket);
77 } // namespace net
79 #endif // NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_