diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-01 07:40:26 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-01 07:40:26 +0000 |
commit | b9ec68838b984d7ca196263a5f3a071057ee2a5d (patch) | |
tree | 021db4605a4336486092659234666ae94134f20f /net | |
parent | 87b3f9184583111b4592a40323c777a467b0c2a2 (diff) | |
download | chromium_src-b9ec68838b984d7ca196263a5f3a071057ee2a5d.zip chromium_src-b9ec68838b984d7ca196263a5f3a071057ee2a5d.tar.gz chromium_src-b9ec68838b984d7ca196263a5f3a071057ee2a5d.tar.bz2 |
Cleanup some test ugliness. Stop using a global.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7273065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 20 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 4 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 13 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 8 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.cc | 5 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.h | 5 | ||||
-rw-r--r-- | net/spdy/spdy_stream_unittest.cc | 18 | ||||
-rw-r--r-- | net/spdy/spdy_test_util.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_test_util.h | 22 |
9 files changed, 45 insertions, 52 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index ac86082..541a4f9b 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -124,7 +124,6 @@ class HttpNetworkTransactionTest : public PlatformTest { }; virtual void SetUp() { - disabled_spdy_session_domain_verification_ = false; NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); spdy::SpdyFramer::set_enable_compression_default(false); @@ -139,10 +138,6 @@ class HttpNetworkTransactionTest : public PlatformTest { PlatformTest::TearDown(); NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); MessageLoop::current()->RunAllPending(); - if (disabled_spdy_session_domain_verification_) { - SpdySession::SetDomainVerification( - spdy_session_domain_verification_old_value_); - } } void KeepAliveConnectionResendRequestTest(const MockRead& read_failure); @@ -211,15 +206,6 @@ class HttpNetworkTransactionTest : public PlatformTest { int expected_status); void ConnectStatusHelper(const MockRead& status); - - void DisableSpdySessionDomainVerification() { - disabled_spdy_session_domain_verification_ = true; - spdy_session_domain_verification_old_value_ = - SpdySession::SetDomainVerification(false); - } - - bool disabled_spdy_session_domain_verification_; - bool spdy_session_domain_verification_old_value_; }; // Fill |str| with a long header list that consumes >= |size| bytes. @@ -8719,7 +8705,6 @@ TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { HttpStreamFactory::set_use_alternate_protocols(true); HttpStreamFactory::set_next_protos(kExpectedNPNString); - DisableSpdySessionDomainVerification(); // Set up a special HttpNetworkSession with a MockCachingHostResolver. SessionDependencies session_deps; @@ -8734,6 +8719,8 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { session_deps.http_auth_handler_factory.get(); params.net_log = session_deps.net_log; scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); + SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); + pool_peer.DisableDomainAuthenticationVerification(); SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; @@ -8861,7 +8848,6 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPoolingWithHostCacheExpiration) { HttpStreamFactory::set_use_alternate_protocols(true); HttpStreamFactory::set_next_protos(kExpectedNPNString); - DisableSpdySessionDomainVerification(); // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. SessionDependencies session_deps; @@ -8876,6 +8862,8 @@ TEST_F(HttpNetworkTransactionTest, session_deps.http_auth_handler_factory.get(); params.net_log = session_deps.net_log; scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); + SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); + pool_peer.DisableDomainAuthenticationVerification(); SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 4c76419..fff263e 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -2432,7 +2432,7 @@ TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { "accept-encoding", "gzip,deflate", }; - const SpdyHeaderInfo kSynStartHeader = make_spdy_header(spdy::SYN_STREAM); + const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); const char* const kStandardGetHeaders[] = { "host", "www.google.com", @@ -2538,7 +2538,7 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { "accept-encoding", "gzip,deflate", }; - const SpdyHeaderInfo kSynStartHeader = make_spdy_header(spdy::SYN_STREAM); + const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); const char* const kStandardGetHeaders[] = { "host", "www.google.com", diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index d4aace1..36288c7 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -210,12 +210,10 @@ bool SpdySession::use_flow_control_ = false; // static size_t SpdySession::max_concurrent_stream_limit_ = 256; -// static -bool SpdySession::verify_domain_authentication_ = true; - SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, SpdySessionPool* spdy_session_pool, SpdySettingsStorage* spdy_settings, + bool verify_domain_authentication, NetLog* net_log) : ALLOW_THIS_IN_INITIALIZER_LIST( read_callback_(this, &SpdySession::OnReadComplete)), @@ -247,7 +245,8 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, stalled_streams_(0), initial_send_window_size_(spdy::kSpdyStreamInitialWindowSize), initial_recv_window_size_(spdy::kSpdyStreamInitialWindowSize), - net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)) { + net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), + verify_domain_authentication_(verify_domain_authentication) { DCHECK(HttpStreamFactory::spdy_enabled()); net_log_.BeginEvent( NetLog::TYPE_SPDY_SESSION, @@ -1527,10 +1526,4 @@ void SpdySession::InvokeUserStreamCreationCallback( callback->Run(result); } -bool SpdySession::SetDomainVerification(bool value) { - bool old_value = verify_domain_authentication_; - verify_domain_authentication_ = value; - return old_value; -} - } // namespace net diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 1fffc9f..5fd3520 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -57,6 +57,7 @@ class NET_API SpdySession : public base::RefCounted<SpdySession>, SpdySession(const HostPortProxyPair& host_port_proxy_pair, SpdySessionPool* spdy_session_pool, SpdySettingsStorage* spdy_settings, + bool verify_domain_authentication, NetLog* net_log); const HostPortPair& host_port_pair() const { @@ -204,7 +205,6 @@ class NET_API SpdySession : public base::RefCounted<SpdySession>, private: friend class base::RefCounted<SpdySession>; FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream); - friend class HttpNetworkTransactionTest; struct PendingCreateStream { PendingCreateStream(const GURL& url, RequestPriority priority, @@ -331,8 +331,6 @@ class NET_API SpdySession : public base::RefCounted<SpdySession>, size_t len); virtual void OnControl(const spdy::SpdyControlFrame* frame); - static bool SetDomainVerification(bool value); - // Callbacks for the Spdy session. CompletionCallbackImpl<SpdySession> read_callback_; CompletionCallbackImpl<SpdySession> write_callback_; @@ -435,10 +433,12 @@ class NET_API SpdySession : public base::RefCounted<SpdySession>, BoundNetLog net_log_; + // Outside of tests, this should always be true. + bool verify_domain_authentication_; + static bool use_ssl_; static bool use_flow_control_; static size_t max_concurrent_stream_limit_; - static bool verify_domain_authentication_; }; class NetLogSpdySynParameter : public NetLog::EventParameters { diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index adaeabf..957d764 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -42,7 +42,8 @@ bool SpdySessionPool::g_enable_ip_pooling = true; SpdySessionPool::SpdySessionPool(HostResolver* resolver, SSLConfigService* ssl_config_service) : ssl_config_service_(ssl_config_service), - resolver_(resolver) { + resolver_(resolver), + verify_domain_authentication_(true) { NetworkChangeNotifier::AddIPAddressObserver(this); if (ssl_config_service_) ssl_config_service_->AddObserver(this); @@ -110,6 +111,7 @@ scoped_refptr<SpdySession> SpdySessionPool::GetInternal( DCHECK(!only_use_existing_sessions); spdy_session = new SpdySession(host_port_proxy_pair, this, &spdy_settings_, + verify_domain_authentication_, net_log.net_log()); UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionGet", CREATED_NEW, @@ -135,6 +137,7 @@ net::Error SpdySessionPool::GetSpdySessionFromSocket( SPDY_SESSION_GET_MAX); // Create the SPDY session and add it to the pool. *spdy_session = new SpdySession(host_port_proxy_pair, this, &spdy_settings_, + verify_domain_authentication_, net_log.net_log()); SpdySessionList* list = GetSessionList(host_port_proxy_pair); if (!list) diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 4ef8c47..99319ee 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -181,7 +181,10 @@ class NET_API SpdySessionPool static bool g_enable_ip_pooling; const scoped_refptr<SSLConfigService> ssl_config_service_; - HostResolver* resolver_; + HostResolver* const resolver_; + + // Defaults to true. May be controlled via SpdySessionPoolPeer for tests. + bool verify_domain_authentication_; DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); }; diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc index c867371..55ee198 100644 --- a/net/spdy/spdy_stream_unittest.cc +++ b/net/spdy/spdy_stream_unittest.cc @@ -9,23 +9,9 @@ #include "net/spdy/spdy_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -namespace net { - // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc -class SpdySessionPoolPeer { - public: - explicit SpdySessionPoolPeer(SpdySessionPool* pool) - : pool_(pool) {} - - void RemoveSpdySession(const scoped_refptr<SpdySession>& session) { - pool_->Remove(session); - } - - private: - SpdySessionPool* const pool_; - - DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); -}; +// +namespace net { namespace { diff --git a/net/spdy/spdy_test_util.cc b/net/spdy/spdy_test_util.cc index a130bcd..d959d5d 100644 --- a/net/spdy/spdy_test_util.cc +++ b/net/spdy/spdy_test_util.cc @@ -969,7 +969,7 @@ SpdyURLRequestContext::SpdyURLRequestContext() SpdyURLRequestContext::~SpdyURLRequestContext() { } -const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type) { +const SpdyHeaderInfo MakeSpdyHeader(spdy::SpdyControlType type) { const SpdyHeaderInfo kHeader = { type, // Kind = Syn 1, // Stream ID diff --git a/net/spdy/spdy_test_util.h b/net/spdy/spdy_test_util.h index 8bba99e..5d0a27f 100644 --- a/net/spdy/spdy_test_util.h +++ b/net/spdy/spdy_test_util.h @@ -369,7 +369,27 @@ class SpdyURLRequestContext : public URLRequestContext { net::URLRequestContextStorage storage_; }; -const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type); +const SpdyHeaderInfo MakeSpdyHeader(spdy::SpdyControlType type); + +class SpdySessionPoolPeer { + public: + explicit SpdySessionPoolPeer(SpdySessionPool* pool) + : pool_(pool) {} + + void RemoveSpdySession(const scoped_refptr<SpdySession>& session) { + pool_->Remove(session); + } + + void DisableDomainAuthenticationVerification() { + pool_->verify_domain_authentication_ = false; + } + + private: + SpdySessionPool* const pool_; + + DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); +}; + } // namespace net #endif // NET_SPDY_SPDY_TEST_UTIL_H_ |