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

Side by Side Diff: net/socket/socks5_client_socket_unittest.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed implementation of attach/detach of request Created 4 years, 5 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
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/socket/socks5_client_socket.h" 5 #include "net/socket/socks5_client_socket.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 std::unique_ptr<SOCKS5ClientSocket> user_sock_; 58 std::unique_ptr<SOCKS5ClientSocket> user_sock_;
59 AddressList address_list_; 59 AddressList address_list_;
60 // Filled in by BuildMockSocket() and owned by its return value 60 // Filled in by BuildMockSocket() and owned by its return value
61 // (which |user_sock| is set to). 61 // (which |user_sock| is set to).
62 StreamSocket* tcp_sock_; 62 StreamSocket* tcp_sock_;
63 TestCompletionCallback callback_; 63 TestCompletionCallback callback_;
64 std::unique_ptr<MockHostResolver> host_resolver_; 64 std::unique_ptr<MockHostResolver> host_resolver_;
65 std::unique_ptr<SocketDataProvider> data_; 65 std::unique_ptr<SocketDataProvider> data_;
66 66
67 private: 67 private:
68 std::unique_ptr<HostResolver::Request> request_;
mmenke 2016/07/19 19:03:56 This doesn't need to be a member of the class - ca
maksims (do not use this acc) 2016/07/21 07:12:46 Done.
68 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocketTest); 69 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocketTest);
69 }; 70 };
70 71
71 SOCKS5ClientSocketTest::SOCKS5ClientSocketTest() 72 SOCKS5ClientSocketTest::SOCKS5ClientSocketTest()
72 : kNwPort(base::HostToNet16(80)), 73 : kNwPort(base::HostToNet16(80)),
73 host_resolver_(new MockHostResolver) { 74 host_resolver_(new MockHostResolver) {
74 } 75 }
75 76
76 // Set up platform before every test case 77 // Set up platform before every test case
77 void SOCKS5ClientSocketTest::SetUp() { 78 void SOCKS5ClientSocketTest::SetUp() {
78 PlatformTest::SetUp(); 79 PlatformTest::SetUp();
79 80
80 // Resolve the "localhost" AddressList used by the TCP connection to connect. 81 // Resolve the "localhost" AddressList used by the TCP connection to connect.
81 HostResolver::RequestInfo info(HostPortPair("www.socks-proxy.com", 1080)); 82 HostResolver::RequestInfo info(HostPortPair("www.socks-proxy.com", 1080));
82 TestCompletionCallback callback; 83 TestCompletionCallback callback;
83 int rv = host_resolver_->Resolve(info, 84 int rv =
84 DEFAULT_PRIORITY, 85 host_resolver_->Resolve(info, DEFAULT_PRIORITY, &address_list_,
85 &address_list_, 86 callback.callback(), &request_, BoundNetLog());
86 callback.callback(),
87 NULL,
88 BoundNetLog());
89 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); 87 ASSERT_THAT(rv, IsError(ERR_IO_PENDING));
90 rv = callback.WaitForResult(); 88 rv = callback.WaitForResult();
91 ASSERT_THAT(rv, IsOk()); 89 ASSERT_THAT(rv, IsOk());
92 } 90 }
93 91
94 std::unique_ptr<SOCKS5ClientSocket> SOCKS5ClientSocketTest::BuildMockSocket( 92 std::unique_ptr<SOCKS5ClientSocket> SOCKS5ClientSocketTest::BuildMockSocket(
95 MockRead reads[], 93 MockRead reads[],
96 size_t reads_count, 94 size_t reads_count,
97 MockWrite writes[], 95 MockWrite writes[],
98 size_t writes_count, 96 size_t writes_count,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 EXPECT_TRUE(user_sock_->IsConnected()); 378 EXPECT_TRUE(user_sock_->IsConnected());
381 net_log_.GetEntries(&net_log_entries); 379 net_log_.GetEntries(&net_log_entries);
382 EXPECT_TRUE(LogContainsEndEvent(net_log_entries, -1, 380 EXPECT_TRUE(LogContainsEndEvent(net_log_entries, -1,
383 NetLog::TYPE_SOCKS5_CONNECT)); 381 NetLog::TYPE_SOCKS5_CONNECT));
384 } 382 }
385 } 383 }
386 384
387 } // namespace 385 } // namespace
388 386
389 } // namespace net 387 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698