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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility>
8
7 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 11 #include "base/format_macros.h"
10 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
11 #include "base/sys_byteorder.h" 13 #include "base/sys_byteorder.h"
12 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
13 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
14 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
15 #include "net/log/net_log.h" 17 #include "net/log/net_log.h"
16 #include "net/socket/client_socket_handle.h" 18 #include "net/socket/client_socket_handle.h"
17 19
18 namespace net { 20 namespace net {
19 21
20 const unsigned int SOCKS5ClientSocket::kGreetReadHeaderSize = 2; 22 const unsigned int SOCKS5ClientSocket::kGreetReadHeaderSize = 2;
21 const unsigned int SOCKS5ClientSocket::kWriteHeaderSize = 10; 23 const unsigned int SOCKS5ClientSocket::kWriteHeaderSize = 10;
22 const unsigned int SOCKS5ClientSocket::kReadHeaderSize = 5; 24 const unsigned int SOCKS5ClientSocket::kReadHeaderSize = 5;
23 const uint8_t SOCKS5ClientSocket::kSOCKS5Version = 0x05; 25 const uint8_t SOCKS5ClientSocket::kSOCKS5Version = 0x05;
24 const uint8_t SOCKS5ClientSocket::kTunnelCommand = 0x01; 26 const uint8_t SOCKS5ClientSocket::kTunnelCommand = 0x01;
25 const uint8_t SOCKS5ClientSocket::kNullByte = 0x00; 27 const uint8_t SOCKS5ClientSocket::kNullByte = 0x00;
26 28
27 static_assert(sizeof(struct in_addr) == 4, "incorrect system size of IPv4"); 29 static_assert(sizeof(struct in_addr) == 4, "incorrect system size of IPv4");
28 static_assert(sizeof(struct in6_addr) == 16, "incorrect system size of IPv6"); 30 static_assert(sizeof(struct in6_addr) == 16, "incorrect system size of IPv6");
29 31
30 SOCKS5ClientSocket::SOCKS5ClientSocket( 32 SOCKS5ClientSocket::SOCKS5ClientSocket(
31 scoped_ptr<ClientSocketHandle> transport_socket, 33 scoped_ptr<ClientSocketHandle> transport_socket,
32 const HostResolver::RequestInfo& req_info) 34 const HostResolver::RequestInfo& req_info)
33 : io_callback_(base::Bind(&SOCKS5ClientSocket::OnIOComplete, 35 : io_callback_(base::Bind(&SOCKS5ClientSocket::OnIOComplete,
34 base::Unretained(this))), 36 base::Unretained(this))),
35 transport_(transport_socket.Pass()), 37 transport_(std::move(transport_socket)),
36 next_state_(STATE_NONE), 38 next_state_(STATE_NONE),
37 completed_handshake_(false), 39 completed_handshake_(false),
38 bytes_sent_(0), 40 bytes_sent_(0),
39 bytes_received_(0), 41 bytes_received_(0),
40 read_header_size(kReadHeaderSize), 42 read_header_size(kReadHeaderSize),
41 was_ever_used_(false), 43 was_ever_used_(false),
42 host_request_info_(req_info), 44 host_request_info_(req_info),
43 net_log_(transport_->socket()->NetLog()) { 45 net_log_(transport_->socket()->NetLog()) {}
44 }
45 46
46 SOCKS5ClientSocket::~SOCKS5ClientSocket() { 47 SOCKS5ClientSocket::~SOCKS5ClientSocket() {
47 Disconnect(); 48 Disconnect();
48 } 49 }
49 50
50 int SOCKS5ClientSocket::Connect(const CompletionCallback& callback) { 51 int SOCKS5ClientSocket::Connect(const CompletionCallback& callback) {
51 DCHECK(transport_.get()); 52 DCHECK(transport_.get());
52 DCHECK(transport_->socket()); 53 DCHECK(transport_->socket());
53 DCHECK_EQ(STATE_NONE, next_state_); 54 DCHECK_EQ(STATE_NONE, next_state_);
54 DCHECK(user_callback_.is_null()); 55 DCHECK(user_callback_.is_null());
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 504
504 int SOCKS5ClientSocket::GetPeerAddress(IPEndPoint* address) const { 505 int SOCKS5ClientSocket::GetPeerAddress(IPEndPoint* address) const {
505 return transport_->socket()->GetPeerAddress(address); 506 return transport_->socket()->GetPeerAddress(address);
506 } 507 }
507 508
508 int SOCKS5ClientSocket::GetLocalAddress(IPEndPoint* address) const { 509 int SOCKS5ClientSocket::GetLocalAddress(IPEndPoint* address) const {
509 return transport_->socket()->GetLocalAddress(address); 510 return transport_->socket()->GetLocalAddress(address);
510 } 511 }
511 512
512 } // namespace net 513 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698