summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/base/run_all_unittests.cc6
-rw-r--r--net/http/http_network_transaction_unittest.cc20
-rw-r--r--net/socket/client_socket_pool_base.cc4
-rw-r--r--net/socket/client_socket_pool_base.h2
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc12
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc12
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc9
7 files changed, 30 insertions, 35 deletions
diff --git a/net/base/run_all_unittests.cc b/net/base/run_all_unittests.cc
index a60e501..bec0da2 100644
--- a/net/base/run_all_unittests.cc
+++ b/net/base/run_all_unittests.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,11 +6,15 @@
#include "base/metrics/histogram.h"
#include "base/nss_util.h"
#include "net/base/net_test_suite.h"
+#include "net/socket/client_socket_pool_base.h"
+
+using net::internal::ClientSocketPoolBaseHelper;
int main(int argc, char** argv) {
// Record histograms, so we can get histograms data in tests.
base::StatisticsRecorder recorder;
NetTestSuite test_suite(argc, argv);
+ ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
#if defined(OS_WIN)
// We want to be sure to init NSPR on the main thread.
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index f21a1a2..ce6fed2 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -6518,9 +6518,6 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) {
}
TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
- bool connect_backup_jobs_enabled =
- internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::set_next_protos(kExpectedNPNString);
SessionDependencies session_deps;
@@ -6609,14 +6606,9 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
HttpStreamFactory::set_next_protos("");
HttpStreamFactory::set_use_alternate_protocols(false);
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- connect_backup_jobs_enabled);
}
TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
- bool connect_backup_jobs_enabled =
- internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::set_next_protos(kExpectedNPNString);
SessionDependencies session_deps;
@@ -6732,14 +6724,9 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
HttpStreamFactory::set_next_protos("");
HttpStreamFactory::set_use_alternate_protocols(false);
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- connect_backup_jobs_enabled);
}
TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
- bool connect_backup_jobs_enabled =
- internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::set_next_protos(kExpectedNPNString);
SessionDependencies session_deps;
@@ -6813,8 +6800,6 @@ TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
HttpStreamFactory::set_next_protos("");
HttpStreamFactory::set_use_alternate_protocols(false);
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- connect_backup_jobs_enabled);
}
class CapturingProxyResolver : public ProxyResolver {
@@ -6856,9 +6841,6 @@ class CapturingProxyResolver : public ProxyResolver {
};
TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) {
- bool connect_backup_jobs_enabled =
- internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::set_next_protos(kExpectedNPNString);
@@ -6970,8 +6952,6 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) {
HttpStreamFactory::set_next_protos("");
HttpStreamFactory::set_use_alternate_protocols(false);
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- connect_backup_jobs_enabled);
}
TEST_F(HttpNetworkTransactionTest,
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 3614d41..e8f53af 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -644,8 +644,10 @@ bool ClientSocketPoolBaseHelper::connect_backup_jobs_enabled() {
}
// static
-void ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(bool enabled) {
+bool ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(bool enabled) {
+ bool old_value = g_connect_backup_jobs_enabled;
g_connect_backup_jobs_enabled = enabled;
+ return old_value;
}
void ClientSocketPoolBaseHelper::EnableConnectBackupJobs() {
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 467831b..fe18ff2 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -287,7 +287,7 @@ class ClientSocketPoolBaseHelper
}
static bool connect_backup_jobs_enabled();
- static void set_connect_backup_jobs_enabled(bool enabled);
+ static bool set_connect_backup_jobs_enabled(bool enabled);
void EnableConnectBackupJobs();
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 209d7a7..8fc42c3 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -526,9 +526,16 @@ class ClientSocketPoolBaseTest : public testing::Test {
protected:
ClientSocketPoolBaseTest()
: params_(new TestSocketParams()),
- histograms_("ClientSocketPoolTest") {}
+ histograms_("ClientSocketPoolTest") {
+ connect_backup_jobs_enabled_ =
+ internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
+ internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true);
+ }
- virtual ~ClientSocketPoolBaseTest() {}
+ virtual ~ClientSocketPoolBaseTest() {
+ internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
+ connect_backup_jobs_enabled_);
+ }
void CreatePool(int max_sockets, int max_sockets_per_group) {
CreatePoolWithIdleTimeouts(
@@ -577,6 +584,7 @@ class ClientSocketPoolBaseTest : public testing::Test {
ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); }
size_t completion_count() const { return test_base_.completion_count(); }
+ bool connect_backup_jobs_enabled_;
MockClientSocketFactory client_socket_factory_;
TestConnectJobFactory* connect_job_factory_;
scoped_refptr<TestSocketParams> params_;
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index 37dae93..889cc5b 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -21,6 +21,8 @@
namespace net {
+using internal::ClientSocketPoolBaseHelper;
+
namespace {
const int kMaxSockets = 32;
@@ -289,7 +291,9 @@ class MockClientSocketFactory : public ClientSocketFactory {
class TransportClientSocketPoolTest : public testing::Test {
protected:
TransportClientSocketPoolTest()
- : params_(
+ : connect_backup_jobs_enabled_(
+ ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)),
+ params_(
new TransportSocketParams(HostPortPair("www.google.com", 80),
kDefaultPriority, GURL(), false, false)),
low_params_(
@@ -305,6 +309,11 @@ class TransportClientSocketPoolTest : public testing::Test {
NULL) {
}
+ ~TransportClientSocketPoolTest() {
+ internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
+ connect_backup_jobs_enabled_);
+ }
+
int StartRequest(const std::string& group_name, RequestPriority priority) {
scoped_refptr<TransportSocketParams> params(new TransportSocketParams(
HostPortPair("www.google.com", 80), MEDIUM, GURL(), false, false));
@@ -327,6 +336,7 @@ class TransportClientSocketPoolTest : public testing::Test {
ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); }
size_t completion_count() const { return test_base_.completion_count(); }
+ bool connect_backup_jobs_enabled_;
scoped_refptr<TransportSocketParams> params_;
scoped_refptr<TransportSocketParams> low_params_;
scoped_ptr<ClientSocketPoolHistograms> histograms_;
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index f0c26f3..b3196b4 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -43,18 +43,11 @@ class SpdyNetworkTransactionTest
google_get_request_initialized_ = false;
google_post_request_initialized_ = false;
google_chunked_post_request_initialized_ = false;
-
- backup_jobs_prev_value_ =
- internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- false);
}
virtual void TearDown() {
// Empty the current queue.
MessageLoop::current()->RunAllPending();
- internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
- backup_jobs_prev_value_);
}
struct TransactionHelperResult {
@@ -511,8 +504,6 @@ class SpdyNetworkTransactionTest
HttpRequestInfo google_post_request_;
HttpRequestInfo google_chunked_post_request_;
HttpRequestInfo google_get_push_request_;
-
- bool backup_jobs_prev_value_;
};
//-----------------------------------------------------------------------------