| Index: net/test/embedded_test_server/embedded_test_server.cc
|
| diff --git a/net/test/embedded_test_server/embedded_test_server.cc b/net/test/embedded_test_server/embedded_test_server.cc
|
| index 3d246d1a820588adb19cb8698fc60a6e56aa7db8..c7cf1efa7fff34c4b822fcb0d68ff6cb3a2d10dc 100644
|
| --- a/net/test/embedded_test_server/embedded_test_server.cc
|
| +++ b/net/test/embedded_test_server/embedded_test_server.cc
|
| @@ -99,6 +99,10 @@ HttpListenSocket::~HttpListenSocket() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| }
|
|
|
| +void HttpListenSocket::DetachFromThread() {
|
| + thread_checker_.DetachFromThread();
|
| +}
|
| +
|
| EmbeddedTestServer::EmbeddedTestServer()
|
| : port_(-1),
|
| weak_factory_(this) {
|
| @@ -114,21 +118,31 @@ EmbeddedTestServer::~EmbeddedTestServer() {
|
| }
|
|
|
| bool EmbeddedTestServer::InitializeAndWaitUntilReady() {
|
| - base::Thread::Options thread_options;
|
| - thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
|
| - io_thread_.reset(new base::Thread("EmbeddedTestServer io thread"));
|
| - CHECK(io_thread_->StartWithOptions(thread_options));
|
| -
|
| + StartThread();
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| if (!PostTaskToIOThreadAndWait(base::Bind(
|
| &EmbeddedTestServer::InitializeOnIOThread, base::Unretained(this)))) {
|
| return false;
|
| }
|
| -
|
| return Started() && base_url_.is_valid();
|
| }
|
|
|
| +void EmbeddedTestServer::StartThread() {
|
| + DCHECK(!io_thread_.get());
|
| + base::Thread::Options thread_options;
|
| + thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
|
| + io_thread_.reset(new base::Thread("EmbeddedTestServer io thread"));
|
| + CHECK(io_thread_->StartWithOptions(thread_options));
|
| +}
|
| +
|
| +void EmbeddedTestServer::StopThread() {
|
| + io_thread_->Stop();
|
| + io_thread_.reset();
|
| + thread_checker_.DetachFromThread();
|
| + listen_socket_->DetachFromThread();
|
| +}
|
| +
|
| bool EmbeddedTestServer::ShutdownAndWaitUntilComplete() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|