| Index: net/quic/quic_network_transaction_unittest.cc
 | 
| diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
 | 
| index 19d85f7ec3117dc39bd5a82d5ec751f22765147f..cb6756915632434cf683e540982f5c07b083fd05 100644
 | 
| --- a/net/quic/quic_network_transaction_unittest.cc
 | 
| +++ b/net/quic/quic_network_transaction_unittest.cc
 | 
| @@ -131,8 +131,6 @@ class QuicNetworkTransactionTest
 | 
|      PlatformTest::TearDown();
 | 
|      NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
 | 
|      base::MessageLoop::current()->RunUntilIdle();
 | 
| -    HttpStreamFactory::set_use_alternate_protocols(false);
 | 
| -    HttpStreamFactory::SetNextProtos(std::vector<NextProto>());
 | 
|    }
 | 
|  
 | 
|    scoped_ptr<QuicEncryptedPacket> ConstructConnectionClosePacket(
 | 
| @@ -188,10 +186,16 @@ class QuicNetworkTransactionTest
 | 
|    }
 | 
|  
 | 
|    void CreateSession() {
 | 
| -    CreateSessionWithFactory(&socket_factory_);
 | 
| +    CreateSessionWithFactory(&socket_factory_, false);
 | 
|    }
 | 
|  
 | 
| -  void CreateSessionWithFactory(ClientSocketFactory* socket_factory) {
 | 
| +  void CreateSessionWithNextProtos() {
 | 
| +    CreateSessionWithFactory(&socket_factory_, true);
 | 
| +  }
 | 
| +
 | 
| +  // If |use_next_protos| is true, enables SPDY and QUIC.
 | 
| +  void CreateSessionWithFactory(ClientSocketFactory* socket_factory,
 | 
| +                                bool use_next_protos) {
 | 
|      params_.enable_quic = true;
 | 
|      params_.quic_clock = clock_;
 | 
|      params_.quic_random = &random_generator_;
 | 
| @@ -206,6 +210,11 @@ class QuicNetworkTransactionTest
 | 
|      params_.http_server_properties = http_server_properties.GetWeakPtr();
 | 
|      params_.quic_supported_versions = SupportedVersions(GetParam());
 | 
|  
 | 
| +    if (use_next_protos) {
 | 
| +      params_.use_alternate_protocols = true;
 | 
| +      params_.next_protos = NextProtosSpdy3();
 | 
| +    }
 | 
| +
 | 
|      session_ = new HttpNetworkSession(params_);
 | 
|      session_->quic_stream_factory()->set_require_confirmation(false);
 | 
|    }
 | 
| @@ -445,8 +454,6 @@ TEST_P(QuicNetworkTransactionTest, DoNotForceQuicForHttps) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    MockRead http_reads[] = {
 | 
|      MockRead("HTTP/1.1 200 OK\r\n"),
 | 
|      MockRead(kQuicAlternateProtocolHttpHeader),
 | 
| @@ -477,7 +484,7 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
 | 
|    // the alternate-protocol job will "win".
 | 
|    AddHangingNonAlternateProtocolSocketData();
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|  
 | 
|    SendRequestAndExpectHttpResponse("hello world");
 | 
|    SendRequestAndExpectQuicResponse("hello!");
 | 
| @@ -487,7 +494,6 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuicForHttps) {
 | 
|    params_.origin_to_force_quic_on =
 | 
|        HostPortPair::FromString("www.google.com:443");
 | 
|    params_.enable_quic_https = true;
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
|  
 | 
|    MockRead http_reads[] = {
 | 
|      MockRead("HTTP/1.1 200 OK\r\n"),
 | 
| @@ -519,14 +525,13 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuicForHttps) {
 | 
|    // the alternate-protocol job will "win".
 | 
|    AddHangingNonAlternateProtocolSocketData();
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|  
 | 
|    // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo().
 | 
|    SendRequestAndExpectHttpResponse("hello world");
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
|    crypto_client_stream_factory_.set_handshake_mode(
 | 
|        MockCryptoClientStream::COLD_START);
 | 
|  
 | 
| @@ -565,7 +570,7 @@ TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
 | 
|                                       http_writes, arraysize(http_writes));
 | 
|    socket_factory.AddSocketDataProvider(&http_data2);
 | 
|  
 | 
| -  CreateSessionWithFactory(&socket_factory);
 | 
| +  CreateSessionWithFactory(&socket_factory, true);
 | 
|  
 | 
|    // Run the first request.
 | 
|    http_data.StopAfter(arraysize(http_reads) + arraysize(http_writes));
 | 
| @@ -585,8 +590,6 @@ TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    MockQuicData mock_quic_data;
 | 
|    mock_quic_data.AddWrite(
 | 
|        ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
 | 
| @@ -605,14 +608,12 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) {
 | 
|    // the alternate-protocol job will "win".
 | 
|    AddHangingNonAlternateProtocolSocketData();
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|    SendRequestAndExpectQuicResponse("hello!");
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    MockQuicData mock_quic_data;
 | 
|    mock_quic_data.AddWrite(
 | 
|        ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
 | 
| @@ -640,7 +641,7 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
 | 
|                           NULL,
 | 
|                           net_log_.bound());
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|    SendRequestAndExpectQuicResponse("hello!");
 | 
|  }
 | 
| @@ -648,7 +649,6 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
 | 
|  TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) {
 | 
|    proxy_service_.reset(
 | 
|        ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
|  
 | 
|    // Since we are using a proxy, the QUIC job will not succeed.
 | 
|    MockWrite http_writes[] = {
 | 
| @@ -682,14 +682,12 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) {
 | 
|                           NULL,
 | 
|                           net_log_.bound());
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|    SendRequestAndExpectHttpResponse("hello world");
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    MockQuicData mock_quic_data;
 | 
|    mock_quic_data.AddWrite(
 | 
|        ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
 | 
| @@ -719,7 +717,7 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
 | 
|    host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address,
 | 
|                           CompletionCallback(), NULL, net_log_.bound());
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    session_->quic_stream_factory()->set_require_confirmation(true);
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|  
 | 
| @@ -735,8 +733,6 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    // Alternate-protocol job
 | 
|    scoped_ptr<QuicEncryptedPacket> close(ConstructConnectionClosePacket(1));
 | 
|    MockRead quic_reads[] = {
 | 
| @@ -759,15 +755,13 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) {
 | 
|                                       NULL, 0);
 | 
|    socket_factory_.AddSocketDataProvider(&http_data);
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
 | 
|    SendRequestAndExpectHttpResponse("hello from http");
 | 
|    ExpectBrokenAlternateProtocolMapping();
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    // Alternate-protocol job
 | 
|    MockRead quic_reads[] = {
 | 
|      MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED),
 | 
| @@ -788,7 +782,7 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
 | 
|                                       NULL, 0);
 | 
|    socket_factory_.AddSocketDataProvider(&http_data);
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|  
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
 | 
|    SendRequestAndExpectHttpResponse("hello from http");
 | 
| @@ -796,8 +790,6 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, NoBrokenAlternateProtocolIfTcpFails) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    // Alternate-protocol job will fail when the session attempts to read.
 | 
|    MockRead quic_reads[] = {
 | 
|      MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED),
 | 
| @@ -816,7 +808,7 @@ TEST_P(QuicNetworkTransactionTest, NoBrokenAlternateProtocolIfTcpFails) {
 | 
|    http_data.set_connect_data(MockConnect(ASYNC, ERR_SOCKET_NOT_CONNECTED));
 | 
|    socket_factory_.AddSocketDataProvider(&http_data);
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|  
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
 | 
|    scoped_ptr<HttpNetworkTransaction> trans(
 | 
| @@ -829,8 +821,6 @@ TEST_P(QuicNetworkTransactionTest, NoBrokenAlternateProtocolIfTcpFails) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    // Alternate-protocol job
 | 
|    MockRead quic_reads[] = {
 | 
|      MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED),
 | 
| @@ -853,7 +843,7 @@ TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
 | 
|                                       NULL, 0);
 | 
|    socket_factory_.AddSocketDataProvider(&http_data);
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|  
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|  
 | 
| @@ -866,8 +856,6 @@ TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolOnConnectFailure) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    // Alternate-protocol job will fail before creating a QUIC session.
 | 
|    StaticSocketDataProvider quic_data(NULL, 0, NULL, 0);
 | 
|    quic_data.set_connect_data(MockConnect(SYNCHRONOUS,
 | 
| @@ -886,7 +874,7 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolOnConnectFailure) {
 | 
|                                       NULL, 0);
 | 
|    socket_factory_.AddSocketDataProvider(&http_data);
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
 | 
|    SendRequestAndExpectHttpResponse("hello from http");
 | 
|  
 | 
| @@ -894,8 +882,6 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolOnConnectFailure) {
 | 
|  }
 | 
|  
 | 
|  TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
 | 
| -  HttpStreamFactory::EnableNpnSpdy3();  // Enables QUIC too.
 | 
| -
 | 
|    MockQuicData mock_quic_data;
 | 
|    mock_quic_data.AddRead(ConstructConnectionClosePacket(1));
 | 
|    mock_quic_data.AddWrite(
 | 
| @@ -931,7 +917,7 @@ TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
 | 
|                           NULL,
 | 
|                           net_log_.bound());
 | 
|  
 | 
| -  CreateSession();
 | 
| +  CreateSessionWithNextProtos();
 | 
|    AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
 | 
|    SendRequestAndExpectHttpResponse("hello world");
 | 
|  }
 | 
| 
 |