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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(thread_checker_.CalledOnValidThread()); | 163 DCHECK(thread_checker_.CalledOnValidThread()); |
164 | 164 |
165 return PostTaskToIOThreadAndWait(base::Bind( | 165 return PostTaskToIOThreadAndWait(base::Bind( |
166 &EmbeddedTestServer::ShutdownOnIOThread, base::Unretained(this))); | 166 &EmbeddedTestServer::ShutdownOnIOThread, base::Unretained(this))); |
167 } | 167 } |
168 | 168 |
169 void EmbeddedTestServer::ShutdownOnIOThread() { | 169 void EmbeddedTestServer::ShutdownOnIOThread() { |
170 DCHECK(io_thread_->task_runner()->BelongsToCurrentThread()); | 170 DCHECK(io_thread_->task_runner()->BelongsToCurrentThread()); |
171 weak_factory_.InvalidateWeakPtrs(); | 171 weak_factory_.InvalidateWeakPtrs(); |
172 listen_socket_.reset(); | 172 listen_socket_.reset(); |
173 STLDeleteContainerPairSecondPointers(connections_.begin(), | 173 base::STLDeleteContainerPairSecondPointers(connections_.begin(), |
174 connections_.end()); | 174 connections_.end()); |
175 connections_.clear(); | 175 connections_.clear(); |
176 } | 176 } |
177 | 177 |
178 void EmbeddedTestServer::HandleRequest(HttpConnection* connection, | 178 void EmbeddedTestServer::HandleRequest(HttpConnection* connection, |
179 std::unique_ptr<HttpRequest> request) { | 179 std::unique_ptr<HttpRequest> request) { |
180 DCHECK(io_thread_->task_runner()->BelongsToCurrentThread()); | 180 DCHECK(io_thread_->task_runner()->BelongsToCurrentThread()); |
181 | 181 |
182 for (const auto& monitor : request_monitors_) | 182 for (const auto& monitor : request_monitors_) |
183 monitor.Run(*request); | 183 monitor.Run(*request); |
184 | 184 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 bool EmbeddedTestServer::FlushAllSocketsAndConnectionsOnUIThread() { | 339 bool EmbeddedTestServer::FlushAllSocketsAndConnectionsOnUIThread() { |
340 return PostTaskToIOThreadAndWait( | 340 return PostTaskToIOThreadAndWait( |
341 base::Bind(&EmbeddedTestServer::FlushAllSocketsAndConnections, | 341 base::Bind(&EmbeddedTestServer::FlushAllSocketsAndConnections, |
342 base::Unretained(this))); | 342 base::Unretained(this))); |
343 } | 343 } |
344 | 344 |
345 void EmbeddedTestServer::FlushAllSocketsAndConnections() { | 345 void EmbeddedTestServer::FlushAllSocketsAndConnections() { |
346 STLDeleteContainerPairSecondPointers(connections_.begin(), | 346 base::STLDeleteContainerPairSecondPointers(connections_.begin(), |
347 connections_.end()); | 347 connections_.end()); |
348 connections_.clear(); | 348 connections_.clear(); |
349 } | 349 } |
350 | 350 |
351 void EmbeddedTestServer::OnAcceptCompleted(int rv) { | 351 void EmbeddedTestServer::OnAcceptCompleted(int rv) { |
352 DCHECK_NE(ERR_IO_PENDING, rv); | 352 DCHECK_NE(ERR_IO_PENDING, rv); |
353 HandleAcceptResult(std::move(accepted_socket_)); | 353 HandleAcceptResult(std::move(accepted_socket_)); |
354 DoAcceptLoop(); | 354 DoAcceptLoop(); |
355 } | 355 } |
356 | 356 |
357 void EmbeddedTestServer::OnHandshakeDone(HttpConnection* connection, int rv) { | 357 void EmbeddedTestServer::OnHandshakeDone(HttpConnection* connection, int rv) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 run_loop.QuitClosure())) { | 463 run_loop.QuitClosure())) { |
464 return false; | 464 return false; |
465 } | 465 } |
466 run_loop.Run(); | 466 run_loop.Run(); |
467 | 467 |
468 return true; | 468 return true; |
469 } | 469 } |
470 | 470 |
471 } // namespace test_server | 471 } // namespace test_server |
472 } // namespace net | 472 } // namespace net |
OLD | NEW |