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

Side by Side Diff: net/http/http_pipelined_host_pool_unittest.cc

Issue 9959033: Move NextProto enum to a new file net/socket/next_proto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address wtc's comments Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_pipelined_host_pool.cc ('k') | net/http/http_pipelined_host_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_pool.h" 5 #include "net/http/http_pipelined_host_pool.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "net/base/ssl_config_service.h" 9 #include "net/base/ssl_config_service.h"
10 #include "net/http/http_pipelined_host.h" 10 #include "net/http/http_pipelined_host.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 MockHost(const Key& key) 49 MockHost(const Key& key)
50 : key_(key) { 50 : key_(key) {
51 } 51 }
52 52
53 MOCK_METHOD6(CreateStreamOnNewPipeline, HttpPipelinedStream*( 53 MOCK_METHOD6(CreateStreamOnNewPipeline, HttpPipelinedStream*(
54 ClientSocketHandle* connection, 54 ClientSocketHandle* connection,
55 const SSLConfig& used_ssl_config, 55 const SSLConfig& used_ssl_config,
56 const ProxyInfo& used_proxy_info, 56 const ProxyInfo& used_proxy_info,
57 const BoundNetLog& net_log, 57 const BoundNetLog& net_log,
58 bool was_npn_negotiated, 58 bool was_npn_negotiated,
59 SSLClientSocket::NextProto protocol_negotiated)); 59 NextProto protocol_negotiated));
60 MOCK_METHOD0(CreateStreamOnExistingPipeline, HttpPipelinedStream*()); 60 MOCK_METHOD0(CreateStreamOnExistingPipeline, HttpPipelinedStream*());
61 MOCK_CONST_METHOD0(IsExistingPipelineAvailable, bool()); 61 MOCK_CONST_METHOD0(IsExistingPipelineAvailable, bool());
62 MOCK_CONST_METHOD0(PipelineInfoToValue, base::Value*()); 62 MOCK_CONST_METHOD0(PipelineInfoToValue, base::Value*());
63 63
64 virtual const Key& GetKey() const OVERRIDE { return key_; } 64 virtual const Key& GetKey() const OVERRIDE { return key_; }
65 65
66 private: 66 private:
67 Key key_; 67 Key key_;
68 }; 68 };
69 69
70 class HttpPipelinedHostPoolTest : public testing::Test { 70 class HttpPipelinedHostPoolTest : public testing::Test {
71 public: 71 public:
72 HttpPipelinedHostPoolTest() 72 HttpPipelinedHostPoolTest()
73 : key_(HostPortPair("host", 123)), 73 : key_(HostPortPair("host", 123)),
74 factory_(new MockHostFactory), // Owned by pool_. 74 factory_(new MockHostFactory), // Owned by pool_.
75 host_(new MockHost(key_)), // Owned by pool_. 75 host_(new MockHost(key_)), // Owned by pool_.
76 http_server_properties_(new HttpServerPropertiesImpl), 76 http_server_properties_(new HttpServerPropertiesImpl),
77 pool_(new HttpPipelinedHostPool(&delegate_, factory_, 77 pool_(new HttpPipelinedHostPool(&delegate_, factory_,
78 http_server_properties_.get(), false)), 78 http_server_properties_.get(), false)),
79 was_npn_negotiated_(false), 79 was_npn_negotiated_(false),
80 protocol_negotiated_(SSLClientSocket::kProtoUnknown) { 80 protocol_negotiated_(kProtoUnknown) {
81 } 81 }
82 82
83 void CreateDummyStream(const HttpPipelinedHost::Key& key, 83 void CreateDummyStream(const HttpPipelinedHost::Key& key,
84 ClientSocketHandle* connection, 84 ClientSocketHandle* connection,
85 HttpPipelinedStream* stream, 85 HttpPipelinedStream* stream,
86 MockHost* host) { 86 MockHost* host) {
87 EXPECT_CALL(*host, CreateStreamOnNewPipeline(connection, 87 EXPECT_CALL(*host, CreateStreamOnNewPipeline(connection,
88 Ref(ssl_config_), 88 Ref(ssl_config_),
89 Ref(proxy_info_), 89 Ref(proxy_info_),
90 Ref(net_log_), 90 Ref(net_log_),
(...skipping 26 matching lines...) Expand all
117 MockPoolDelegate delegate_; 117 MockPoolDelegate delegate_;
118 MockHostFactory* factory_; 118 MockHostFactory* factory_;
119 MockHost* host_; 119 MockHost* host_;
120 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_; 120 scoped_ptr<HttpServerPropertiesImpl> http_server_properties_;
121 scoped_ptr<HttpPipelinedHostPool> pool_; 121 scoped_ptr<HttpPipelinedHostPool> pool_;
122 122
123 const SSLConfig ssl_config_; 123 const SSLConfig ssl_config_;
124 const ProxyInfo proxy_info_; 124 const ProxyInfo proxy_info_;
125 const BoundNetLog net_log_; 125 const BoundNetLog net_log_;
126 bool was_npn_negotiated_; 126 bool was_npn_negotiated_;
127 SSLClientSocket::NextProto protocol_negotiated_; 127 NextProto protocol_negotiated_;
128 }; 128 };
129 129
130 TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) { 130 TEST_F(HttpPipelinedHostPoolTest, DefaultUnknown) {
131 EXPECT_TRUE(pool_->IsKeyEligibleForPipelining(key_)); 131 EXPECT_TRUE(pool_->IsKeyEligibleForPipelining(key_));
132 EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _, 132 EXPECT_CALL(*factory_, CreateNewHost(pool_.get(), Ref(key_), _,
133 PIPELINE_UNKNOWN, false)) 133 PIPELINE_UNKNOWN, false))
134 .Times(1) 134 .Times(1)
135 .WillOnce(Return(host_)); 135 .WillOnce(Return(host_));
136 136
137 CreateDummyStream(key_, kDummyConnection, kDummyStream, host_); 137 CreateDummyStream(key_, kDummyConnection, kDummyStream, host_);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 pool_->OnHostIdle(host1); 252 pool_->OnHostIdle(host1);
253 pool_->OnHostIdle(host2); 253 pool_->OnHostIdle(host2);
254 pool_->OnHostIdle(host3); 254 pool_->OnHostIdle(host3);
255 255
256 delete host_; // Must manually delete, because it's never added to |pool_|. 256 delete host_; // Must manually delete, because it's never added to |pool_|.
257 } 257 }
258 258
259 } // anonymous namespace 259 } // anonymous namespace
260 260
261 } // namespace net 261 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_pool.cc ('k') | net/http/http_pipelined_host_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698