| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/grpc_support/test/quic_test_server.h" | 5 #include "components/grpc_support/test/quic_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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 SetupQuicHttpResponseCache(); | 76 SetupQuicHttpResponseCache(); |
| 77 | 77 |
| 78 g_quic_server = new net::QuicSimpleServer( | 78 g_quic_server = new net::QuicSimpleServer( |
| 79 std::move(proof_source), config, | 79 std::move(proof_source), config, |
| 80 net::QuicCryptoServerConfig::ConfigOptions(), net::AllSupportedVersions(), | 80 net::QuicCryptoServerConfig::ConfigOptions(), net::AllSupportedVersions(), |
| 81 g_quic_response_cache); | 81 g_quic_response_cache); |
| 82 | 82 |
| 83 // Start listening on an unbound port. | 83 // Start listening on an unbound port. |
| 84 int rv = g_quic_server->Listen( | 84 int rv = g_quic_server->Listen( |
| 85 net::IPEndPoint(net::IPAddress::IPv4AllZeros(), 0)); | 85 net::IPEndPoint(net::IPAddress::IPv4AllZeros(), 0)); |
| 86 CHECK_GE(rv, 0) << "Quic server fails to start"; | 86 // Quic server fails to start |
| 87 CHECK_GE(rv, 0); |
| 87 g_quic_server_port = g_quic_server->server_address().port(); | 88 g_quic_server_port = g_quic_server->server_address().port(); |
| 88 | 89 |
| 89 server_started_event->Signal(); | 90 server_started_event->Signal(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 void ShutdownOnServerThread(base::WaitableEvent* server_stopped_event) { | 93 void ShutdownOnServerThread(base::WaitableEvent* server_stopped_event) { |
| 93 DCHECK(g_quic_server_thread->task_runner()->BelongsToCurrentThread()); | 94 DCHECK(g_quic_server_thread->task_runner()->BelongsToCurrentThread()); |
| 94 g_quic_server->Shutdown(); | 95 g_quic_server->Shutdown(); |
| 95 delete g_quic_server; | 96 delete g_quic_server; |
| 96 g_quic_server = nullptr; | 97 g_quic_server = nullptr; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 server_stopped_event.Wait(); | 132 server_stopped_event.Wait(); |
| 132 delete g_quic_server_thread; | 133 delete g_quic_server_thread; |
| 133 g_quic_server_thread = nullptr; | 134 g_quic_server_thread = nullptr; |
| 134 } | 135 } |
| 135 | 136 |
| 136 int GetQuicTestServerPort() { | 137 int GetQuicTestServerPort() { |
| 137 return g_quic_server_port; | 138 return g_quic_server_port; |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace grpc_support | 141 } // namespace grpc_support |
| OLD | NEW |