summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorxunjieli <xunjieli@chromium.org>2015-04-02 22:07:27 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-03 05:08:03 +0000
commitc497950841e9c370eec411d7f920f374c7f299a8 (patch)
treecd9502761bf4119742e47d24798d81ceb596fd7d /net/socket
parentc11e7bb244652731cc67c023bd2cf39e52df3544 (diff)
downloadchromium_src-c497950841e9c370eec411d7f920f374c7f299a8.zip
chromium_src-c497950841e9c370eec411d7f920f374c7f299a8.tar.gz
chromium_src-c497950841e9c370eec411d7f920f374c7f299a8.tar.bz2
Make UnixDomainListenSocket's CreateAnd* methods private
This CL makes UnixDomainListenSocket's CreateAnd* methods private, so there won't be any new consumers of UnixDomainListenSocket. This is a part of the effort to remove UnixDomainListenSocket entirely. BUG=472766 Review URL: https://codereview.chromium.org/1058993002 Cr-Commit-Position: refs/heads/master@{#323600}
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/unix_domain_listen_socket_posix.cc36
-rw-r--r--net/socket/unix_domain_listen_socket_posix.h88
-rw-r--r--net/socket/unix_domain_listen_socket_posix_unittest.cc30
3 files changed, 46 insertions, 108 deletions
diff --git a/net/socket/unix_domain_listen_socket_posix.cc b/net/socket/unix_domain_listen_socket_posix.cc
index 3e46439..333ef0b 100644
--- a/net/socket/unix_domain_listen_socket_posix.cc
+++ b/net/socket/unix_domain_listen_socket_posix.cc
@@ -127,41 +127,5 @@ void UnixDomainListenSocket::Accept() {
socket_delegate_->DidAccept(this, sock.Pass());
}
-UnixDomainListenSocketFactory::UnixDomainListenSocketFactory(
- const std::string& path,
- const UnixDomainListenSocket::AuthCallback& auth_callback)
- : path_(path),
- auth_callback_(auth_callback) {}
-
-UnixDomainListenSocketFactory::~UnixDomainListenSocketFactory() {}
-
-scoped_ptr<StreamListenSocket> UnixDomainListenSocketFactory::CreateAndListen(
- StreamListenSocket::Delegate* delegate) const {
- return UnixDomainListenSocket::CreateAndListen(
- path_, delegate, auth_callback_).Pass();
-}
-
-#if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED)
-
-UnixDomainListenSocketWithAbstractNamespaceFactory::
-UnixDomainListenSocketWithAbstractNamespaceFactory(
- const std::string& path,
- const std::string& fallback_path,
- const UnixDomainListenSocket::AuthCallback& auth_callback)
- : UnixDomainListenSocketFactory(path, auth_callback),
- fallback_path_(fallback_path) {}
-
-UnixDomainListenSocketWithAbstractNamespaceFactory::
-~UnixDomainListenSocketWithAbstractNamespaceFactory() {}
-
-scoped_ptr<StreamListenSocket>
-UnixDomainListenSocketWithAbstractNamespaceFactory::CreateAndListen(
- StreamListenSocket::Delegate* delegate) const {
- return UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
- path_, fallback_path_, delegate, auth_callback_);
-}
-
-#endif
-
} // namespace deprecated
} // namespace net
diff --git a/net/socket/unix_domain_listen_socket_posix.h b/net/socket/unix_domain_listen_socket_posix.h
index 82ec342..da578ce 100644
--- a/net/socket/unix_domain_listen_socket_posix.h
+++ b/net/socket/unix_domain_listen_socket_posix.h
@@ -22,36 +22,27 @@
#define SOCKET_ABSTRACT_NAMESPACE_SUPPORTED
#endif
+namespace remoting {
+class GnubbyAuthHandlerPosix;
+}
+
namespace net {
namespace deprecated {
// Unix Domain Socket Implementation. Supports abstract namespaces on Linux.
+// This class is deprecated and will be removed once crbug.com/472766 is fixed.
+// There should not be any new consumer of this class.
class NET_EXPORT UnixDomainListenSocket : public StreamListenSocket {
public:
typedef UnixDomainServerSocket::AuthCallback AuthCallback;
~UnixDomainListenSocket() override;
- // Note that the returned UnixDomainListenSocket instance does not take
- // ownership of |del|.
- static scoped_ptr<UnixDomainListenSocket> CreateAndListen(
- const std::string& path,
- StreamListenSocket::Delegate* del,
- const AuthCallback& auth_callback);
-
-#if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED)
- // Same as above except that the created socket uses the abstract namespace
- // which is a Linux-only feature. If |fallback_path| is not empty,
- // make the second attempt with the provided fallback name.
- static scoped_ptr<UnixDomainListenSocket>
- CreateAndListenWithAbstractNamespace(
- const std::string& path,
- const std::string& fallback_path,
- StreamListenSocket::Delegate* del,
- const AuthCallback& auth_callback);
-#endif
-
private:
+ // Note that friend classes are temporary until crbug.com/472766 is fixed.
+ friend class UnixDomainListenSocketTestHelper;
+ friend class remoting::GnubbyAuthHandlerPosix;
+
UnixDomainListenSocket(SocketDescriptor s,
StreamListenSocket::Delegate* del,
const AuthCallback& auth_callback);
@@ -66,55 +57,28 @@ class NET_EXPORT UnixDomainListenSocket : public StreamListenSocket {
// StreamListenSocket:
void Accept() override;
- AuthCallback auth_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(UnixDomainListenSocket);
-};
-
-// Factory that can be used to instantiate UnixDomainListenSocket.
-class NET_EXPORT UnixDomainListenSocketFactory
- : public StreamListenSocketFactory {
- public:
- // Note that this class does not take ownership of the provided delegate.
- UnixDomainListenSocketFactory(
+ // Note that the returned UnixDomainListenSocket instance does not take
+ // ownership of |del|.
+ static scoped_ptr<UnixDomainListenSocket> CreateAndListen(
const std::string& path,
- const UnixDomainListenSocket::AuthCallback& auth_callback);
- ~UnixDomainListenSocketFactory() override;
-
- // StreamListenSocketFactory:
- scoped_ptr<StreamListenSocket> CreateAndListen(
- StreamListenSocket::Delegate* delegate) const override;
-
- protected:
- const std::string path_;
- const UnixDomainListenSocket::AuthCallback auth_callback_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(UnixDomainListenSocketFactory);
-};
+ StreamListenSocket::Delegate* del,
+ const AuthCallback& auth_callback);
#if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED)
-// Use this factory to instantiate UnixDomainListenSocket using the abstract
-// namespace feature (only supported on Linux).
-class NET_EXPORT UnixDomainListenSocketWithAbstractNamespaceFactory
- : public UnixDomainListenSocketFactory {
- public:
- UnixDomainListenSocketWithAbstractNamespaceFactory(
- const std::string& path,
- const std::string& fallback_path,
- const UnixDomainListenSocket::AuthCallback& auth_callback);
- ~UnixDomainListenSocketWithAbstractNamespaceFactory() override;
-
- // UnixDomainListenSocketFactory:
- scoped_ptr<StreamListenSocket> CreateAndListen(
- StreamListenSocket::Delegate* delegate) const override;
+ // Same as above except that the created socket uses the abstract namespace
+ // which is a Linux-only feature. If |fallback_path| is not empty,
+ // make the second attempt with the provided fallback name.
+ static scoped_ptr<UnixDomainListenSocket>
+ CreateAndListenWithAbstractNamespace(const std::string& path,
+ const std::string& fallback_path,
+ StreamListenSocket::Delegate* del,
+ const AuthCallback& auth_callback);
+#endif
- private:
- std::string fallback_path_;
+ AuthCallback auth_callback_;
- DISALLOW_COPY_AND_ASSIGN(UnixDomainListenSocketWithAbstractNamespaceFactory);
+ DISALLOW_COPY_AND_ASSIGN(UnixDomainListenSocket);
};
-#endif
} // namespace deprecated
} // namespace net
diff --git a/net/socket/unix_domain_listen_socket_posix_unittest.cc b/net/socket/unix_domain_listen_socket_posix_unittest.cc
index aaf3623..1513ca9 100644
--- a/net/socket/unix_domain_listen_socket_posix_unittest.cc
+++ b/net/socket/unix_domain_listen_socket_posix_unittest.cc
@@ -142,6 +142,8 @@ bool UserCanConnectCallback(
return allow_user;
}
+} // namespace
+
class UnixDomainListenSocketTestHelper : public testing::Test {
public:
void CreateAndListen() {
@@ -150,6 +152,15 @@ class UnixDomainListenSocketTestHelper : public testing::Test {
socket_delegate_->OnListenCompleted();
}
+ scoped_ptr<UnixDomainListenSocket> CreateAndListenWithAbstractNamespace(
+ const std::string& path,
+ const std::string& fallback_path,
+ StreamListenSocket::Delegate* del,
+ const UnixDomainListenSocket::AuthCallback& auth_callback) {
+ return UnixDomainListenSocket::CreateAndListenInternal(
+ path, fallback_path, del, auth_callback, true);
+ }
+
protected:
UnixDomainListenSocketTestHelper(const string& path_str, bool allow_user)
: allow_user_(allow_user) {
@@ -222,6 +233,8 @@ class UnixDomainListenSocketTestHelper : public testing::Test {
scoped_ptr<UnixDomainListenSocket> socket_;
};
+namespace {
+
class UnixDomainListenSocketTest : public UnixDomainListenSocketTestHelper {
protected:
UnixDomainListenSocketTest()
@@ -260,28 +273,25 @@ TEST_F(UnixDomainListenSocketTestWithInvalidPath,
// file.
TEST_F(UnixDomainListenSocketTestWithInvalidPath,
CreateAndListenWithAbstractNamespace) {
- socket_ = UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
+ socket_ = CreateAndListenWithAbstractNamespace(
file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
EXPECT_FALSE(socket_.get() == NULL);
}
TEST_F(UnixDomainListenSocketTest, TestFallbackName) {
scoped_ptr<UnixDomainListenSocket> existing_socket =
- UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
+ CreateAndListenWithAbstractNamespace(
file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
EXPECT_FALSE(existing_socket.get() == NULL);
// First, try to bind socket with the same name with no fallback name.
- socket_ =
- UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
- file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
+ socket_ = CreateAndListenWithAbstractNamespace(
+ file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
EXPECT_TRUE(socket_.get() == NULL);
// Now with a fallback name.
const char kFallbackSocketName[] = "socket_for_testing_2";
- socket_ = UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
- file_path_.value(),
- GetTempSocketPath(kFallbackSocketName).value(),
- socket_delegate_.get(),
- MakeAuthCallback());
+ socket_ = CreateAndListenWithAbstractNamespace(
+ file_path_.value(), GetTempSocketPath(kFallbackSocketName).value(),
+ socket_delegate_.get(), MakeAuthCallback());
EXPECT_FALSE(socket_.get() == NULL);
}
#endif