Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: net/socket/unix_domain_socket_posix.cc

Issue 20142003: Remove ref-counting from StreamListenSocket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/unix_domain_socket_posix.h ('k') | net/socket/unix_domain_socket_posix_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/unix_domain_socket_posix.cc
diff --git a/net/socket/unix_domain_socket_posix.cc b/net/socket/unix_domain_socket_posix.cc
index 9166024b2d8fe380e15a03570fff941e14c18710..2b781d58b354e6871245f2e5d63f5e977a907be0 100644
--- a/net/socket/unix_domain_socket_posix.cc
+++ b/net/socket/unix_domain_socket_posix.cc
@@ -54,7 +54,7 @@ UnixDomainSocket::AuthCallback UnixDomainSocket::NoAuthentication() {
}
// static
-UnixDomainSocket* UnixDomainSocket::CreateAndListenInternal(
+scoped_ptr<UnixDomainSocket> UnixDomainSocket::CreateAndListenInternal(
const std::string& path,
const std::string& fallback_path,
StreamListenSocket::Delegate* del,
@@ -64,14 +64,15 @@ UnixDomainSocket* UnixDomainSocket::CreateAndListenInternal(
if (s == kInvalidSocket && !fallback_path.empty())
s = CreateAndBind(fallback_path, use_abstract_namespace);
if (s == kInvalidSocket)
- return NULL;
- UnixDomainSocket* sock = new UnixDomainSocket(s, del, auth_callback);
+ return scoped_ptr<UnixDomainSocket>();
+ scoped_ptr<UnixDomainSocket> sock(
+ new UnixDomainSocket(s, del, auth_callback));
sock->Listen();
- return sock;
+ return sock.Pass();
}
// static
-scoped_refptr<UnixDomainSocket> UnixDomainSocket::CreateAndListen(
+scoped_ptr<UnixDomainSocket> UnixDomainSocket::CreateAndListen(
const std::string& path,
StreamListenSocket::Delegate* del,
const AuthCallback& auth_callback) {
@@ -80,14 +81,14 @@ scoped_refptr<UnixDomainSocket> UnixDomainSocket::CreateAndListen(
#if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED)
// static
-scoped_refptr<UnixDomainSocket>
+scoped_ptr<UnixDomainSocket>
UnixDomainSocket::CreateAndListenWithAbstractNamespace(
const std::string& path,
const std::string& fallback_path,
StreamListenSocket::Delegate* del,
const AuthCallback& auth_callback) {
- return make_scoped_refptr(
- CreateAndListenInternal(path, fallback_path, del, auth_callback, true));
+ return
+ CreateAndListenInternal(path, fallback_path, del, auth_callback, true);
}
#endif
@@ -148,11 +149,11 @@ void UnixDomainSocket::Accept() {
LOG(ERROR) << "close() error";
return;
}
- scoped_refptr<UnixDomainSocket> sock(
+ scoped_ptr<UnixDomainSocket> sock(
new UnixDomainSocket(conn, socket_delegate_, auth_callback_));
// It's up to the delegate to AddRef if it wants to keep it around.
sock->WatchSocket(WAITING_READ);
- socket_delegate_->DidAccept(this, sock.get());
+ socket_delegate_->DidAccept(this, sock.PassAs<StreamListenSocket>());
}
UnixDomainSocketFactory::UnixDomainSocketFactory(
@@ -163,10 +164,10 @@ UnixDomainSocketFactory::UnixDomainSocketFactory(
UnixDomainSocketFactory::~UnixDomainSocketFactory() {}
-scoped_refptr<StreamListenSocket> UnixDomainSocketFactory::CreateAndListen(
+scoped_ptr<StreamListenSocket> UnixDomainSocketFactory::CreateAndListen(
StreamListenSocket::Delegate* delegate) const {
return UnixDomainSocket::CreateAndListen(
- path_, delegate, auth_callback_);
+ path_, delegate, auth_callback_).PassAs<StreamListenSocket>();
}
#if defined(SOCKET_ABSTRACT_NAMESPACE_SUPPORTED)
@@ -182,11 +183,12 @@ UnixDomainSocketWithAbstractNamespaceFactory(
UnixDomainSocketWithAbstractNamespaceFactory::
~UnixDomainSocketWithAbstractNamespaceFactory() {}
-scoped_refptr<StreamListenSocket>
+scoped_ptr<StreamListenSocket>
UnixDomainSocketWithAbstractNamespaceFactory::CreateAndListen(
StreamListenSocket::Delegate* delegate) const {
return UnixDomainSocket::CreateAndListenWithAbstractNamespace(
- path_, fallback_path_, delegate, auth_callback_);
+ path_, fallback_path_, delegate, auth_callback_)
+ .PassAs<StreamListenSocket>();
}
#endif
« no previous file with comments | « net/socket/unix_domain_socket_posix.h ('k') | net/socket/unix_domain_socket_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698