| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 19 #include "net/cert/ct_policy_enforcer.h" |
| 19 #include "net/cert/mock_cert_verifier.h" | 20 #include "net/cert/mock_cert_verifier.h" |
| 21 #include "net/cert/multi_log_ct_verifier.h" |
| 20 #include "net/http/http_cache.h" | 22 #include "net/http/http_cache.h" |
| 21 #include "net/http/http_network_session.h" | 23 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_network_transaction.h" | 24 #include "net/http/http_network_transaction.h" |
| 23 #include "net/http/http_server_properties_impl.h" | 25 #include "net/http/http_server_properties_impl.h" |
| 24 #include "net/socket/socket_test_util.h" | 26 #include "net/socket/socket_test_util.h" |
| 25 #include "net/socket/ssl_client_socket.h" | 27 #include "net/socket/ssl_client_socket.h" |
| 26 #include "net/socket/transport_client_socket_pool.h" | 28 #include "net/socket/transport_client_socket_pool.h" |
| 27 #include "net/spdy/buffered_spdy_framer.h" | 29 #include "net/spdy/buffered_spdy_framer.h" |
| 28 #include "net/spdy/spdy_alt_svc_wire_format.h" | 30 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 29 #include "net/spdy/spdy_framer.h" | 31 #include "net/spdy/spdy_framer.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 MockECSignatureCreatorFactory::~MockECSignatureCreatorFactory() { | 326 MockECSignatureCreatorFactory::~MockECSignatureCreatorFactory() { |
| 325 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); | 327 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); |
| 326 } | 328 } |
| 327 | 329 |
| 328 crypto::ECSignatureCreator* MockECSignatureCreatorFactory::Create( | 330 crypto::ECSignatureCreator* MockECSignatureCreatorFactory::Create( |
| 329 crypto::ECPrivateKey* key) { | 331 crypto::ECPrivateKey* key) { |
| 330 return new MockECSignatureCreator(key); | 332 return new MockECSignatureCreator(key); |
| 331 } | 333 } |
| 332 | 334 |
| 333 SpdySessionDependencies::SpdySessionDependencies(NextProto protocol) | 335 SpdySessionDependencies::SpdySessionDependencies(NextProto protocol) |
| 336 : SpdySessionDependencies(protocol, ProxyService::CreateDirect()) {} |
| 337 |
| 338 SpdySessionDependencies::SpdySessionDependencies( |
| 339 NextProto protocol, |
| 340 std::unique_ptr<ProxyService> proxy_service) |
| 334 : host_resolver(new MockCachingHostResolver), | 341 : host_resolver(new MockCachingHostResolver), |
| 335 cert_verifier(new MockCertVerifier), | 342 cert_verifier(new MockCertVerifier), |
| 336 channel_id_service(nullptr), | 343 channel_id_service(nullptr), |
| 337 transport_security_state(new TransportSecurityState), | 344 transport_security_state(new TransportSecurityState), |
| 338 proxy_service(ProxyService::CreateDirect()), | 345 cert_transparency_verifier(new MultiLogCTVerifier), |
| 346 ct_policy_enforcer(new CTPolicyEnforcer), |
| 347 proxy_service(std::move(proxy_service)), |
| 339 ssl_config_service(new SSLConfigServiceDefaults), | 348 ssl_config_service(new SSLConfigServiceDefaults), |
| 340 socket_factory(new MockClientSocketFactory), | 349 socket_factory(new MockClientSocketFactory), |
| 341 http_auth_handler_factory( | 350 http_auth_handler_factory( |
| 342 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 351 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
| 343 http_server_properties(new HttpServerPropertiesImpl), | 352 http_server_properties(new HttpServerPropertiesImpl), |
| 344 enable_ip_pooling(true), | 353 enable_ip_pooling(true), |
| 345 enable_ping(false), | 354 enable_ping(false), |
| 346 enable_user_alternate_protocol_ports(false), | 355 enable_user_alternate_protocol_ports(false), |
| 347 enable_npn(false), | 356 enable_npn(false), |
| 348 enable_priority_dependencies(true), | 357 enable_priority_dependencies(true), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 361 | 370 |
| 362 // Note: The CancelledTransaction test does cleanup by running all | 371 // Note: The CancelledTransaction test does cleanup by running all |
| 363 // tasks in the message loop (RunAllPending). Unfortunately, that | 372 // tasks in the message loop (RunAllPending). Unfortunately, that |
| 364 // doesn't clean up tasks on the host resolver thread; and | 373 // doesn't clean up tasks on the host resolver thread; and |
| 365 // TCPConnectJob is currently not cancellable. Using synchronous | 374 // TCPConnectJob is currently not cancellable. Using synchronous |
| 366 // lookups allows the test to shutdown cleanly. Until we have | 375 // lookups allows the test to shutdown cleanly. Until we have |
| 367 // cancellable TCPConnectJobs, use synchronous lookups. | 376 // cancellable TCPConnectJobs, use synchronous lookups. |
| 368 host_resolver->set_synchronous_mode(true); | 377 host_resolver->set_synchronous_mode(true); |
| 369 } | 378 } |
| 370 | 379 |
| 371 SpdySessionDependencies::SpdySessionDependencies( | |
| 372 NextProto protocol, | |
| 373 std::unique_ptr<ProxyService> proxy_service) | |
| 374 : host_resolver(new MockHostResolver), | |
| 375 cert_verifier(new MockCertVerifier), | |
| 376 channel_id_service(nullptr), | |
| 377 transport_security_state(new TransportSecurityState), | |
| 378 proxy_service(std::move(proxy_service)), | |
| 379 ssl_config_service(new SSLConfigServiceDefaults), | |
| 380 socket_factory(new MockClientSocketFactory), | |
| 381 http_auth_handler_factory( | |
| 382 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | |
| 383 http_server_properties(new HttpServerPropertiesImpl), | |
| 384 enable_ip_pooling(true), | |
| 385 enable_ping(false), | |
| 386 enable_user_alternate_protocol_ports(false), | |
| 387 enable_npn(false), | |
| 388 enable_priority_dependencies(true), | |
| 389 enable_spdy31(true), | |
| 390 enable_quic(false), | |
| 391 enable_alternative_service_for_insecure_origins(true), | |
| 392 protocol(protocol), | |
| 393 session_max_recv_window_size( | |
| 394 SpdySession::GetDefaultInitialWindowSize(protocol)), | |
| 395 stream_max_recv_window_size( | |
| 396 SpdySession::GetDefaultInitialWindowSize(protocol)), | |
| 397 time_func(&base::TimeTicks::Now), | |
| 398 enable_alternative_service_with_different_host(true), | |
| 399 net_log(NULL) { | |
| 400 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | |
| 401 } | |
| 402 | |
| 403 SpdySessionDependencies::~SpdySessionDependencies() {} | 380 SpdySessionDependencies::~SpdySessionDependencies() {} |
| 404 | 381 |
| 405 // static | 382 // static |
| 406 std::unique_ptr<HttpNetworkSession> SpdySessionDependencies::SpdyCreateSession( | 383 std::unique_ptr<HttpNetworkSession> SpdySessionDependencies::SpdyCreateSession( |
| 407 SpdySessionDependencies* session_deps) { | 384 SpdySessionDependencies* session_deps) { |
| 408 HttpNetworkSession::Params params = CreateSessionParams(session_deps); | 385 HttpNetworkSession::Params params = CreateSessionParams(session_deps); |
| 409 params.client_socket_factory = session_deps->socket_factory.get(); | 386 params.client_socket_factory = session_deps->socket_factory.get(); |
| 410 std::unique_ptr<HttpNetworkSession> http_session( | 387 std::unique_ptr<HttpNetworkSession> http_session( |
| 411 new HttpNetworkSession(params)); | 388 new HttpNetworkSession(params)); |
| 412 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); | 389 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); |
| 413 pool_peer.SetEnableSendingInitialData(false); | 390 pool_peer.SetEnableSendingInitialData(false); |
| 414 return http_session; | 391 return http_session; |
| 415 } | 392 } |
| 416 | 393 |
| 417 // static | 394 // static |
| 418 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( | 395 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( |
| 419 SpdySessionDependencies* session_deps) { | 396 SpdySessionDependencies* session_deps) { |
| 420 DCHECK(next_proto_is_spdy(session_deps->protocol)) << | 397 DCHECK(next_proto_is_spdy(session_deps->protocol)) << |
| 421 "Invalid protocol: " << session_deps->protocol; | 398 "Invalid protocol: " << session_deps->protocol; |
| 422 | 399 |
| 423 HttpNetworkSession::Params params; | 400 HttpNetworkSession::Params params; |
| 424 params.host_resolver = session_deps->host_resolver.get(); | 401 params.host_resolver = session_deps->host_resolver.get(); |
| 425 params.cert_verifier = session_deps->cert_verifier.get(); | 402 params.cert_verifier = session_deps->cert_verifier.get(); |
| 426 params.channel_id_service = session_deps->channel_id_service.get(); | 403 params.channel_id_service = session_deps->channel_id_service.get(); |
| 427 params.transport_security_state = | 404 params.transport_security_state = |
| 428 session_deps->transport_security_state.get(); | 405 session_deps->transport_security_state.get(); |
| 406 params.cert_transparency_verifier = |
| 407 session_deps->cert_transparency_verifier.get(); |
| 408 params.ct_policy_enforcer = session_deps->ct_policy_enforcer.get(); |
| 429 params.proxy_service = session_deps->proxy_service.get(); | 409 params.proxy_service = session_deps->proxy_service.get(); |
| 430 params.ssl_config_service = session_deps->ssl_config_service.get(); | 410 params.ssl_config_service = session_deps->ssl_config_service.get(); |
| 431 params.http_auth_handler_factory = | 411 params.http_auth_handler_factory = |
| 432 session_deps->http_auth_handler_factory.get(); | 412 session_deps->http_auth_handler_factory.get(); |
| 433 params.http_server_properties = session_deps->http_server_properties.get(); | 413 params.http_server_properties = session_deps->http_server_properties.get(); |
| 434 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; | 414 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; |
| 435 params.enable_user_alternate_protocol_ports = | 415 params.enable_user_alternate_protocol_ports = |
| 436 session_deps->enable_user_alternate_protocol_ports; | 416 session_deps->enable_user_alternate_protocol_ports; |
| 437 params.enable_npn = session_deps->enable_npn; | 417 params.enable_npn = session_deps->enable_npn; |
| 438 params.enable_priority_dependencies = | 418 params.enable_priority_dependencies = |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 } | 1299 } |
| 1320 } | 1300 } |
| 1321 | 1301 |
| 1322 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1302 void SpdyTestUtil::SetPriority(RequestPriority priority, |
| 1323 SpdySynStreamIR* ir) const { | 1303 SpdySynStreamIR* ir) const { |
| 1324 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1304 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
| 1325 priority, spdy_version())); | 1305 priority, spdy_version())); |
| 1326 } | 1306 } |
| 1327 | 1307 |
| 1328 } // namespace net | 1308 } // namespace net |
| OLD | NEW |