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/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/address_list.h" | 11 #include "net/base/address_list.h" |
10 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
11 #include "net/base/winsock_init.h" | 13 #include "net/base/winsock_init.h" |
12 #include "net/dns/host_resolver.h" | 14 #include "net/dns/host_resolver.h" |
13 #include "net/dns/mock_host_resolver.h" | 15 #include "net/dns/mock_host_resolver.h" |
14 #include "net/log/net_log.h" | 16 #include "net/log/net_log.h" |
15 #include "net/log/test_net_log.h" | 17 #include "net/log/test_net_log.h" |
16 #include "net/log/test_net_log_entry.h" | 18 #include "net/log/test_net_log_entry.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 EXPECT_EQ(ERR_IO_PENDING, rv); | 81 EXPECT_EQ(ERR_IO_PENDING, rv); |
80 rv = callback.WaitForResult(); | 82 rv = callback.WaitForResult(); |
81 EXPECT_EQ(OK, rv); | 83 EXPECT_EQ(OK, rv); |
82 EXPECT_TRUE(tcp_sock_->IsConnected()); | 84 EXPECT_TRUE(tcp_sock_->IsConnected()); |
83 | 85 |
84 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 86 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
85 // |connection| takes ownership of |tcp_sock_|, but keep a | 87 // |connection| takes ownership of |tcp_sock_|, but keep a |
86 // non-owning pointer to it. | 88 // non-owning pointer to it. |
87 connection->SetSocket(scoped_ptr<StreamSocket>(tcp_sock_)); | 89 connection->SetSocket(scoped_ptr<StreamSocket>(tcp_sock_)); |
88 return scoped_ptr<SOCKSClientSocket>(new SOCKSClientSocket( | 90 return scoped_ptr<SOCKSClientSocket>(new SOCKSClientSocket( |
89 connection.Pass(), | 91 std::move(connection), |
90 HostResolver::RequestInfo(HostPortPair(hostname, port)), | 92 HostResolver::RequestInfo(HostPortPair(hostname, port)), DEFAULT_PRIORITY, |
91 DEFAULT_PRIORITY, | |
92 host_resolver)); | 93 host_resolver)); |
93 } | 94 } |
94 | 95 |
95 // Implementation of HostResolver that never completes its resolve request. | 96 // Implementation of HostResolver that never completes its resolve request. |
96 // We use this in the test "DisconnectWhileHostResolveInProgress" to make | 97 // We use this in the test "DisconnectWhileHostResolveInProgress" to make |
97 // sure that the outstanding resolve request gets cancelled. | 98 // sure that the outstanding resolve request gets cancelled. |
98 class HangingHostResolverWithCancel : public HostResolver { | 99 class HangingHostResolverWithCancel : public HostResolver { |
99 public: | 100 public: |
100 HangingHostResolverWithCancel() : outstanding_request_(NULL) {} | 101 HangingHostResolverWithCancel() : outstanding_request_(NULL) {} |
101 | 102 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 NULL, 0, | 445 NULL, 0, |
445 host_resolver.get(), | 446 host_resolver.get(), |
446 kHostName, 80, | 447 kHostName, 80, |
447 NULL); | 448 NULL); |
448 | 449 |
449 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, | 450 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, |
450 callback_.GetResult(user_sock_->Connect(callback_.callback()))); | 451 callback_.GetResult(user_sock_->Connect(callback_.callback()))); |
451 } | 452 } |
452 | 453 |
453 } // namespace net | 454 } // namespace net |
OLD | NEW |