Chromium Code Reviews| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 if (result == OK) { | 191 if (result == OK) { |
| 192 base_url_ = GURL(std::string("http://") + address.ToString()); | 192 base_url_ = GURL(std::string("http://") + address.ToString()); |
| 193 } else { | 193 } else { |
| 194 LOG(ERROR) << "GetLocalAddress failed: " << ErrorToString(result); | 194 LOG(ERROR) << "GetLocalAddress failed: " << ErrorToString(result); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 void EmbeddedTestServer::ListenOnIOThread() { | 198 void EmbeddedTestServer::ListenOnIOThread() { |
| 199 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 199 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
| 200 DCHECK(Started()); | 200 DCHECK(Started()); |
| 201 | |
| 202 #if !defined(OS_POSIX) | |
| 203 // Releases the socket here so that we could rebind it and watch it on the | |
| 204 // right IO thread below. An alternative is to simply call | |
| 205 // StreamListenSocket::WatchSocket, which is protected at the moment. | |
| 206 // This hack is only needed for non POSIX platforms, since on POSIX platforms | |
| 207 // StreamListenSocket::Listen calls StreamListenSocket::WatchSocket inside the | |
| 208 // function. | |
| 209 listen_socket_.reset(); | |
| 210 | |
| 211 SocketDescriptor socket_descriptor = | |
| 212 TCPListenSocket::CreateAndBind("127.0.0.1", port_); | |
|
xiyuan
2014/08/11 22:00:41
Thank you for digging through the problem.
Maybe
oshima
2014/08/12 04:27:25
sounds good to me.
If this was broken, I'm curiou
guohui
2014/08/12 15:55:19
thanks xiyuan, missed that =)
i think it is becau
| |
| 213 if (socket_descriptor == kInvalidSocket) | |
| 214 return; | |
| 215 | |
| 216 listen_socket_.reset(new HttpListenSocket(socket_descriptor, this)); | |
| 217 #endif | |
| 218 | |
| 201 listen_socket_->Listen(); | 219 listen_socket_->Listen(); |
| 202 } | 220 } |
| 203 | 221 |
| 204 void EmbeddedTestServer::ShutdownOnIOThread() { | 222 void EmbeddedTestServer::ShutdownOnIOThread() { |
| 205 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 223 DCHECK(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
| 206 | 224 |
| 207 listen_socket_.reset(); | 225 listen_socket_.reset(); |
| 208 STLDeleteContainerPairSecondPointers(connections_.begin(), | 226 STLDeleteContainerPairSecondPointers(connections_.begin(), |
| 209 connections_.end()); | 227 connections_.end()); |
| 210 connections_.clear(); | 228 connections_.clear(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 FROM_HERE, closure, run_loop.QuitClosure())) { | 345 FROM_HERE, closure, run_loop.QuitClosure())) { |
| 328 return false; | 346 return false; |
| 329 } | 347 } |
| 330 run_loop.Run(); | 348 run_loop.Run(); |
| 331 | 349 |
| 332 return true; | 350 return true; |
| 333 } | 351 } |
| 334 | 352 |
| 335 } // namespace test_server | 353 } // namespace test_server |
| 336 } // namespace net | 354 } // namespace net |
| OLD | NEW |