OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/http_pipelined_host_impl.h" | 5 #include "net/http/http_pipelined_host_impl.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/base/ssl_config_service.h" | 8 #include "net/base/ssl_config_service.h" |
9 #include "net/http/http_pipelined_connection.h" | 9 #include "net/http/http_pipelined_connection.h" |
10 #include "net/proxy/proxy_info.h" | 10 #include "net/proxy/proxy_info.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 host_.reset(new HttpPipelinedHostImpl( | 96 host_.reset(new HttpPipelinedHostImpl( |
97 &delegate_, origin_, factory_, capability)); | 97 &delegate_, origin_, factory_, capability)); |
98 } | 98 } |
99 | 99 |
100 MockPipeline* AddTestPipeline(int depth, bool usable, bool active) { | 100 MockPipeline* AddTestPipeline(int depth, bool usable, bool active) { |
101 MockPipeline* pipeline = new MockPipeline(depth, usable, active); | 101 MockPipeline* pipeline = new MockPipeline(depth, usable, active); |
102 EXPECT_CALL(*factory_, CreateNewPipeline(kDummyConnection, host_.get(), | 102 EXPECT_CALL(*factory_, CreateNewPipeline(kDummyConnection, host_.get(), |
103 MatchesOrigin(origin_), | 103 MatchesOrigin(origin_), |
104 Ref(ssl_config_), Ref(proxy_info_), | 104 Ref(ssl_config_), Ref(proxy_info_), |
105 Ref(net_log_), true, | 105 Ref(net_log_), true, |
106 SSLClientSocket::kProtoSPDY2)) | 106 SSLClientSocket::kProtoSPDY21)) |
107 .Times(1) | 107 .Times(1) |
108 .WillOnce(Return(pipeline)); | 108 .WillOnce(Return(pipeline)); |
109 EXPECT_CALL(*pipeline, CreateNewStream()) | 109 EXPECT_CALL(*pipeline, CreateNewStream()) |
110 .Times(1) | 110 .Times(1) |
111 .WillOnce(Return(kDummyStream)); | 111 .WillOnce(Return(kDummyStream)); |
112 EXPECT_EQ(kDummyStream, host_->CreateStreamOnNewPipeline( | 112 EXPECT_EQ(kDummyStream, host_->CreateStreamOnNewPipeline( |
113 kDummyConnection, ssl_config_, proxy_info_, net_log_, true, | 113 kDummyConnection, ssl_config_, proxy_info_, net_log_, true, |
114 SSLClientSocket::kProtoSPDY2)); | 114 SSLClientSocket::kProtoSPDY21)); |
115 return pipeline; | 115 return pipeline; |
116 } | 116 } |
117 | 117 |
118 void ClearTestPipeline(MockPipeline* pipeline) { | 118 void ClearTestPipeline(MockPipeline* pipeline) { |
119 pipeline->SetState(0, true, true); | 119 pipeline->SetState(0, true, true); |
120 host_->OnPipelineHasCapacity(pipeline); | 120 host_->OnPipelineHasCapacity(pipeline); |
121 } | 121 } |
122 | 122 |
123 NiceMock<MockHostDelegate> delegate_; | 123 NiceMock<MockHostDelegate> delegate_; |
124 HostPortPair origin_; | 124 HostPortPair origin_; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 .Times(0); | 256 .Times(0); |
257 EXPECT_CALL(delegate_, | 257 EXPECT_CALL(delegate_, |
258 OnHostDeterminedCapability(host_.get(), PIPELINE_INCAPABLE)) | 258 OnHostDeterminedCapability(host_.get(), PIPELINE_INCAPABLE)) |
259 .Times(1); | 259 .Times(1); |
260 host_->OnPipelineFeedback(pipeline, | 260 host_->OnPipelineFeedback(pipeline, |
261 HttpPipelinedConnection::OLD_HTTP_VERSION); | 261 HttpPipelinedConnection::OLD_HTTP_VERSION); |
262 | 262 |
263 ClearTestPipeline(pipeline); | 263 ClearTestPipeline(pipeline); |
264 EXPECT_EQ(NULL, host_->CreateStreamOnNewPipeline( | 264 EXPECT_EQ(NULL, host_->CreateStreamOnNewPipeline( |
265 kDummyConnection, ssl_config_, proxy_info_, net_log_, true, | 265 kDummyConnection, ssl_config_, proxy_info_, net_log_, true, |
266 SSLClientSocket::kProtoSPDY2)); | 266 SSLClientSocket::kProtoSPDY21)); |
267 } | 267 } |
268 | 268 |
269 TEST_F(HttpPipelinedHostImplTest, ShutsDownOnAuthenticationRequired) { | 269 TEST_F(HttpPipelinedHostImplTest, ShutsDownOnAuthenticationRequired) { |
270 SetCapability(PIPELINE_UNKNOWN); | 270 SetCapability(PIPELINE_UNKNOWN); |
271 MockPipeline* pipeline = AddTestPipeline(1, true, true); | 271 MockPipeline* pipeline = AddTestPipeline(1, true, true); |
272 | 272 |
273 EXPECT_EQ(NULL, host_->CreateStreamOnExistingPipeline()); | 273 EXPECT_EQ(NULL, host_->CreateStreamOnExistingPipeline()); |
274 EXPECT_CALL(delegate_, OnHostHasAdditionalCapacity(host_.get())) | 274 EXPECT_CALL(delegate_, OnHostHasAdditionalCapacity(host_.get())) |
275 .Times(0); | 275 .Times(0); |
276 EXPECT_CALL(delegate_, | 276 EXPECT_CALL(delegate_, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 .Times(1); | 354 .Times(1); |
355 host_->OnPipelineFeedback(pipeline, | 355 host_->OnPipelineFeedback(pipeline, |
356 HttpPipelinedConnection::PIPELINE_SOCKET_ERROR); | 356 HttpPipelinedConnection::PIPELINE_SOCKET_ERROR); |
357 | 357 |
358 ClearTestPipeline(pipeline); | 358 ClearTestPipeline(pipeline); |
359 } | 359 } |
360 | 360 |
361 } // anonymous namespace | 361 } // anonymous namespace |
362 | 362 |
363 } // namespace net | 363 } // namespace net |
OLD | NEW |