OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/test/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return PostTaskToIOThreadAndWait(base::Bind( | 183 return PostTaskToIOThreadAndWait(base::Bind( |
184 &EmbeddedTestServer::ShutdownOnIOThread, base::Unretained(this))); | 184 &EmbeddedTestServer::ShutdownOnIOThread, base::Unretained(this))); |
185 } | 185 } |
186 | 186 |
187 void EmbeddedTestServer::StartThread() { | 187 void EmbeddedTestServer::StartThread() { |
188 DCHECK(!io_thread_.get()); | 188 DCHECK(!io_thread_.get()); |
189 base::Thread::Options thread_options; | 189 base::Thread::Options thread_options; |
190 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 190 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
191 io_thread_.reset(new base::Thread("EmbeddedTestServer io thread")); | 191 io_thread_.reset(new base::Thread("EmbeddedTestServer io thread")); |
192 CHECK(io_thread_->StartWithOptions(thread_options)); | 192 CHECK(io_thread_->StartWithOptions(thread_options)); |
193 CHECK(io_thread_->WaitUntilThreadStarted()); | |
194 } | 193 } |
195 | 194 |
196 void EmbeddedTestServer::InitializeOnIOThread() { | 195 void EmbeddedTestServer::InitializeOnIOThread() { |
197 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 196 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
198 DCHECK(!Started()); | 197 DCHECK(!Started()); |
199 | 198 |
200 SocketDescriptor socket_descriptor = | 199 SocketDescriptor socket_descriptor = |
201 TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port_); | 200 TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port_); |
202 if (socket_descriptor == kInvalidSocket) | 201 if (socket_descriptor == kInvalidSocket) |
203 return; | 202 return; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 FROM_HERE, closure, run_loop.QuitClosure())) { | 353 FROM_HERE, closure, run_loop.QuitClosure())) { |
355 return false; | 354 return false; |
356 } | 355 } |
357 run_loop.Run(); | 356 run_loop.Run(); |
358 | 357 |
359 return true; | 358 return true; |
360 } | 359 } |
361 | 360 |
362 } // namespace test_server | 361 } // namespace test_server |
363 } // namespace net | 362 } // namespace net |
OLD | NEW |