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

Unified Diff: net/http/http_pipelined_host_pool_unittest.cc

Issue 9433015: Add a force pipelining option to load flags. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix build on other platforms Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_pipelined_host_pool_unittest.cc
diff --git a/net/http/http_pipelined_host_pool_unittest.cc b/net/http/http_pipelined_host_pool_unittest.cc
index beb580749da83ea92899e834a03bb8f07a4ee359..8d345ed1a84362cc84be0610553b4e13bbf426f3 100644
--- a/net/http/http_pipelined_host_pool_unittest.cc
+++ b/net/http/http_pipelined_host_pool_unittest.cc
@@ -30,21 +30,22 @@ HttpPipelinedStream* kDummyStream =
class MockPoolDelegate : public HttpPipelinedHostPool::Delegate {
public:
MOCK_METHOD1(OnHttpPipelinedHostHasAdditionalCapacity,
- void(const HostPortPair& origin));
+ void(HttpPipelinedHost* host));
};
class MockHostFactory : public HttpPipelinedHost::Factory {
public:
MOCK_METHOD4(CreateNewHost, HttpPipelinedHost*(
- HttpPipelinedHost::Delegate* delegate, const HostPortPair& origin,
+ HttpPipelinedHost::Delegate* delegate,
+ const HttpPipelinedHost::Key& key,
HttpPipelinedConnection::Factory* factory,
HttpPipelinedHostCapability capability));
};
class MockHost : public HttpPipelinedHost {
public:
- MockHost(const HostPortPair& origin)
- : origin_(origin) {
+ MockHost(const Key& key)
+ : key_(key) {
}
MOCK_METHOD6(CreateStreamOnNewPipeline, HttpPipelinedStream*(
@@ -58,18 +59,18 @@ class MockHost : public HttpPipelinedHost {
MOCK_CONST_METHOD0(IsExistingPipelineAvailable, bool());
MOCK_CONST_METHOD0(PipelineInfoToValue, base::Value*());
- virtual const HostPortPair& origin() const OVERRIDE { return origin_; }
+ virtual const Key& key() const OVERRIDE { return key_; }
private:
- HostPortPair origin_;
+ Key key_;
};
class HttpPipelinedHostPoolTest : public testing::Test {
public:
HttpPipelinedHostPoolTest()
- : origin_("host", 123),
+ : key_(HostPortPair("host", 123), false),
factory_(new MockHostFactory), // Owned by pool_.
- host_(new MockHost(origin_)), // Owned by pool_.
+ host_(new MockHost(key_)), // Owned by pool_.
http_server_properties_(new HttpServerPropertiesImpl),
pool_(new HttpPipelinedHostPool(&delegate_, factory_,
http_server_properties_.get())),
@@ -87,13 +88,13 @@ class HttpPipelinedHostPoolTest : public testing::Test {
.Times(1)
.WillOnce(Return(kDummyStream));
EXPECT_EQ(kDummyStream,
- pool_->CreateStreamOnNewPipeline(origin_, kDummyConnection,
+ pool_->CreateStreamOnNewPipeline(key_, kDummyConnection,
ssl_config_, proxy_info_,
net_log_, was_npn_negotiated_,
protocol_negotiated_));
}
- HostPortPair origin_;
+ HttpPipelinedHost::Key key_;
MockPoolDelegate delegate_;
MockHostFactory* factory_;
MockHost* host_;
@@ -108,8 +109,8 @@ class HttpPipelinedHostPoolTest : public testing::Test {
};
TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) {
- EXPECT_TRUE(pool_->IsHostEligibleForPipelining(origin_));
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_TRUE(pool_->IsKeyEligibleForPipelining(key_));
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
@@ -119,7 +120,7 @@ TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) {
}
TEST_F(HttpPipelinedHostPoolTest, RemembersIncapable) {
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
@@ -127,19 +128,19 @@ TEST_F(HttpPipelinedHostPoolTest, RemembersIncapable) {
CreateDummyStream();
pool_->OnHostDeterminedCapability(host_, PIPELINE_INCAPABLE);
pool_->OnHostIdle(host_);
- EXPECT_FALSE(pool_->IsHostEligibleForPipelining(origin_));
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_FALSE(pool_->IsKeyEligibleForPipelining(key_));
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_INCAPABLE))
.Times(0);
EXPECT_EQ(NULL,
- pool_->CreateStreamOnNewPipeline(origin_, kDummyConnection,
+ pool_->CreateStreamOnNewPipeline(key_, kDummyConnection,
ssl_config_, proxy_info_, net_log_,
was_npn_negotiated_,
protocol_negotiated_));
}
TEST_F(HttpPipelinedHostPoolTest, RemembersCapable) {
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
@@ -147,10 +148,10 @@ TEST_F(HttpPipelinedHostPoolTest, RemembersCapable) {
CreateDummyStream();
pool_->OnHostDeterminedCapability(host_, PIPELINE_CAPABLE);
pool_->OnHostIdle(host_);
- EXPECT_TRUE(pool_->IsHostEligibleForPipelining(origin_));
+ EXPECT_TRUE(pool_->IsKeyEligibleForPipelining(key_));
- host_ = new MockHost(origin_);
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ host_ = new MockHost(key_);
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_CAPABLE))
.Times(1)
.WillOnce(Return(host_));
@@ -159,7 +160,7 @@ TEST_F(HttpPipelinedHostPoolTest, RemembersCapable) {
}
TEST_F(HttpPipelinedHostPoolTest, IncapableIsSticky) {
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
@@ -169,21 +170,21 @@ TEST_F(HttpPipelinedHostPoolTest, IncapableIsSticky) {
pool_->OnHostDeterminedCapability(host_, PIPELINE_INCAPABLE);
pool_->OnHostDeterminedCapability(host_, PIPELINE_CAPABLE);
pool_->OnHostIdle(host_);
- EXPECT_FALSE(pool_->IsHostEligibleForPipelining(origin_));
+ EXPECT_FALSE(pool_->IsKeyEligibleForPipelining(key_));
}
TEST_F(HttpPipelinedHostPoolTest, RemainsUnknownWithoutFeedback) {
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
CreateDummyStream();
pool_->OnHostIdle(host_);
- EXPECT_TRUE(pool_->IsHostEligibleForPipelining(origin_));
+ EXPECT_TRUE(pool_->IsKeyEligibleForPipelining(key_));
- host_ = new MockHost(origin_);
- EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(origin_), _,
+ host_ = new MockHost(key_);
+ EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
PIPELINE_UNKNOWN))
.Times(1)
.WillOnce(Return(host_));
@@ -194,10 +195,12 @@ TEST_F(HttpPipelinedHostPoolTest, RemainsUnknownWithoutFeedback) {
TEST_F(HttpPipelinedHostPoolTest, PopulatesServerProperties) {
EXPECT_EQ(PIPELINE_UNKNOWN,
- http_server_properties_->GetPipelineCapability(host_->origin()));
+ http_server_properties_->GetPipelineCapability(
+ host_->key().origin()));
pool_->OnHostDeterminedCapability(host_, PIPELINE_CAPABLE);
EXPECT_EQ(PIPELINE_CAPABLE,
- http_server_properties_->GetPipelineCapability(host_->origin()));
+ http_server_properties_->GetPipelineCapability(
+ host_->key().origin()));
delete host_; // Must manually delete, because it's never added to |pool_|.
}

Powered by Google App Engine
This is Rietveld 408576698