OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SOCKET_POSIX_H_ | 5 #ifndef NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ |
6 #define NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ | 6 #define NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Note that the returned UnixDomainSocket instance does not take ownership of | 39 // Note that the returned UnixDomainSocket instance does not take ownership of |
40 // |del|. | 40 // |del|. |
41 static scoped_refptr<UnixDomainSocket> CreateAndListen( | 41 static scoped_refptr<UnixDomainSocket> CreateAndListen( |
42 const std::string& path, | 42 const std::string& path, |
43 StreamListenSocket::Delegate* del, | 43 StreamListenSocket::Delegate* del, |
44 const AuthCallback& auth_callback); | 44 const AuthCallback& auth_callback); |
45 | 45 |
46 #if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED) | 46 #if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED) |
47 // Same as above except that the created socket uses the abstract namespace | 47 // Same as above except that the created socket uses the abstract namespace |
48 // which is a Linux-only feature. | 48 // which is a Linux-only feature. If |fallback_path| is not empty, |
| 49 // make the second attempt with the provided fallback name. |
49 static scoped_refptr<UnixDomainSocket> CreateAndListenWithAbstractNamespace( | 50 static scoped_refptr<UnixDomainSocket> CreateAndListenWithAbstractNamespace( |
50 const std::string& path, | 51 const std::string& path, |
| 52 const std::string& fallback_path, |
51 StreamListenSocket::Delegate* del, | 53 StreamListenSocket::Delegate* del, |
52 const AuthCallback& auth_callback); | 54 const AuthCallback& auth_callback); |
53 #endif | 55 #endif |
54 | 56 |
55 private: | 57 private: |
56 UnixDomainSocket(SocketDescriptor s, | 58 UnixDomainSocket(SocketDescriptor s, |
57 StreamListenSocket::Delegate* del, | 59 StreamListenSocket::Delegate* del, |
58 const AuthCallback& auth_callback); | 60 const AuthCallback& auth_callback); |
59 virtual ~UnixDomainSocket(); | 61 virtual ~UnixDomainSocket(); |
60 | 62 |
61 static UnixDomainSocket* CreateAndListenInternal( | 63 static UnixDomainSocket* CreateAndListenInternal( |
62 const std::string& path, | 64 const std::string& path, |
| 65 const std::string& fallback_path, |
63 StreamListenSocket::Delegate* del, | 66 StreamListenSocket::Delegate* del, |
64 const AuthCallback& auth_callback, | 67 const AuthCallback& auth_callback, |
65 bool use_abstract_namespace); | 68 bool use_abstract_namespace); |
66 | 69 |
67 static SocketDescriptor CreateAndBind(const std::string& path, | 70 static SocketDescriptor CreateAndBind(const std::string& path, |
68 bool use_abstract_namespace); | 71 bool use_abstract_namespace); |
69 | 72 |
70 // StreamListenSocket: | 73 // StreamListenSocket: |
71 virtual void Accept() OVERRIDE; | 74 virtual void Accept() OVERRIDE; |
72 | 75 |
(...skipping 23 matching lines...) Expand all Loading... |
96 }; | 99 }; |
97 | 100 |
98 #if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED) | 101 #if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED) |
99 // Use this factory to instantiate UnixDomainSocket using the abstract | 102 // Use this factory to instantiate UnixDomainSocket using the abstract |
100 // namespace feature (only supported on Linux). | 103 // namespace feature (only supported on Linux). |
101 class NET_EXPORT UnixDomainSocketWithAbstractNamespaceFactory | 104 class NET_EXPORT UnixDomainSocketWithAbstractNamespaceFactory |
102 : public UnixDomainSocketFactory { | 105 : public UnixDomainSocketFactory { |
103 public: | 106 public: |
104 UnixDomainSocketWithAbstractNamespaceFactory( | 107 UnixDomainSocketWithAbstractNamespaceFactory( |
105 const std::string& path, | 108 const std::string& path, |
| 109 const std::string& fallback_path, |
106 const UnixDomainSocket::AuthCallback& auth_callback); | 110 const UnixDomainSocket::AuthCallback& auth_callback); |
107 virtual ~UnixDomainSocketWithAbstractNamespaceFactory(); | 111 virtual ~UnixDomainSocketWithAbstractNamespaceFactory(); |
108 | 112 |
109 // UnixDomainSocketFactory: | 113 // UnixDomainSocketFactory: |
110 virtual scoped_refptr<StreamListenSocket> CreateAndListen( | 114 virtual scoped_refptr<StreamListenSocket> CreateAndListen( |
111 StreamListenSocket::Delegate* delegate) const OVERRIDE; | 115 StreamListenSocket::Delegate* delegate) const OVERRIDE; |
112 | 116 |
113 private: | 117 private: |
| 118 std::string fallback_path_; |
| 119 |
114 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketWithAbstractNamespaceFactory); | 120 DISALLOW_COPY_AND_ASSIGN(UnixDomainSocketWithAbstractNamespaceFactory); |
115 }; | 121 }; |
116 #endif | 122 #endif |
117 | 123 |
118 } // namespace net | 124 } // namespace net |
119 | 125 |
120 #endif // NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ | 126 #endif // NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_ |
OLD | NEW |