Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: net/spdy/spdy_test_util_common.cc

Issue 1298253002: Remove reference counting from HttpNetworkSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 SpdySession::GetDefaultInitialWindowSize(protocol)), 409 SpdySession::GetDefaultInitialWindowSize(protocol)),
410 time_func(&base::TimeTicks::Now), 410 time_func(&base::TimeTicks::Now),
411 use_alternative_services(true), 411 use_alternative_services(true),
412 net_log(NULL) { 412 net_log(NULL) {
413 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; 413 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
414 } 414 }
415 415
416 SpdySessionDependencies::~SpdySessionDependencies() {} 416 SpdySessionDependencies::~SpdySessionDependencies() {}
417 417
418 // static 418 // static
419 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession( 419 scoped_ptr<HttpNetworkSession> SpdySessionDependencies::SpdyCreateSession(
420 SpdySessionDependencies* session_deps) { 420 SpdySessionDependencies* session_deps) {
421 HttpNetworkSession::Params params = CreateSessionParams(session_deps); 421 HttpNetworkSession::Params params = CreateSessionParams(session_deps);
422 params.client_socket_factory = session_deps->socket_factory.get(); 422 params.client_socket_factory = session_deps->socket_factory.get();
423 HttpNetworkSession* http_session = new HttpNetworkSession(params); 423 scoped_ptr<HttpNetworkSession> http_session(new HttpNetworkSession(params));
424 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); 424 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool());
425 pool_peer.SetEnableSendingInitialData(false); 425 pool_peer.SetEnableSendingInitialData(false);
426 return http_session; 426 return http_session.Pass();
427 } 427 }
428 428
429 // static 429 // static
430 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSessionDeterministic( 430 scoped_ptr<HttpNetworkSession>
431 SpdySessionDependencies::SpdyCreateSessionDeterministic(
431 SpdySessionDependencies* session_deps) { 432 SpdySessionDependencies* session_deps) {
432 HttpNetworkSession::Params params = CreateSessionParams(session_deps); 433 HttpNetworkSession::Params params = CreateSessionParams(session_deps);
433 params.client_socket_factory = 434 params.client_socket_factory =
434 session_deps->deterministic_socket_factory.get(); 435 session_deps->deterministic_socket_factory.get();
435 HttpNetworkSession* http_session = new HttpNetworkSession(params); 436 scoped_ptr<HttpNetworkSession> http_session(new HttpNetworkSession(params));
436 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); 437 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool());
437 pool_peer.SetEnableSendingInitialData(false); 438 pool_peer.SetEnableSendingInitialData(false);
438 return http_session; 439 return http_session.Pass();
439 } 440 }
440 441
441 // static 442 // static
442 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( 443 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams(
443 SpdySessionDependencies* session_deps) { 444 SpdySessionDependencies* session_deps) {
444 DCHECK(next_proto_is_spdy(session_deps->protocol)) << 445 DCHECK(next_proto_is_spdy(session_deps->protocol)) <<
445 "Invalid protocol: " << session_deps->protocol; 446 "Invalid protocol: " << session_deps->protocol;
446 447
447 HttpNetworkSession::Params params; 448 HttpNetworkSession::Params params;
448 params.host_resolver = session_deps->host_resolver.get(); 449 params.host_resolver = session_deps->host_resolver.get();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 params.cert_verifier = cert_verifier(); 494 params.cert_verifier = cert_verifier();
494 params.transport_security_state = transport_security_state(); 495 params.transport_security_state = transport_security_state();
495 params.proxy_service = proxy_service(); 496 params.proxy_service = proxy_service();
496 params.ssl_config_service = ssl_config_service(); 497 params.ssl_config_service = ssl_config_service();
497 params.http_auth_handler_factory = http_auth_handler_factory(); 498 params.http_auth_handler_factory = http_auth_handler_factory();
498 params.network_delegate = network_delegate(); 499 params.network_delegate = network_delegate();
499 params.enable_spdy_compression = false; 500 params.enable_spdy_compression = false;
500 params.enable_spdy_ping_based_connection_checking = false; 501 params.enable_spdy_ping_based_connection_checking = false;
501 params.spdy_default_protocol = protocol; 502 params.spdy_default_protocol = protocol;
502 params.http_server_properties = http_server_properties(); 503 params.http_server_properties = http_server_properties();
503 scoped_refptr<HttpNetworkSession> network_session( 504 storage_.set_http_network_session(
504 new HttpNetworkSession(params)); 505 make_scoped_ptr(new HttpNetworkSession(params)));
505 SpdySessionPoolPeer pool_peer(network_session->spdy_session_pool()); 506 SpdySessionPoolPeer pool_peer(
507 storage_.http_network_session()->spdy_session_pool());
506 pool_peer.SetEnableSendingInitialData(false); 508 pool_peer.SetEnableSendingInitialData(false);
507 storage_.set_http_transaction_factory(make_scoped_ptr(new HttpCache( 509 storage_.set_http_transaction_factory(make_scoped_ptr(
508 network_session.get(), HttpCache::DefaultBackend::InMemory(0)))); 510 new HttpCache(storage_.http_network_session(),
511 HttpCache::DefaultBackend::InMemory(0), false)));
509 } 512 }
510 513
511 SpdyURLRequestContext::~SpdyURLRequestContext() { 514 SpdyURLRequestContext::~SpdyURLRequestContext() {
512 AssertNoURLRequests(); 515 AssertNoURLRequests();
513 } 516 }
514 517
515 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key) { 518 bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key) {
516 return pool->FindAvailableSession(key, BoundNetLog()) != NULL; 519 return pool->FindAvailableSession(key, BoundNetLog()) != NULL;
517 } 520 }
518 521
519 namespace { 522 namespace {
520 523
521 base::WeakPtr<SpdySession> CreateSpdySessionHelper( 524 base::WeakPtr<SpdySession> CreateSpdySessionHelper(
522 const scoped_refptr<HttpNetworkSession>& http_session, 525 HttpNetworkSession* http_session,
523 const SpdySessionKey& key, 526 const SpdySessionKey& key,
524 const BoundNetLog& net_log, 527 const BoundNetLog& net_log,
525 Error expected_status, 528 Error expected_status,
526 bool is_secure) { 529 bool is_secure) {
527 EXPECT_FALSE(HasSpdySession(http_session->spdy_session_pool(), key)); 530 EXPECT_FALSE(HasSpdySession(http_session->spdy_session_pool(), key));
528 531
529 scoped_refptr<TransportSocketParams> transport_params( 532 scoped_refptr<TransportSocketParams> transport_params(
530 new TransportSocketParams( 533 new TransportSocketParams(
531 key.host_port_pair(), false, false, OnHostResolutionCallback(), 534 key.host_port_pair(), false, false, OnHostResolutionCallback(),
532 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); 535 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 key, connection.Pass(), net_log, OK, is_secure); 576 key, connection.Pass(), net_log, OK, is_secure);
574 // Failure is reported asynchronously. 577 // Failure is reported asynchronously.
575 EXPECT_TRUE(spdy_session != NULL); 578 EXPECT_TRUE(spdy_session != NULL);
576 EXPECT_TRUE(HasSpdySession(http_session->spdy_session_pool(), key)); 579 EXPECT_TRUE(HasSpdySession(http_session->spdy_session_pool(), key));
577 return spdy_session; 580 return spdy_session;
578 } 581 }
579 582
580 } // namespace 583 } // namespace
581 584
582 base::WeakPtr<SpdySession> CreateInsecureSpdySession( 585 base::WeakPtr<SpdySession> CreateInsecureSpdySession(
583 const scoped_refptr<HttpNetworkSession>& http_session, 586 HttpNetworkSession* http_session,
584 const SpdySessionKey& key, 587 const SpdySessionKey& key,
585 const BoundNetLog& net_log) { 588 const BoundNetLog& net_log) {
586 return CreateSpdySessionHelper(http_session, key, net_log, 589 return CreateSpdySessionHelper(http_session, key, net_log,
587 OK, false /* is_secure */); 590 OK, false /* is_secure */);
588 } 591 }
589 592
590 base::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure( 593 base::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure(
591 const scoped_refptr<HttpNetworkSession>& http_session, 594 HttpNetworkSession* http_session,
592 const SpdySessionKey& key, 595 const SpdySessionKey& key,
593 Error expected_error, 596 Error expected_error,
594 const BoundNetLog& net_log) { 597 const BoundNetLog& net_log) {
595 DCHECK_LT(expected_error, ERR_IO_PENDING); 598 DCHECK_LT(expected_error, ERR_IO_PENDING);
596 return CreateSpdySessionHelper(http_session, key, net_log, 599 return CreateSpdySessionHelper(http_session, key, net_log,
597 expected_error, false /* is_secure */); 600 expected_error, false /* is_secure */);
598 } 601 }
599 602
600 base::WeakPtr<SpdySession> CreateSecureSpdySession( 603 base::WeakPtr<SpdySession> CreateSecureSpdySession(
601 const scoped_refptr<HttpNetworkSession>& http_session, 604 HttpNetworkSession* http_session,
602 const SpdySessionKey& key, 605 const SpdySessionKey& key,
603 const BoundNetLog& net_log) { 606 const BoundNetLog& net_log) {
604 return CreateSpdySessionHelper(http_session, key, net_log, 607 return CreateSpdySessionHelper(http_session, key, net_log,
605 OK, true /* is_secure */); 608 OK, true /* is_secure */);
606 } 609 }
607 610
608 namespace { 611 namespace {
609 612
610 // A ClientSocket used for CreateFakeSpdySession() below. 613 // A ClientSocket used for CreateFakeSpdySession() below.
611 class FakeSpdySessionClientSocket : public MockClientSocket { 614 class FakeSpdySessionClientSocket : public MockClientSocket {
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 } 1342 }
1340 } 1343 }
1341 1344
1342 void SpdyTestUtil::SetPriority(RequestPriority priority, 1345 void SpdyTestUtil::SetPriority(RequestPriority priority,
1343 SpdySynStreamIR* ir) const { 1346 SpdySynStreamIR* ir) const {
1344 ir->set_priority(ConvertRequestPriorityToSpdyPriority( 1347 ir->set_priority(ConvertRequestPriorityToSpdyPriority(
1345 priority, spdy_version())); 1348 priority, spdy_version()));
1346 } 1349 }
1347 1350
1348 } // namespace net 1351 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698