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

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

Issue 284423002: Remove HttpStreamFactory's NPN/SPDY globals, except for spdy_enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge Created 6 years, 7 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_stream_factory_impl_job.cc ('k') | net/net.gypi » ('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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 25 matching lines...) Expand all
36 // This file can be included from net/http even though 36 // This file can be included from net/http even though
37 // it is in net/websockets because it doesn't 37 // it is in net/websockets because it doesn't
38 // introduce any link dependency to net/websockets. 38 // introduce any link dependency to net/websockets.
39 #include "net/websockets/websocket_handshake_stream_base.h" 39 #include "net/websockets/websocket_handshake_stream_base.h"
40 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
41 41
42 namespace net { 42 namespace net {
43 43
44 namespace { 44 namespace {
45 45
46 class UseAlternateProtocolsScopedSetter {
47 public:
48 explicit UseAlternateProtocolsScopedSetter(bool use_alternate_protocols)
49 : use_alternate_protocols_(HttpStreamFactory::use_alternate_protocols()) {
50 HttpStreamFactory::set_use_alternate_protocols(use_alternate_protocols);
51 }
52 ~UseAlternateProtocolsScopedSetter() {
53 HttpStreamFactory::set_use_alternate_protocols(use_alternate_protocols_);
54 }
55
56 private:
57 bool use_alternate_protocols_;
58 };
59
60 class MockWebSocketHandshakeStream : public WebSocketHandshakeStreamBase { 46 class MockWebSocketHandshakeStream : public WebSocketHandshakeStreamBase {
61 public: 47 public:
62 enum StreamType { 48 enum StreamType {
63 kStreamTypeBasic, 49 kStreamTypeBasic,
64 kStreamTypeSpdy, 50 kStreamTypeSpdy,
65 }; 51 };
66 52
67 explicit MockWebSocketHandshakeStream(StreamType type) : type_(type) {} 53 explicit MockWebSocketHandshakeStream(StreamType type) : type_(type) {}
68 54
69 virtual ~MockWebSocketHandshakeStream() {} 55 virtual ~MockWebSocketHandshakeStream() {}
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 EXPECT_EQ(1, GetSocketPoolGroupCount( 1244 EXPECT_EQ(1, GetSocketPoolGroupCount(
1259 session->GetTransportSocketPool( 1245 session->GetTransportSocketPool(
1260 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 1246 HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
1261 EXPECT_EQ(1, GetSocketPoolGroupCount( 1247 EXPECT_EQ(1, GetSocketPoolGroupCount(
1262 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 1248 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
1263 EXPECT_TRUE(waiter1.used_proxy_info().is_direct()); 1249 EXPECT_TRUE(waiter1.used_proxy_info().is_direct());
1264 } 1250 }
1265 1251
1266 // TODO(ricea): Re-enable once WebSocket over SPDY is implemented. 1252 // TODO(ricea): Re-enable once WebSocket over SPDY is implemented.
1267 TEST_P(HttpStreamFactoryTest, DISABLED_OrphanedWebSocketStream) { 1253 TEST_P(HttpStreamFactoryTest, DISABLED_OrphanedWebSocketStream) {
1268 UseAlternateProtocolsScopedSetter use_alternate_protocols(true);
1269 SpdySessionDependencies session_deps(GetParam(), 1254 SpdySessionDependencies session_deps(GetParam(),
1270 ProxyService::CreateDirect()); 1255 ProxyService::CreateDirect());
1256 session_deps.use_alternate_protocols = true;
1271 1257
1272 MockRead mock_read(ASYNC, OK); 1258 MockRead mock_read(ASYNC, OK);
1273 DeterministicSocketData socket_data(&mock_read, 1, NULL, 0); 1259 DeterministicSocketData socket_data(&mock_read, 1, NULL, 0);
1274 socket_data.set_connect_data(MockConnect(ASYNC, OK)); 1260 socket_data.set_connect_data(MockConnect(ASYNC, OK));
1275 session_deps.deterministic_socket_factory->AddSocketDataProvider( 1261 session_deps.deterministic_socket_factory->AddSocketDataProvider(
1276 &socket_data); 1262 &socket_data);
1277 1263
1278 MockRead mock_read2(ASYNC, OK); 1264 MockRead mock_read2(ASYNC, OK);
1279 DeterministicSocketData socket_data2(&mock_read2, 1, NULL, 0); 1265 DeterministicSocketData socket_data2(&mock_read2, 1, NULL, 0);
1280 socket_data2.set_connect_data(MockConnect(ASYNC, ERR_IO_PENDING)); 1266 socket_data2.set_connect_data(MockConnect(ASYNC, ERR_IO_PENDING));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 1320 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
1335 1321
1336 // Make sure there is no orphaned job. it is already canceled. 1322 // Make sure there is no orphaned job. it is already canceled.
1337 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( 1323 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>(
1338 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); 1324 session->http_stream_factory_for_websocket())->num_orphaned_jobs());
1339 } 1325 }
1340 1326
1341 } // namespace 1327 } // namespace
1342 1328
1343 } // namespace net 1329 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.cc ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698