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

Unified Diff: chrome/test/chromedriver/net/test_http_server.cc

Issue 497223003: Revert of Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 1d19524d9157f6f22918f880a5742ff21611ee5f..740a33d78e4409a67ed7c108867693049fb6c109 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_server_socket.h"
+#include "net/socket/tcp_listen_socket.h"
#include "testing/gtest/include/gtest/gtest.h"
TestHttpServer::TestHttpServer()
@@ -92,7 +92,10 @@
server_->Send404(connection_id);
break;
case kClose:
- server_->Close(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));
break;
}
}
@@ -109,7 +112,10 @@
server_->SendOverWebSocket(connection_id, data);
break;
case kCloseOnMessage:
- server_->Close(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));
break;
}
}
@@ -122,10 +128,8 @@
void TestHttpServer::StartOnServerThread(bool* success,
base::WaitableEvent* event) {
- scoped_ptr<net::ServerSocket> server_socket(
- new net::TCPServerSocket(NULL, net::NetLog::Source()));
- server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1);
- server_.reset(new net::HttpServer(server_socket.Pass(), this));
+ net::TCPListenSocketFactory factory("127.0.0.1", 0);
+ server_ = new net::HttpServer(factory, this);
net::IPEndPoint address;
int error = server_->GetLocalAddress(&address);
@@ -135,13 +139,14 @@
web_socket_url_ = GURL(base::StringPrintf("ws://127.0.0.1:%d",
address.port()));
} else {
- server_.reset(NULL);
+ server_ = NULL;
}
*success = server_.get();
event->Signal();
}
void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) {
- server_.reset(NULL);
+ if (server_.get())
+ server_ = NULL;
event->Signal();
}
« no previous file with comments | « chrome/test/chromedriver/net/test_http_server.h ('k') | chrome/test/chromedriver/server/chromedriver_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698