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_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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 virtual ~WebSocketBasicHandshakeStream() { | 265 virtual ~WebSocketBasicHandshakeStream() { |
266 connection_->socket()->Disconnect(); | 266 connection_->socket()->Disconnect(); |
267 } | 267 } |
268 | 268 |
269 ClientSocketHandle* connection() { return connection_.get(); } | 269 ClientSocketHandle* connection() { return connection_.get(); } |
270 | 270 |
271 private: | 271 private: |
272 scoped_ptr<ClientSocketHandle> connection_; | 272 scoped_ptr<ClientSocketHandle> connection_; |
273 }; | 273 }; |
274 | 274 |
275 class WebSocketStreamFactory : public WebSocketHandshakeStreamBase::Factory { | 275 class WebSocketHandshakeStreamFactory |
| 276 : public WebSocketHandshakeStreamBase::Factory { |
276 public: | 277 public: |
277 virtual ~WebSocketStreamFactory() {} | 278 virtual ~WebSocketHandshakeStreamFactory() {} |
278 | 279 |
279 virtual WebSocketHandshakeStreamBase* CreateBasicStream( | 280 virtual WebSocketHandshakeStreamBase* CreateBasicStream( |
280 ClientSocketHandle* connection, | 281 ClientSocketHandle* connection, |
281 bool using_proxy) OVERRIDE { | 282 bool using_proxy) OVERRIDE { |
282 return new WebSocketBasicHandshakeStream(connection); | 283 return new WebSocketBasicHandshakeStream(connection); |
283 } | 284 } |
284 | 285 |
285 virtual WebSocketHandshakeStreamBase* CreateSpdyStream( | 286 virtual WebSocketHandshakeStreamBase* CreateSpdyStream( |
286 const base::WeakPtr<SpdySession>& spdy_session, | 287 const base::WeakPtr<SpdySession>& spdy_session, |
287 bool use_relative_url) OVERRIDE { | 288 bool use_relative_url) OVERRIDE { |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 924 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
924 | 925 |
925 // Now request a stream. | 926 // Now request a stream. |
926 HttpRequestInfo request_info; | 927 HttpRequestInfo request_info; |
927 request_info.method = "GET"; | 928 request_info.method = "GET"; |
928 request_info.url = GURL("ws://www.google.com"); | 929 request_info.url = GURL("ws://www.google.com"); |
929 request_info.load_flags = 0; | 930 request_info.load_flags = 0; |
930 | 931 |
931 SSLConfig ssl_config; | 932 SSLConfig ssl_config; |
932 StreamRequestWaiter waiter; | 933 StreamRequestWaiter waiter; |
933 WebSocketStreamFactory factory; | 934 WebSocketHandshakeStreamFactory factory; |
934 scoped_ptr<HttpStreamRequest> request( | 935 scoped_ptr<HttpStreamRequest> request( |
935 session->websocket_handshake_stream_factory() | 936 session->websocket_handshake_stream_factory() |
936 ->RequestWebSocketHandshakeStream(request_info, | 937 ->RequestWebSocketHandshakeStream(request_info, |
937 DEFAULT_PRIORITY, | 938 DEFAULT_PRIORITY, |
938 ssl_config, | 939 ssl_config, |
939 ssl_config, | 940 ssl_config, |
940 &waiter, | 941 &waiter, |
941 &factory, | 942 &factory, |
942 BoundNetLog())); | 943 BoundNetLog())); |
943 waiter.WaitForStream(); | 944 waiter.WaitForStream(); |
(...skipping 30 matching lines...) Expand all Loading... |
974 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 975 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
975 | 976 |
976 // Now request a stream. | 977 // Now request a stream. |
977 HttpRequestInfo request_info; | 978 HttpRequestInfo request_info; |
978 request_info.method = "GET"; | 979 request_info.method = "GET"; |
979 request_info.url = GURL("wss://www.google.com"); | 980 request_info.url = GURL("wss://www.google.com"); |
980 request_info.load_flags = 0; | 981 request_info.load_flags = 0; |
981 | 982 |
982 SSLConfig ssl_config; | 983 SSLConfig ssl_config; |
983 StreamRequestWaiter waiter; | 984 StreamRequestWaiter waiter; |
984 WebSocketStreamFactory factory; | 985 WebSocketHandshakeStreamFactory factory; |
985 scoped_ptr<HttpStreamRequest> request( | 986 scoped_ptr<HttpStreamRequest> request( |
986 session->websocket_handshake_stream_factory() | 987 session->websocket_handshake_stream_factory() |
987 ->RequestWebSocketHandshakeStream(request_info, | 988 ->RequestWebSocketHandshakeStream(request_info, |
988 DEFAULT_PRIORITY, | 989 DEFAULT_PRIORITY, |
989 ssl_config, | 990 ssl_config, |
990 ssl_config, | 991 ssl_config, |
991 &waiter, | 992 &waiter, |
992 &factory, | 993 &factory, |
993 BoundNetLog())); | 994 BoundNetLog())); |
994 waiter.WaitForStream(); | 995 waiter.WaitForStream(); |
(...skipping 27 matching lines...) Expand all Loading... |
1022 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 1023 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
1023 | 1024 |
1024 // Now request a stream. | 1025 // Now request a stream. |
1025 HttpRequestInfo request_info; | 1026 HttpRequestInfo request_info; |
1026 request_info.method = "GET"; | 1027 request_info.method = "GET"; |
1027 request_info.url = GURL("ws://www.google.com"); | 1028 request_info.url = GURL("ws://www.google.com"); |
1028 request_info.load_flags = 0; | 1029 request_info.load_flags = 0; |
1029 | 1030 |
1030 SSLConfig ssl_config; | 1031 SSLConfig ssl_config; |
1031 StreamRequestWaiter waiter; | 1032 StreamRequestWaiter waiter; |
1032 WebSocketStreamFactory factory; | 1033 WebSocketHandshakeStreamFactory factory; |
1033 scoped_ptr<HttpStreamRequest> request( | 1034 scoped_ptr<HttpStreamRequest> request( |
1034 session->websocket_handshake_stream_factory() | 1035 session->websocket_handshake_stream_factory() |
1035 ->RequestWebSocketHandshakeStream(request_info, | 1036 ->RequestWebSocketHandshakeStream(request_info, |
1036 DEFAULT_PRIORITY, | 1037 DEFAULT_PRIORITY, |
1037 ssl_config, | 1038 ssl_config, |
1038 ssl_config, | 1039 ssl_config, |
1039 &waiter, | 1040 &waiter, |
1040 &factory, | 1041 &factory, |
1041 BoundNetLog())); | 1042 BoundNetLog())); |
1042 waiter.WaitForStream(); | 1043 waiter.WaitForStream(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 session(SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 1137 session(SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
1137 | 1138 |
1138 // Now request a stream. | 1139 // Now request a stream. |
1139 HttpRequestInfo request_info; | 1140 HttpRequestInfo request_info; |
1140 request_info.method = "GET"; | 1141 request_info.method = "GET"; |
1141 request_info.url = GURL("wss://www.google.com"); | 1142 request_info.url = GURL("wss://www.google.com"); |
1142 request_info.load_flags = 0; | 1143 request_info.load_flags = 0; |
1143 | 1144 |
1144 SSLConfig ssl_config; | 1145 SSLConfig ssl_config; |
1145 StreamRequestWaiter waiter1; | 1146 StreamRequestWaiter waiter1; |
1146 WebSocketStreamFactory factory; | 1147 WebSocketHandshakeStreamFactory factory; |
1147 scoped_ptr<HttpStreamRequest> request1( | 1148 scoped_ptr<HttpStreamRequest> request1( |
1148 session->websocket_handshake_stream_factory() | 1149 session->websocket_handshake_stream_factory() |
1149 ->RequestWebSocketHandshakeStream(request_info, | 1150 ->RequestWebSocketHandshakeStream(request_info, |
1150 DEFAULT_PRIORITY, | 1151 DEFAULT_PRIORITY, |
1151 ssl_config, | 1152 ssl_config, |
1152 ssl_config, | 1153 ssl_config, |
1153 &waiter1, | 1154 &waiter1, |
1154 &factory, | 1155 &factory, |
1155 BoundNetLog())); | 1156 BoundNetLog())); |
1156 waiter1.WaitForStream(); | 1157 waiter1.WaitForStream(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 request_info.url = GURL("ws://www.google.com:8888"); | 1227 request_info.url = GURL("ws://www.google.com:8888"); |
1227 request_info.load_flags = 0; | 1228 request_info.load_flags = 0; |
1228 | 1229 |
1229 session->http_server_properties()->SetAlternateProtocol( | 1230 session->http_server_properties()->SetAlternateProtocol( |
1230 HostPortPair("www.google.com", 8888), | 1231 HostPortPair("www.google.com", 8888), |
1231 9999, | 1232 9999, |
1232 NPN_SPDY_3); | 1233 NPN_SPDY_3); |
1233 | 1234 |
1234 SSLConfig ssl_config; | 1235 SSLConfig ssl_config; |
1235 StreamRequestWaiter waiter; | 1236 StreamRequestWaiter waiter; |
1236 WebSocketStreamFactory factory; | 1237 WebSocketHandshakeStreamFactory factory; |
1237 scoped_ptr<HttpStreamRequest> request( | 1238 scoped_ptr<HttpStreamRequest> request( |
1238 session->websocket_handshake_stream_factory() | 1239 session->websocket_handshake_stream_factory() |
1239 ->RequestWebSocketHandshakeStream(request_info, | 1240 ->RequestWebSocketHandshakeStream(request_info, |
1240 DEFAULT_PRIORITY, | 1241 DEFAULT_PRIORITY, |
1241 ssl_config, | 1242 ssl_config, |
1242 ssl_config, | 1243 ssl_config, |
1243 &waiter, | 1244 &waiter, |
1244 &factory, | 1245 &factory, |
1245 BoundNetLog())); | 1246 BoundNetLog())); |
1246 waiter.WaitForStream(); | 1247 waiter.WaitForStream(); |
(...skipping 17 matching lines...) Expand all Loading... |
1264 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 1265 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
1265 | 1266 |
1266 // Make sure there is no orphaned job. it is already canceled. | 1267 // Make sure there is no orphaned job. it is already canceled. |
1267 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( | 1268 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( |
1268 session->websocket_handshake_stream_factory())->num_orphaned_jobs()); | 1269 session->websocket_handshake_stream_factory())->num_orphaned_jobs()); |
1269 } | 1270 } |
1270 | 1271 |
1271 } // namespace | 1272 } // namespace |
1272 | 1273 |
1273 } // namespace net | 1274 } // namespace net |
OLD | NEW |