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

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

Issue 22794008: Remove deprecated functions that take StreamSockets instead of handles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
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/socks_client_socket.h" 5 #include "net/socket/socks_client_socket.h"
6 6
7 #include "net/base/address_list.h" 7 #include "net/base/address_list.h"
8 #include "net/base/net_log.h" 8 #include "net/base/net_log.h"
9 #include "net/base/net_log_unittest.h" 9 #include "net/base/net_log_unittest.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
(...skipping 19 matching lines...) Expand all
30 SOCKSClientSocket* BuildMockSocket(MockRead reads[], size_t reads_count, 30 SOCKSClientSocket* BuildMockSocket(MockRead reads[], size_t reads_count,
31 MockWrite writes[], size_t writes_count, 31 MockWrite writes[], size_t writes_count,
32 HostResolver* host_resolver, 32 HostResolver* host_resolver,
33 const std::string& hostname, int port, 33 const std::string& hostname, int port,
34 NetLog* net_log); 34 NetLog* net_log);
35 virtual void SetUp(); 35 virtual void SetUp();
36 36
37 protected: 37 protected:
38 scoped_ptr<SOCKSClientSocket> user_sock_; 38 scoped_ptr<SOCKSClientSocket> user_sock_;
39 AddressList address_list_; 39 AddressList address_list_;
40 // Filled in by BuildMockSocket() and owned by its return value
41 // (which |user_sock| is set to).
40 StreamSocket* tcp_sock_; 42 StreamSocket* tcp_sock_;
41 TestCompletionCallback callback_; 43 TestCompletionCallback callback_;
42 scoped_ptr<MockHostResolver> host_resolver_; 44 scoped_ptr<MockHostResolver> host_resolver_;
43 scoped_ptr<SocketDataProvider> data_; 45 scoped_ptr<SocketDataProvider> data_;
44 }; 46 };
45 47
46 SOCKSClientSocketTest::SOCKSClientSocketTest() 48 SOCKSClientSocketTest::SOCKSClientSocketTest()
47 : host_resolver_(new MockHostResolver) { 49 : host_resolver_(new MockHostResolver) {
48 } 50 }
49 51
(...skipping 16 matching lines...) Expand all
66 data_.reset(new StaticSocketDataProvider(reads, reads_count, 68 data_.reset(new StaticSocketDataProvider(reads, reads_count,
67 writes, writes_count)); 69 writes, writes_count));
68 tcp_sock_ = new MockTCPClientSocket(address_list_, net_log, data_.get()); 70 tcp_sock_ = new MockTCPClientSocket(address_list_, net_log, data_.get());
69 71
70 int rv = tcp_sock_->Connect(callback.callback()); 72 int rv = tcp_sock_->Connect(callback.callback());
71 EXPECT_EQ(ERR_IO_PENDING, rv); 73 EXPECT_EQ(ERR_IO_PENDING, rv);
72 rv = callback.WaitForResult(); 74 rv = callback.WaitForResult();
73 EXPECT_EQ(OK, rv); 75 EXPECT_EQ(OK, rv);
74 EXPECT_TRUE(tcp_sock_->IsConnected()); 76 EXPECT_TRUE(tcp_sock_->IsConnected());
75 77
76 return new SOCKSClientSocket(tcp_sock_, 78 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
79 // |connection| takes ownership of |tcp_sock_|, but we still keep a
80 // non-owning pointer to it.
Ryan Sleevi 2013/08/13 20:26:13 same comment nit: s/we still// https://groups.goo
akalin 2013/08/13 20:51:28 Done.
81 connection->set_socket(tcp_sock_);
82 return new SOCKSClientSocket(connection.release(),
Ryan Sleevi 2013/08/13 20:26:13 same style nit: linebreak
akalin 2013/08/13 20:51:28 Done.
77 HostResolver::RequestInfo(HostPortPair(hostname, port)), 83 HostResolver::RequestInfo(HostPortPair(hostname, port)),
78 host_resolver); 84 host_resolver);
79 } 85 }
80 86
81 // Implementation of HostResolver that never completes its resolve request. 87 // Implementation of HostResolver that never completes its resolve request.
82 // We use this in the test "DisconnectWhileHostResolveInProgress" to make 88 // We use this in the test "DisconnectWhileHostResolveInProgress" to make
83 // sure that the outstanding resolve request gets cancelled. 89 // sure that the outstanding resolve request gets cancelled.
84 class HangingHostResolverWithCancel : public HostResolver { 90 class HangingHostResolverWithCancel : public HostResolver {
85 public: 91 public:
86 HangingHostResolverWithCancel() : outstanding_request_(NULL) {} 92 HangingHostResolverWithCancel() : outstanding_request_(NULL) {}
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. 403 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve.
398 user_sock_->Disconnect(); 404 user_sock_->Disconnect();
399 405
400 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); 406 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest());
401 407
402 EXPECT_FALSE(user_sock_->IsConnected()); 408 EXPECT_FALSE(user_sock_->IsConnected());
403 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); 409 EXPECT_FALSE(user_sock_->IsConnectedAndIdle());
404 } 410 }
405 411
406 } // namespace net 412 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698