diff options
author | szym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 19:03:06 +0000 |
---|---|---|
committer | szym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 19:03:06 +0000 |
commit | 8b62f8e537893c76633cc94e2327c2c2bfc340ee (patch) | |
tree | 9f38f00402039886c0b306a193f87b6c9d127b3d /chrome_frame | |
parent | df248dc033de8f3b48f5d2c4dc49d739537c8ad4 (diff) | |
download | chromium_src-8b62f8e537893c76633cc94e2327c2c2bfc340ee.zip chromium_src-8b62f8e537893c76633cc94e2327c2c2bfc340ee.tar.gz chromium_src-8b62f8e537893c76633cc94e2327c2c2bfc340ee.tar.bz2 |
Remove ref-counting from StreamListenSocket
Changes APIs for StreamListenSocket, TCPListenSocket, UnixDomainSocket and derived test classes to use scoped_ptr instead of scoped_refptr.
BUG=263963
Review URL: https://chromiumcodereview.appspot.com/20142003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/test_server.cc | 16 | ||||
-rw-r--r-- | chrome_frame/test/test_server.h | 21 |
2 files changed, 19 insertions, 18 deletions
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc index 5162b40..3e91879 100644 --- a/chrome_frame/test/test_server.cc +++ b/chrome_frame/test/test_server.cc @@ -198,9 +198,10 @@ Connection* SimpleWebServer::FindConnection( return NULL; } -void SimpleWebServer::DidAccept(net::StreamListenSocket* server, - net::StreamListenSocket* connection) { - connections_.push_back(new Connection(connection)); +void SimpleWebServer::DidAccept( + net::StreamListenSocket* server, + scoped_ptr<net::StreamListenSocket> connection) { + connections_.push_back(new Connection(connection.Pass())); } void SimpleWebServer::DidRead(net::StreamListenSocket* connection, @@ -262,7 +263,6 @@ HTTPTestServer::HTTPTestServer(int port, const std::wstring& address, } HTTPTestServer::~HTTPTestServer() { - server_ = NULL; } std::list<scoped_refptr<ConfigurableConnection>>::iterator @@ -294,8 +294,8 @@ scoped_refptr<ConfigurableConnection> HTTPTestServer::ConnectionFromSocket( } void HTTPTestServer::DidAccept(net::StreamListenSocket* server, - net::StreamListenSocket* socket) { - connection_list_.push_back(new ConfigurableConnection(socket)); + scoped_ptr<net::StreamListenSocket> socket) { + connection_list_.push_back(new ConfigurableConnection(socket.Pass())); } void HTTPTestServer::DidRead(net::StreamListenSocket* socket, @@ -362,12 +362,12 @@ void ConfigurableConnection::SendChunk() { FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), base::TimeDelta::FromMilliseconds(options_.timeout_)); } else { - socket_ = 0; // close the connection. + Close(); } } void ConfigurableConnection::Close() { - socket_ = NULL; + socket_.reset(); } void ConfigurableConnection::Send(const std::string& headers, diff --git a/chrome_frame/test/test_server.h b/chrome_frame/test/test_server.h index ade2b18..80ffdd5 100644 --- a/chrome_frame/test/test_server.h +++ b/chrome_frame/test/test_server.h @@ -107,7 +107,8 @@ class Request { // shut down. class Connection { public: - explicit Connection(net::StreamListenSocket* sock) : socket_(sock) { + explicit Connection(scoped_ptr<net::StreamListenSocket> sock) + : socket_(sock.Pass()) { } ~Connection() { @@ -126,11 +127,11 @@ class Connection { } void OnSocketClosed() { - socket_ = NULL; + socket_.reset(); } protected: - scoped_refptr<net::StreamListenSocket> socket_; + scoped_ptr<net::StreamListenSocket> socket_; Request request_; private: @@ -303,7 +304,7 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate { // StreamListenSocket::Delegate overrides. virtual void DidAccept(net::StreamListenSocket* server, - net::StreamListenSocket* connection); + scoped_ptr<net::StreamListenSocket> connection); virtual void DidRead(net::StreamListenSocket* connection, const char* data, int len); @@ -336,7 +337,7 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate { Connection* FindConnection(const net::StreamListenSocket* socket) const; std::string host_; - scoped_refptr<net::StreamListenSocket> server_; + scoped_ptr<net::StreamListenSocket> server_; ConnectionList connections_; std::list<Response*> responses_; QuitResponse quit_; @@ -362,8 +363,8 @@ class ConfigurableConnection : public base::RefCounted<ConfigurableConnection> { int64 timeout_; }; - explicit ConfigurableConnection(net::StreamListenSocket* sock) - : socket_(sock), + explicit ConfigurableConnection(scoped_ptr<net::StreamListenSocket> sock) + : socket_(sock.Pass()), cur_pos_(0) {} // Send HTTP response with provided |headers| and |content|. Appends @@ -385,7 +386,7 @@ class ConfigurableConnection : public base::RefCounted<ConfigurableConnection> { // Closes the connection by releasing this instance's reference on its socket. void Close(); - scoped_refptr<net::StreamListenSocket> socket_; + scoped_ptr<net::StreamListenSocket> socket_; Request r_; SendOptions options_; std::string data_; @@ -432,12 +433,12 @@ class HTTPTestServer : public net::StreamListenSocket::Delegate { // StreamListenSocket::Delegate overrides. virtual void DidAccept(net::StreamListenSocket* server, - net::StreamListenSocket* socket); + scoped_ptr<net::StreamListenSocket> socket); virtual void DidRead(net::StreamListenSocket* socket, const char* data, int len); virtual void DidClose(net::StreamListenSocket* socket); - scoped_refptr<net::StreamListenSocket> server_; + scoped_ptr<net::StreamListenSocket> server_; ConnectionList connection_list_; DISALLOW_COPY_AND_ASSIGN(HTTPTestServer); |