Chromium Code Reviews| 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..a7a4d081c0e100d809c93a4512364ed0c498f644 100644 |
| --- a/chrome/test/chromedriver/net/test_http_server.cc |
| +++ b/chrome/test/chromedriver/net/test_http_server.cc |
| @@ -13,7 +13,6 @@ |
| #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 "testing/gtest/include/gtest/gtest.h" |
| TestHttpServer::TestHttpServer() |
| @@ -95,7 +94,8 @@ void TestHttpServer::OnWebSocketRequest( |
| // 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)); |
| + base::Bind(&net::HttpServer::Close, server_->AsWeakPtr(), |
| + connection_id)); |
| break; |
| } |
| } |
| @@ -115,7 +115,8 @@ void TestHttpServer::OnWebSocketMessage(int connection_id, |
| // 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)); |
| + base::Bind(&net::HttpServer::Close, server_->AsWeakPtr(), |
| + connection_id)); |
| break; |
| } |
| } |
| @@ -128,8 +129,8 @@ 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); |
| + server_.reset(net::HttpServer::Create("127.0.0.1", 0, this)); |
| + EXPECT_NE(NULL, server_.get()); |
|
mmenke
2014/05/23 19:20:58
If this fails, we'll crash 2 lines down.
Suggest:
byungchul
2014/05/30 00:19:02
Removed.
|
| net::IPEndPoint address; |
| int error = server_->GetLocalAddress(&address); |
| @@ -139,14 +140,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(); |
| } |