Index: chrome/test/chromedriver/net/test_http_server.cc |
diff --git a/chrome/test/chromedriver/net/test_http_server.cc b/chrome/test/chromedriver/net/test_http_server.cc |
index 740a33d78e4409a67ed7c108867693049fb6c109..e7e975bb42d65dd1835740e475c1e87117bae157 100644 |
--- a/chrome/test/chromedriver/net/test_http_server.cc |
+++ b/chrome/test/chromedriver/net/test_http_server.cc |
@@ -13,7 +13,7 @@ |
#include "net/base/ip_endpoint.h" |
#include "net/base/net_errors.h" |
#include "net/server/http_server_request_info.h" |
-#include "net/socket/tcp_listen_socket.h" |
+#include "net/socket/tcp_server_socket.h" |
#include "testing/gtest/include/gtest/gtest.h" |
TestHttpServer::TestHttpServer() |
@@ -92,10 +92,7 @@ void TestHttpServer::OnWebSocketRequest( |
server_->Send404(connection_id); |
break; |
case kClose: |
- // net::HttpServer doesn't allow us to close connection during callback. |
- base::MessageLoop::current()->PostTask( |
- FROM_HERE, |
- base::Bind(&net::HttpServer::Close, server_, connection_id)); |
+ server_->Close(connection_id); |
break; |
} |
} |
@@ -112,10 +109,7 @@ void TestHttpServer::OnWebSocketMessage(int connection_id, |
server_->SendOverWebSocket(connection_id, data); |
break; |
case kCloseOnMessage: |
- // net::HttpServer doesn't allow us to close connection during callback. |
- base::MessageLoop::current()->PostTask( |
- FROM_HERE, |
- base::Bind(&net::HttpServer::Close, server_, connection_id)); |
+ server_->Close(connection_id); |
break; |
} |
} |
@@ -128,8 +122,9 @@ void TestHttpServer::OnClose(int connection_id) { |
void TestHttpServer::StartOnServerThread(bool* success, |
base::WaitableEvent* event) { |
- net::TCPListenSocketFactory factory("127.0.0.1", 0); |
- server_ = new net::HttpServer(factory, this); |
+ net::TCPServerSocketFactory factory; |
+ factory.SetAddressAndPort("127.0.0.1", 0); |
+ server_.reset(new net::HttpServer(factory.CreateAndListen(), this)); |
net::IPEndPoint address; |
int error = server_->GetLocalAddress(&address); |
@@ -139,14 +134,13 @@ void TestHttpServer::StartOnServerThread(bool* success, |
web_socket_url_ = GURL(base::StringPrintf("ws://127.0.0.1:%d", |
address.port())); |
} else { |
- server_ = NULL; |
+ server_.reset(NULL); |
} |
*success = server_.get(); |
event->Signal(); |
} |
void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) { |
- if (server_.get()) |
- server_ = NULL; |
+ server_.reset(NULL); |
event->Signal(); |
} |