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 <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 scheme->assign(gurl.scheme()); | 43 scheme->assign(gurl.scheme()); |
44 host->assign(gurl.host()); | 44 host->assign(gurl.host()); |
45 if (gurl.has_port()) { | 45 if (gurl.has_port()) { |
46 host->append(":"); | 46 host->append(":"); |
47 host->append(gurl.port()); | 47 host->append(gurl.port()); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 std::vector<NextProto> SpdyNextProtos() { | 53 NextProtoVector SpdyNextProtos() { |
54 std::vector<NextProto> next_protos; | 54 NextProtoVector next_protos; |
55 for (int i = kProtoMinimumVersion; i <= kProtoMaximumVersion; ++i) { | 55 for (int i = kProtoMinimumVersion; i <= kProtoMaximumVersion; ++i) { |
56 next_protos.push_back(static_cast<NextProto>(i)); | 56 next_protos.push_back(static_cast<NextProto>(i)); |
57 } | 57 } |
58 return next_protos; | 58 return next_protos; |
59 } | 59 } |
60 | 60 |
61 // Chop a frame into an array of MockWrites. | 61 // Chop a frame into an array of MockWrites. |
62 // |data| is the frame to chop. | 62 // |data| is the frame to chop. |
63 // |length| is the length of the frame to chop. | 63 // |length| is the length of the frame to chop. |
64 // |num_chunks| is the number of chunks to create. | 64 // |num_chunks| is the number of chunks to create. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 deterministic_socket_factory(new DeterministicMockClientSocketFactory), | 350 deterministic_socket_factory(new DeterministicMockClientSocketFactory), |
351 http_auth_handler_factory( | 351 http_auth_handler_factory( |
352 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 352 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
353 enable_ip_pooling(true), | 353 enable_ip_pooling(true), |
354 enable_compression(false), | 354 enable_compression(false), |
355 enable_ping(false), | 355 enable_ping(false), |
356 enable_user_alternate_protocol_ports(false), | 356 enable_user_alternate_protocol_ports(false), |
357 protocol(protocol), | 357 protocol(protocol), |
358 stream_initial_recv_window_size(kSpdyStreamInitialWindowSize), | 358 stream_initial_recv_window_size(kSpdyStreamInitialWindowSize), |
359 time_func(&base::TimeTicks::Now), | 359 time_func(&base::TimeTicks::Now), |
| 360 force_spdy_over_ssl(false), |
| 361 force_spdy_always(false), |
| 362 use_alternate_protocols(false), |
360 net_log(NULL) { | 363 net_log(NULL) { |
361 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | 364 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; |
362 | 365 |
363 // Note: The CancelledTransaction test does cleanup by running all | 366 // Note: The CancelledTransaction test does cleanup by running all |
364 // tasks in the message loop (RunAllPending). Unfortunately, that | 367 // tasks in the message loop (RunAllPending). Unfortunately, that |
365 // doesn't clean up tasks on the host resolver thread; and | 368 // doesn't clean up tasks on the host resolver thread; and |
366 // TCPConnectJob is currently not cancellable. Using synchronous | 369 // TCPConnectJob is currently not cancellable. Using synchronous |
367 // lookups allows the test to shutdown cleanly. Until we have | 370 // lookups allows the test to shutdown cleanly. Until we have |
368 // cancellable TCPConnectJobs, use synchronous lookups. | 371 // cancellable TCPConnectJobs, use synchronous lookups. |
369 host_resolver->set_synchronous_mode(true); | 372 host_resolver->set_synchronous_mode(true); |
(...skipping 10 matching lines...) Expand all Loading... |
380 deterministic_socket_factory(new DeterministicMockClientSocketFactory), | 383 deterministic_socket_factory(new DeterministicMockClientSocketFactory), |
381 http_auth_handler_factory( | 384 http_auth_handler_factory( |
382 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 385 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
383 enable_ip_pooling(true), | 386 enable_ip_pooling(true), |
384 enable_compression(false), | 387 enable_compression(false), |
385 enable_ping(false), | 388 enable_ping(false), |
386 enable_user_alternate_protocol_ports(false), | 389 enable_user_alternate_protocol_ports(false), |
387 protocol(protocol), | 390 protocol(protocol), |
388 stream_initial_recv_window_size(kSpdyStreamInitialWindowSize), | 391 stream_initial_recv_window_size(kSpdyStreamInitialWindowSize), |
389 time_func(&base::TimeTicks::Now), | 392 time_func(&base::TimeTicks::Now), |
| 393 force_spdy_over_ssl(false), |
| 394 force_spdy_always(false), |
| 395 use_alternate_protocols(false), |
390 net_log(NULL) { | 396 net_log(NULL) { |
391 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | 397 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; |
392 } | 398 } |
393 | 399 |
394 SpdySessionDependencies::~SpdySessionDependencies() {} | 400 SpdySessionDependencies::~SpdySessionDependencies() {} |
395 | 401 |
396 // static | 402 // static |
397 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession( | 403 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession( |
398 SpdySessionDependencies* session_deps) { | 404 SpdySessionDependencies* session_deps) { |
399 net::HttpNetworkSession::Params params = CreateSessionParams(session_deps); | 405 net::HttpNetworkSession::Params params = CreateSessionParams(session_deps); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 params.http_server_properties = | 440 params.http_server_properties = |
435 session_deps->http_server_properties.GetWeakPtr(); | 441 session_deps->http_server_properties.GetWeakPtr(); |
436 params.enable_spdy_compression = session_deps->enable_compression; | 442 params.enable_spdy_compression = session_deps->enable_compression; |
437 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; | 443 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; |
438 params.enable_user_alternate_protocol_ports = | 444 params.enable_user_alternate_protocol_ports = |
439 session_deps->enable_user_alternate_protocol_ports; | 445 session_deps->enable_user_alternate_protocol_ports; |
440 params.spdy_default_protocol = session_deps->protocol; | 446 params.spdy_default_protocol = session_deps->protocol; |
441 params.spdy_stream_initial_recv_window_size = | 447 params.spdy_stream_initial_recv_window_size = |
442 session_deps->stream_initial_recv_window_size; | 448 session_deps->stream_initial_recv_window_size; |
443 params.time_func = session_deps->time_func; | 449 params.time_func = session_deps->time_func; |
| 450 params.next_protos = session_deps->next_protos; |
444 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; | 451 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; |
| 452 params.force_spdy_over_ssl = session_deps->force_spdy_over_ssl; |
| 453 params.force_spdy_always = session_deps->force_spdy_always; |
| 454 params.use_alternate_protocols = session_deps->use_alternate_protocols; |
445 params.net_log = session_deps->net_log; | 455 params.net_log = session_deps->net_log; |
446 return params; | 456 return params; |
447 } | 457 } |
448 | 458 |
449 SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol) | 459 SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol, |
| 460 bool force_spdy_over_ssl, |
| 461 bool force_spdy_always) |
450 : storage_(this) { | 462 : storage_(this) { |
451 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | 463 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; |
452 | 464 |
453 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); | 465 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); |
454 storage_.set_cert_verifier(new MockCertVerifier); | 466 storage_.set_cert_verifier(new MockCertVerifier); |
455 storage_.set_transport_security_state(new TransportSecurityState); | 467 storage_.set_transport_security_state(new TransportSecurityState); |
456 storage_.set_proxy_service(ProxyService::CreateDirect()); | 468 storage_.set_proxy_service(ProxyService::CreateDirect()); |
457 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 469 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
458 storage_.set_http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault( | 470 storage_.set_http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault( |
459 host_resolver())); | 471 host_resolver())); |
460 storage_.set_http_server_properties( | 472 storage_.set_http_server_properties( |
461 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 473 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
462 net::HttpNetworkSession::Params params; | 474 net::HttpNetworkSession::Params params; |
463 params.client_socket_factory = &socket_factory_; | 475 params.client_socket_factory = &socket_factory_; |
464 params.host_resolver = host_resolver(); | 476 params.host_resolver = host_resolver(); |
465 params.cert_verifier = cert_verifier(); | 477 params.cert_verifier = cert_verifier(); |
466 params.transport_security_state = transport_security_state(); | 478 params.transport_security_state = transport_security_state(); |
467 params.proxy_service = proxy_service(); | 479 params.proxy_service = proxy_service(); |
468 params.ssl_config_service = ssl_config_service(); | 480 params.ssl_config_service = ssl_config_service(); |
469 params.http_auth_handler_factory = http_auth_handler_factory(); | 481 params.http_auth_handler_factory = http_auth_handler_factory(); |
470 params.network_delegate = network_delegate(); | 482 params.network_delegate = network_delegate(); |
471 params.enable_spdy_compression = false; | 483 params.enable_spdy_compression = false; |
472 params.enable_spdy_ping_based_connection_checking = false; | 484 params.enable_spdy_ping_based_connection_checking = false; |
473 params.spdy_default_protocol = protocol; | 485 params.spdy_default_protocol = protocol; |
| 486 params.force_spdy_over_ssl = force_spdy_over_ssl; |
| 487 params.force_spdy_always = force_spdy_always; |
474 params.http_server_properties = http_server_properties(); | 488 params.http_server_properties = http_server_properties(); |
475 scoped_refptr<HttpNetworkSession> network_session( | 489 scoped_refptr<HttpNetworkSession> network_session( |
476 new HttpNetworkSession(params)); | 490 new HttpNetworkSession(params)); |
477 SpdySessionPoolPeer pool_peer(network_session->spdy_session_pool()); | 491 SpdySessionPoolPeer pool_peer(network_session->spdy_session_pool()); |
478 pool_peer.SetEnableSendingInitialData(false); | 492 pool_peer.SetEnableSendingInitialData(false); |
479 storage_.set_http_transaction_factory(new HttpCache( | 493 storage_.set_http_transaction_factory(new HttpCache( |
480 network_session.get(), HttpCache::DefaultBackend::InMemory(0))); | 494 network_session.get(), HttpCache::DefaultBackend::InMemory(0))); |
481 } | 495 } |
482 | 496 |
483 SpdyURLRequestContext::~SpdyURLRequestContext() { | 497 SpdyURLRequestContext::~SpdyURLRequestContext() { |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 } | 1234 } |
1221 } | 1235 } |
1222 | 1236 |
1223 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1237 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1224 SpdySynStreamIR* ir) const { | 1238 SpdySynStreamIR* ir) const { |
1225 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1239 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1226 priority, spdy_version())); | 1240 priority, spdy_version())); |
1227 } | 1241 } |
1228 | 1242 |
1229 } // namespace net | 1243 } // namespace net |
OLD | NEW |