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_connection_impl.h" | 5 #include "net/http/http_pipelined_connection_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "net/base/request_priority.h" | 14 #include "net/base/request_priority.h" |
14 #include "net/http/http_pipelined_stream.h" | 15 #include "net/http/http_pipelined_stream.h" |
15 #include "net/socket/client_socket_handle.h" | 16 #include "net/socket/client_socket_handle.h" |
16 #include "net/socket/client_socket_pool_histograms.h" | 17 #include "net/socket/client_socket_pool_histograms.h" |
17 #include "net/socket/socket_test_util.h" | 18 #include "net/socket/socket_test_util.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 pool_(1, 1, &histograms_, &factory_), | 74 pool_(1, 1, &histograms_, &factory_), |
74 origin_("host", 123) { | 75 origin_("host", 123) { |
75 } | 76 } |
76 | 77 |
77 void TearDown() { | 78 void TearDown() { |
78 MessageLoop::current()->RunAllPending(); | 79 MessageLoop::current()->RunAllPending(); |
79 } | 80 } |
80 | 81 |
81 void Initialize(MockRead* reads, size_t reads_count, | 82 void Initialize(MockRead* reads, size_t reads_count, |
82 MockWrite* writes, size_t writes_count) { | 83 MockWrite* writes, size_t writes_count) { |
83 data_ = new DeterministicSocketData(reads, reads_count, | 84 data_.reset(new DeterministicSocketData(reads, reads_count, |
84 writes, writes_count); | 85 writes, writes_count)); |
85 data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); | 86 data_->set_connect_data(MockConnect(SYNCHRONOUS, OK)); |
86 if (reads_count || writes_count) { | 87 if (reads_count || writes_count) { |
87 data_->StopAfter(reads_count + writes_count); | 88 data_->StopAfter(reads_count + writes_count); |
88 } | 89 } |
89 factory_.AddSocketDataProvider(data_.get()); | 90 factory_.AddSocketDataProvider(data_.get()); |
90 scoped_refptr<DummySocketParams> params; | 91 scoped_refptr<DummySocketParams> params; |
91 ClientSocketHandle* connection = new ClientSocketHandle; | 92 ClientSocketHandle* connection = new ClientSocketHandle; |
92 connection->Init("a", params, MEDIUM, CompletionCallback(), &pool_, | 93 connection->Init("a", params, MEDIUM, CompletionCallback(), &pool_, |
93 BoundNetLog()); | 94 BoundNetLog()); |
94 pipeline_.reset(new HttpPipelinedConnectionImpl( | 95 pipeline_.reset(new HttpPipelinedConnectionImpl( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 callback_.callback())); | 142 callback_.callback())); |
142 EXPECT_EQ(OK, stream->ReadResponseHeaders(callback_.callback())); | 143 EXPECT_EQ(OK, stream->ReadResponseHeaders(callback_.callback())); |
143 ExpectResponse(filename, stream, false); | 144 ExpectResponse(filename, stream, false); |
144 | 145 |
145 stream->Close(false); | 146 stream->Close(false); |
146 } | 147 } |
147 | 148 |
148 DeterministicMockClientSocketFactory factory_; | 149 DeterministicMockClientSocketFactory factory_; |
149 ClientSocketPoolHistograms histograms_; | 150 ClientSocketPoolHistograms histograms_; |
150 MockTransportClientSocketPool pool_; | 151 MockTransportClientSocketPool pool_; |
151 scoped_refptr<DeterministicSocketData> data_; | 152 scoped_ptr<DeterministicSocketData> data_; |
152 | 153 |
153 HostPortPair origin_; | 154 HostPortPair origin_; |
154 SSLConfig ssl_config_; | 155 SSLConfig ssl_config_; |
155 ProxyInfo proxy_info_; | 156 ProxyInfo proxy_info_; |
156 NiceMock<MockPipelineDelegate> delegate_; | 157 NiceMock<MockPipelineDelegate> delegate_; |
157 TestCompletionCallback callback_; | 158 TestCompletionCallback callback_; |
158 scoped_ptr<HttpPipelinedConnectionImpl> pipeline_; | 159 scoped_ptr<HttpPipelinedConnectionImpl> pipeline_; |
159 ScopedVector<HttpRequestInfo> request_info_vector_; | 160 ScopedVector<HttpRequestInfo> request_info_vector_; |
160 }; | 161 }; |
161 | 162 |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 MessageLoop::current()->RunAllPending(); | 1603 MessageLoop::current()->RunAllPending(); |
1603 | 1604 |
1604 stream->Close(false); | 1605 stream->Close(false); |
1605 EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(1); | 1606 EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(1); |
1606 stream.reset(NULL); | 1607 stream.reset(NULL); |
1607 } | 1608 } |
1608 | 1609 |
1609 } // anonymous namespace | 1610 } // anonymous namespace |
1610 | 1611 |
1611 } // namespace net | 1612 } // namespace net |
OLD | NEW |