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

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

Issue 1550843002: Convert enable_bidirectional_stream into build flag local to net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync Created 4 years, 11 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
« no previous file with comments | « net/http/http_stream_factory_impl_request.cc ('k') | net/net.gyp » ('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_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "net/base/port_util.h" 14 #include "net/base/port_util.h"
15 #include "net/base/test_completion_callback.h" 15 #include "net/base/test_completion_callback.h"
16 #include "net/cert/mock_cert_verifier.h" 16 #include "net/cert/mock_cert_verifier.h"
17 #include "net/dns/mock_host_resolver.h" 17 #include "net/dns/mock_host_resolver.h"
18 #include "net/http/http_auth_handler_factory.h" 18 #include "net/http/http_auth_handler_factory.h"
19 #include "net/http/http_network_session.h" 19 #include "net/http/http_network_session.h"
20 #include "net/http/http_network_session_peer.h" 20 #include "net/http/http_network_session_peer.h"
21 #include "net/http/http_network_transaction.h" 21 #include "net/http/http_network_transaction.h"
22 #include "net/http/http_request_info.h" 22 #include "net/http/http_request_info.h"
23 #include "net/http/http_server_properties.h" 23 #include "net/http/http_server_properties.h"
24 #include "net/http/http_server_properties_impl.h" 24 #include "net/http/http_server_properties_impl.h"
25 #include "net/http/http_stream.h" 25 #include "net/http/http_stream.h"
26 #include "net/http/transport_security_state.h" 26 #include "net/http/transport_security_state.h"
27 #include "net/log/net_log.h" 27 #include "net/log/net_log.h"
28 #include "net/net_features.h"
28 #include "net/proxy/proxy_info.h" 29 #include "net/proxy/proxy_info.h"
29 #include "net/proxy/proxy_service.h" 30 #include "net/proxy/proxy_service.h"
30 #include "net/quic/quic_server_id.h" 31 #include "net/quic/quic_server_id.h"
31 #include "net/quic/test_tools/quic_stream_factory_peer.h" 32 #include "net/quic/test_tools/quic_stream_factory_peer.h"
32 #include "net/socket/client_socket_handle.h" 33 #include "net/socket/client_socket_handle.h"
33 #include "net/socket/mock_client_socket_pool_manager.h" 34 #include "net/socket/mock_client_socket_pool_manager.h"
34 #include "net/socket/next_proto.h" 35 #include "net/socket/next_proto.h"
35 #include "net/socket/socket_test_util.h" 36 #include "net/socket/socket_test_util.h"
36 #include "net/spdy/spdy_session.h" 37 #include "net/spdy/spdy_session.h"
37 #include "net/spdy/spdy_session_pool.h" 38 #include "net/spdy/spdy_session_pool.h"
38 #include "net/spdy/spdy_test_util_common.h" 39 #include "net/spdy/spdy_test_util_common.h"
39 #include "net/ssl/ssl_config_service.h" 40 #include "net/ssl/ssl_config_service.h"
40 #include "net/ssl/ssl_config_service_defaults.h" 41 #include "net/ssl/ssl_config_service_defaults.h"
41 // This file can be included from net/http even though 42 // This file can be included from net/http even though
42 // it is in net/websockets because it doesn't 43 // it is in net/websockets because it doesn't
43 // introduce any link dependency to net/websockets. 44 // introduce any link dependency to net/websockets.
44 #include "net/websockets/websocket_handshake_stream_base.h" 45 #include "net/websockets/websocket_handshake_stream_base.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
46 47
47 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 48 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
48 #include "net/http/bidirectional_stream_job.h" 49 #include "net/http/bidirectional_stream_job.h"
49 #endif 50 #endif
50 51
51 namespace net { 52 namespace net {
52 53
53 class BidirectionalStreamJob; 54 class BidirectionalStreamJob;
54 55
55 namespace { 56 namespace {
56 57
57 class MockWebSocketHandshakeStream : public WebSocketHandshakeStreamBase { 58 class MockWebSocketHandshakeStream : public WebSocketHandshakeStreamBase {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 used_ssl_config_ = used_ssl_config; 174 used_ssl_config_ = used_ssl_config;
174 used_proxy_info_ = used_proxy_info; 175 used_proxy_info_ = used_proxy_info;
175 } 176 }
176 177
177 void OnBidirectionalStreamJobReady(const SSLConfig& used_ssl_config, 178 void OnBidirectionalStreamJobReady(const SSLConfig& used_ssl_config,
178 const ProxyInfo& used_proxy_info, 179 const ProxyInfo& used_proxy_info,
179 BidirectionalStreamJob* stream) override { 180 BidirectionalStreamJob* stream) override {
180 stream_done_ = true; 181 stream_done_ = true;
181 if (waiting_for_stream_) 182 if (waiting_for_stream_)
182 base::MessageLoop::current()->QuitWhenIdle(); 183 base::MessageLoop::current()->QuitWhenIdle();
183 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 184 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
184 bidirectional_stream_job_.reset(stream); 185 bidirectional_stream_job_.reset(stream);
185 #else 186 #else
186 DCHECK(!stream); 187 DCHECK(!stream);
187 #endif 188 #endif
188 used_ssl_config_ = used_ssl_config; 189 used_ssl_config_ = used_ssl_config;
189 used_proxy_info_ = used_proxy_info; 190 used_proxy_info_ = used_proxy_info;
190 } 191 }
191 192
192 void OnStreamFailed(int status, 193 void OnStreamFailed(int status,
193 const SSLConfig& used_ssl_config, 194 const SSLConfig& used_ssl_config,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 236 }
236 237
237 HttpStream* stream() { 238 HttpStream* stream() {
238 return stream_.get(); 239 return stream_.get();
239 } 240 }
240 241
241 MockWebSocketHandshakeStream* websocket_stream() { 242 MockWebSocketHandshakeStream* websocket_stream() {
242 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get()); 243 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get());
243 } 244 }
244 245
245 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 246 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
246 BidirectionalStreamJob* bidirectional_stream_job() { 247 BidirectionalStreamJob* bidirectional_stream_job() {
247 return bidirectional_stream_job_.get(); 248 return bidirectional_stream_job_.get();
248 } 249 }
249 #endif 250 #endif
250 251
251 bool stream_done() const { return stream_done_; } 252 bool stream_done() const { return stream_done_; }
252 int error_status() const { return error_status_; } 253 int error_status() const { return error_status_; }
253 254
254 private: 255 private:
255 bool waiting_for_stream_; 256 bool waiting_for_stream_;
256 bool stream_done_; 257 bool stream_done_;
257 scoped_ptr<HttpStream> stream_; 258 scoped_ptr<HttpStream> stream_;
258 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_; 259 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_;
259 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 260 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
260 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job_; 261 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job_;
261 #endif 262 #endif
262 SSLConfig used_ssl_config_; 263 SSLConfig used_ssl_config_;
263 ProxyInfo used_proxy_info_; 264 ProxyInfo used_proxy_info_;
264 int error_status_; 265 int error_status_;
265 266
266 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); 267 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter);
267 }; 268 };
268 269
269 class WebSocketSpdyHandshakeStream : public MockWebSocketHandshakeStream { 270 class WebSocketSpdyHandshakeStream : public MockWebSocketHandshakeStream {
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 EXPECT_EQ(1, GetSocketPoolGroupCount( 1378 EXPECT_EQ(1, GetSocketPoolGroupCount(
1378 session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL))); 1379 session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)));
1379 EXPECT_EQ(0, GetSocketPoolGroupCount( 1380 EXPECT_EQ(0, GetSocketPoolGroupCount(
1380 session->GetTransportSocketPool( 1381 session->GetTransportSocketPool(
1381 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 1382 HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
1382 EXPECT_EQ(0, GetSocketPoolGroupCount( 1383 EXPECT_EQ(0, GetSocketPoolGroupCount(
1383 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 1384 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
1384 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 1385 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
1385 } 1386 }
1386 1387
1387 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 1388 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
1388 TEST_P(HttpStreamFactoryTest, RequestBidirectionalStreamJob) { 1389 TEST_P(HttpStreamFactoryTest, RequestBidirectionalStreamJob) {
1389 SpdySessionDependencies session_deps(GetParam(), 1390 SpdySessionDependencies session_deps(GetParam(),
1390 ProxyService::CreateDirect()); 1391 ProxyService::CreateDirect());
1391 1392
1392 MockRead mock_read(ASYNC, OK); 1393 MockRead mock_read(ASYNC, OK);
1393 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0); 1394 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0);
1394 socket_data.set_connect_data(MockConnect(ASYNC, OK)); 1395 socket_data.set_connect_data(MockConnect(ASYNC, OK));
1395 session_deps.socket_factory->AddSocketDataProvider(&socket_data); 1396 session_deps.socket_factory->AddSocketDataProvider(&socket_data);
1396 1397
1397 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); 1398 SSLSocketDataProvider ssl_socket_data(ASYNC, OK);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 1682 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
1682 1683
1683 // Make sure there is no orphaned job. it is already canceled. 1684 // Make sure there is no orphaned job. it is already canceled.
1684 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( 1685 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>(
1685 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); 1686 session->http_stream_factory_for_websocket())->num_orphaned_jobs());
1686 } 1687 }
1687 1688
1688 } // namespace 1689 } // namespace
1689 1690
1690 } // namespace net 1691 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_request.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698