| 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 "base/lazy_instance.h" | 5 #include "base/lazy_instance.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "components/grpc_support/include/bidirectional_stream_c.h" | 14 #include "components/grpc_support/include/bidirectional_stream_c.h" |
| 15 #include "components/grpc_support/test/quic_test_server.h" | 15 #include "components/grpc_support/test/quic_test_server.h" |
| 16 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
| 17 #include "net/cert/mock_cert_verifier.h" | 17 #include "net/cert/mock_cert_verifier.h" |
| 18 #include "net/dns/mapped_host_resolver.h" | 18 #include "net/dns/mapped_host_resolver.h" |
| 19 #include "net/dns/mock_host_resolver.h" | 19 #include "net/dns/mock_host_resolver.h" |
| 20 #include "net/http/http_server_properties_impl.h" | 20 #include "net/http/http_server_properties_impl.h" |
| 21 #include "net/quic/core/quic_versions.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
| 22 | 23 |
| 23 namespace grpc_support { | 24 namespace grpc_support { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // URLRequestContextGetter for BidirectionalStreamTest. This is used instead of | 27 // URLRequestContextGetter for BidirectionalStreamTest. This is used instead of |
| 27 // net::TestURLRequestContextGetter because the URLRequestContext needs to be | 28 // net::TestURLRequestContextGetter because the URLRequestContext needs to be |
| 28 // created on the test_io_thread_ for the test, and TestURLRequestContextGetter | 29 // created on the test_io_thread_ for the test, and TestURLRequestContextGetter |
| 29 // does not allow for lazy instantiation of the URLRequestContext if additional | 30 // does not allow for lazy instantiation of the URLRequestContext if additional |
| 30 // setup is required. | 31 // setup is required. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 mock_cert_verifier_->set_default_result(net::OK); | 48 mock_cert_verifier_->set_default_result(net::OK); |
| 48 server_properties_.reset(new net::HttpServerPropertiesImpl()); | 49 server_properties_.reset(new net::HttpServerPropertiesImpl()); |
| 49 | 50 |
| 50 // Need to enable QUIC for the test server. | 51 // Need to enable QUIC for the test server. |
| 51 auto params = base::MakeUnique<net::HttpNetworkSession::Params>(); | 52 auto params = base::MakeUnique<net::HttpNetworkSession::Params>(); |
| 52 params->enable_quic = true; | 53 params->enable_quic = true; |
| 53 params->enable_http2 = true; | 54 params->enable_http2 = true; |
| 54 net::AlternativeService alternative_service(net::kProtoQUIC, "", 443); | 55 net::AlternativeService alternative_service(net::kProtoQUIC, "", 443); |
| 55 url::SchemeHostPort quic_hint_server("https", kTestServerHost, 443); | 56 url::SchemeHostPort quic_hint_server("https", kTestServerHost, 443); |
| 56 server_properties_->SetAlternativeService( | 57 server_properties_->SetAlternativeService( |
| 57 quic_hint_server, alternative_service, base::Time::Max()); | 58 quic_hint_server, alternative_service, base::Time::Max(), |
| 59 net::QuicVersionVector()); |
| 58 | 60 |
| 59 request_context_->set_cert_verifier(mock_cert_verifier_.get()); | 61 request_context_->set_cert_verifier(mock_cert_verifier_.get()); |
| 60 request_context_->set_host_resolver(host_resolver_.get()); | 62 request_context_->set_host_resolver(host_resolver_.get()); |
| 61 request_context_->set_http_server_properties(server_properties_.get()); | 63 request_context_->set_http_server_properties(server_properties_.get()); |
| 62 request_context_->set_http_network_session_params(std::move(params)); | 64 request_context_->set_http_network_session_params(std::move(params)); |
| 63 | 65 |
| 64 request_context_->Init(); | 66 request_context_->Init(); |
| 65 } | 67 } |
| 66 return request_context_.get(); | 68 return request_context_.get(); |
| 67 } | 69 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 g_request_context_getter_.Get()->SetTestServerPort(port); | 127 g_request_context_getter_.Get()->SetTestServerPort(port); |
| 126 static stream_engine engine; | 128 static stream_engine engine; |
| 127 engine.obj = g_request_context_getter_.Get().get(); | 129 engine.obj = g_request_context_getter_.Get().get(); |
| 128 return &engine; | 130 return &engine; |
| 129 } | 131 } |
| 130 | 132 |
| 131 void StartTestStreamEngine(int port) {} | 133 void StartTestStreamEngine(int port) {} |
| 132 void ShutdownTestStreamEngine() {} | 134 void ShutdownTestStreamEngine() {} |
| 133 | 135 |
| 134 } // namespace grpc_support | 136 } // namespace grpc_support |
| OLD | NEW |