| 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/spdy/spdy_proxy_client_socket.h" | 5 #include "net/spdy/spdy_proxy_client_socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| 11 #include "net/base/test_completion_callback.h" | 11 #include "net/base/test_completion_callback.h" |
| 12 #include "net/base/winsock_init.h" | 12 #include "net/base/winsock_init.h" |
| 13 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
| 14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 15 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
| 16 #include "net/log/capturing_net_log.h" | |
| 17 #include "net/log/net_log.h" | 16 #include "net/log/net_log.h" |
| 18 #include "net/log/net_log_unittest.h" | 17 #include "net/log/net_log_unittest.h" |
| 18 #include "net/log/test_net_log.h" |
| 19 #include "net/socket/client_socket_factory.h" | 19 #include "net/socket/client_socket_factory.h" |
| 20 #include "net/socket/next_proto.h" | 20 #include "net/socket/next_proto.h" |
| 21 #include "net/socket/socket_test_util.h" | 21 #include "net/socket/socket_test_util.h" |
| 22 #include "net/socket/tcp_client_socket.h" | 22 #include "net/socket/tcp_client_socket.h" |
| 23 #include "net/spdy/buffered_spdy_framer.h" | 23 #include "net/spdy/buffered_spdy_framer.h" |
| 24 #include "net/spdy/spdy_http_utils.h" | 24 #include "net/spdy/spdy_http_utils.h" |
| 25 #include "net/spdy/spdy_protocol.h" | 25 #include "net/spdy/spdy_protocol.h" |
| 26 #include "net/spdy/spdy_session_pool.h" | 26 #include "net/spdy/spdy_session_pool.h" |
| 27 #include "net/spdy/spdy_test_util_common.h" | 27 #include "net/spdy/spdy_test_util_common.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 void CloseSpdySession(net::Error error, const std::string& description) { | 113 void CloseSpdySession(net::Error error, const std::string& description) { |
| 114 spdy_session_->CloseSessionOnError(error, description); | 114 spdy_session_->CloseSessionOnError(error, description); |
| 115 } | 115 } |
| 116 | 116 |
| 117 SpdyTestUtil spdy_util_; | 117 SpdyTestUtil spdy_util_; |
| 118 scoped_ptr<SpdyProxyClientSocket> sock_; | 118 scoped_ptr<SpdyProxyClientSocket> sock_; |
| 119 TestCompletionCallback read_callback_; | 119 TestCompletionCallback read_callback_; |
| 120 TestCompletionCallback write_callback_; | 120 TestCompletionCallback write_callback_; |
| 121 scoped_ptr<DeterministicSocketData> data_; | 121 scoped_ptr<DeterministicSocketData> data_; |
| 122 CapturingBoundNetLog net_log_; | 122 BoundTestNetLog net_log_; |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 scoped_refptr<HttpNetworkSession> session_; | 125 scoped_refptr<HttpNetworkSession> session_; |
| 126 scoped_refptr<IOBuffer> read_buf_; | 126 scoped_refptr<IOBuffer> read_buf_; |
| 127 SpdySessionDependencies session_deps_; | 127 SpdySessionDependencies session_deps_; |
| 128 MockConnect connect_data_; | 128 MockConnect connect_data_; |
| 129 base::WeakPtr<SpdySession> spdy_session_; | 129 base::WeakPtr<SpdySession> spdy_session_; |
| 130 BufferedSpdyFramer framer_; | 130 BufferedSpdyFramer framer_; |
| 131 | 131 |
| 132 std::string user_agent_; | 132 std::string user_agent_; |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 | 1267 |
| 1268 AssertConnectSucceeds(); | 1268 AssertConnectSucceeds(); |
| 1269 | 1269 |
| 1270 Run(1); // SpdySession consumes the next read and sends it to | 1270 Run(1); // SpdySession consumes the next read and sends it to |
| 1271 // sock_ to be buffered. | 1271 // sock_ to be buffered. |
| 1272 AssertSyncReadEquals(kMsg1, kLen1); | 1272 AssertSyncReadEquals(kMsg1, kLen1); |
| 1273 | 1273 |
| 1274 NetLog::Source sock_source = sock_->NetLog().source(); | 1274 NetLog::Source sock_source = sock_->NetLog().source(); |
| 1275 sock_.reset(); | 1275 sock_.reset(); |
| 1276 | 1276 |
| 1277 CapturingNetLog::CapturedEntryList entry_list; | 1277 TestNetLog::CapturedEntryList entry_list; |
| 1278 net_log_.GetEntriesForSource(sock_source, &entry_list); | 1278 net_log_.GetEntriesForSource(sock_source, &entry_list); |
| 1279 | 1279 |
| 1280 ASSERT_EQ(entry_list.size(), 10u); | 1280 ASSERT_EQ(entry_list.size(), 10u); |
| 1281 EXPECT_TRUE(LogContainsBeginEvent(entry_list, 0, NetLog::TYPE_SOCKET_ALIVE)); | 1281 EXPECT_TRUE(LogContainsBeginEvent(entry_list, 0, NetLog::TYPE_SOCKET_ALIVE)); |
| 1282 EXPECT_TRUE(LogContainsEvent(entry_list, 1, | 1282 EXPECT_TRUE(LogContainsEvent(entry_list, 1, |
| 1283 NetLog::TYPE_HTTP2_PROXY_CLIENT_SESSION, | 1283 NetLog::TYPE_HTTP2_PROXY_CLIENT_SESSION, |
| 1284 NetLog::PHASE_NONE)); | 1284 NetLog::PHASE_NONE)); |
| 1285 EXPECT_TRUE(LogContainsBeginEvent(entry_list, 2, | 1285 EXPECT_TRUE(LogContainsBeginEvent(entry_list, 2, |
| 1286 NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_SEND_REQUEST)); | 1286 NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_SEND_REQUEST)); |
| 1287 EXPECT_TRUE(LogContainsEvent(entry_list, 3, | 1287 EXPECT_TRUE(LogContainsEvent(entry_list, 3, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 | 1372 |
| 1373 EXPECT_FALSE(sock_.get()); | 1373 EXPECT_FALSE(sock_.get()); |
| 1374 EXPECT_TRUE(read_callback.have_result()); | 1374 EXPECT_TRUE(read_callback.have_result()); |
| 1375 EXPECT_FALSE(write_callback_.have_result()); | 1375 EXPECT_FALSE(write_callback_.have_result()); |
| 1376 | 1376 |
| 1377 // Let the RST_STREAM write while |rst| is in-scope. | 1377 // Let the RST_STREAM write while |rst| is in-scope. |
| 1378 base::MessageLoop::current()->RunUntilIdle(); | 1378 base::MessageLoop::current()->RunUntilIdle(); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 } // namespace net | 1381 } // namespace net |
| OLD | NEW |