| Index: net/socket/socks5_client_socket.cc
|
| diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
|
| index 681f73f26e983f824567c7a2561d72fc10d6fe64..13565ae9c9bc9d91bbce29db8bf5de9823313d3b 100644
|
| --- a/net/socket/socks5_client_socket.cc
|
| +++ b/net/socket/socks5_client_socket.cc
|
| @@ -144,12 +144,12 @@ bool SOCKS5ClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
|
| }
|
| NOTREACHED();
|
| return false;
|
| -
|
| }
|
|
|
| // Read is called by the transport layer above to read. This can only be done
|
| // if the SOCKS handshake is complete.
|
| -int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len,
|
| +int SOCKS5ClientSocket::Read(IOBuffer* buf,
|
| + int buf_len,
|
| const CompletionCallback& callback) {
|
| DCHECK(completed_handshake_);
|
| DCHECK_EQ(STATE_NONE, next_state_);
|
| @@ -157,9 +157,11 @@ int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len,
|
| DCHECK(!callback.is_null());
|
|
|
| int rv = transport_->socket()->Read(
|
| - buf, buf_len,
|
| + buf,
|
| + buf_len,
|
| base::Bind(&SOCKS5ClientSocket::OnReadWriteComplete,
|
| - base::Unretained(this), callback));
|
| + base::Unretained(this),
|
| + callback));
|
| if (rv > 0)
|
| was_ever_used_ = true;
|
| return rv;
|
| @@ -167,7 +169,8 @@ int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len,
|
|
|
| // Write is called by the transport layer. This can only be done if the
|
| // SOCKS handshake is complete.
|
| -int SOCKS5ClientSocket::Write(IOBuffer* buf, int buf_len,
|
| +int SOCKS5ClientSocket::Write(IOBuffer* buf,
|
| + int buf_len,
|
| const CompletionCallback& callback) {
|
| DCHECK(completed_handshake_);
|
| DCHECK_EQ(STATE_NONE, next_state_);
|
| @@ -175,9 +178,11 @@ int SOCKS5ClientSocket::Write(IOBuffer* buf, int buf_len,
|
| DCHECK(!callback.is_null());
|
|
|
| int rv = transport_->socket()->Write(
|
| - buf, buf_len,
|
| + buf,
|
| + buf_len,
|
| base::Bind(&SOCKS5ClientSocket::OnReadWriteComplete,
|
| - base::Unretained(this), callback));
|
| + base::Unretained(this),
|
| + callback));
|
| if (rv > 0)
|
| was_ever_used_ = true;
|
| return rv;
|
| @@ -251,8 +256,8 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
|
| break;
|
| case STATE_HANDSHAKE_WRITE_COMPLETE:
|
| rv = DoHandshakeWriteComplete(rv);
|
| - net_log_.EndEventWithNetErrorCode(
|
| - NetLog::TYPE_SOCKS5_HANDSHAKE_WRITE, rv);
|
| + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS5_HANDSHAKE_WRITE,
|
| + rv);
|
| break;
|
| case STATE_HANDSHAKE_READ:
|
| DCHECK_EQ(OK, rv);
|
| @@ -261,8 +266,8 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
|
| break;
|
| case STATE_HANDSHAKE_READ_COMPLETE:
|
| rv = DoHandshakeReadComplete(rv);
|
| - net_log_.EndEventWithNetErrorCode(
|
| - NetLog::TYPE_SOCKS5_HANDSHAKE_READ, rv);
|
| + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS5_HANDSHAKE_READ,
|
| + rv);
|
| break;
|
| default:
|
| NOTREACHED() << "bad state";
|
| @@ -273,7 +278,7 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
|
| return rv;
|
| }
|
|
|
| -const char kSOCKS5GreetWriteData[] = { 0x05, 0x01, 0x00 }; // no authentication
|
| +const char kSOCKS5GreetWriteData[] = {0x05, 0x01, 0x00}; // no authentication
|
|
|
| int SOCKS5ClientSocket::DoGreetWrite() {
|
| // Since we only have 1 byte to send the hostname length in, if the
|
| @@ -284,18 +289,18 @@ int SOCKS5ClientSocket::DoGreetWrite() {
|
| }
|
|
|
| if (buffer_.empty()) {
|
| - buffer_ = std::string(kSOCKS5GreetWriteData,
|
| - arraysize(kSOCKS5GreetWriteData));
|
| + buffer_ =
|
| + std::string(kSOCKS5GreetWriteData, arraysize(kSOCKS5GreetWriteData));
|
| bytes_sent_ = 0;
|
| }
|
|
|
| next_state_ = STATE_GREET_WRITE_COMPLETE;
|
| size_t handshake_buf_len = buffer_.size() - bytes_sent_;
|
| handshake_buf_ = new IOBuffer(handshake_buf_len);
|
| - memcpy(handshake_buf_->data(), &buffer_.data()[bytes_sent_],
|
| - handshake_buf_len);
|
| - return transport_->socket()
|
| - ->Write(handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| + memcpy(
|
| + handshake_buf_->data(), &buffer_.data()[bytes_sent_], handshake_buf_len);
|
| + return transport_->socket()->Write(
|
| + handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| }
|
|
|
| int SOCKS5ClientSocket::DoGreetWriteComplete(int result) {
|
| @@ -317,8 +322,8 @@ int SOCKS5ClientSocket::DoGreetRead() {
|
| next_state_ = STATE_GREET_READ_COMPLETE;
|
| size_t handshake_buf_len = kGreetReadHeaderSize - bytes_received_;
|
| handshake_buf_ = new IOBuffer(handshake_buf_len);
|
| - return transport_->socket()
|
| - ->Read(handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| + return transport_->socket()->Read(
|
| + handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| }
|
|
|
| int SOCKS5ClientSocket::DoGreetReadComplete(int result) {
|
| @@ -354,21 +359,21 @@ int SOCKS5ClientSocket::DoGreetReadComplete(int result) {
|
| return OK;
|
| }
|
|
|
| -int SOCKS5ClientSocket::BuildHandshakeWriteBuffer(std::string* handshake)
|
| - const {
|
| +int SOCKS5ClientSocket::BuildHandshakeWriteBuffer(
|
| + std::string* handshake) const {
|
| DCHECK(handshake->empty());
|
|
|
| handshake->push_back(kSOCKS5Version);
|
| handshake->push_back(kTunnelCommand); // Connect command
|
| - handshake->push_back(kNullByte); // Reserved null
|
| + handshake->push_back(kNullByte); // Reserved null
|
|
|
| handshake->push_back(kEndPointDomain); // The type of the address.
|
|
|
| DCHECK_GE(static_cast<size_t>(0xFF), host_request_info_.hostname().size());
|
|
|
| // First add the size of the hostname, followed by the hostname.
|
| - handshake->push_back(static_cast<unsigned char>(
|
| - host_request_info_.hostname().size()));
|
| + handshake->push_back(
|
| + static_cast<unsigned char>(host_request_info_.hostname().size()));
|
| handshake->append(host_request_info_.hostname());
|
|
|
| uint16 nw_port = base::HostToNet16(host_request_info_.port());
|
| @@ -390,10 +395,9 @@ int SOCKS5ClientSocket::DoHandshakeWrite() {
|
| int handshake_buf_len = buffer_.size() - bytes_sent_;
|
| DCHECK_LT(0, handshake_buf_len);
|
| handshake_buf_ = new IOBuffer(handshake_buf_len);
|
| - memcpy(handshake_buf_->data(), &buffer_[bytes_sent_],
|
| - handshake_buf_len);
|
| - return transport_->socket()
|
| - ->Write(handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| + memcpy(handshake_buf_->data(), &buffer_[bytes_sent_], handshake_buf_len);
|
| + return transport_->socket()->Write(
|
| + handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| }
|
|
|
| int SOCKS5ClientSocket::DoHandshakeWriteComplete(int result) {
|
| @@ -426,8 +430,8 @@ int SOCKS5ClientSocket::DoHandshakeRead() {
|
|
|
| int handshake_buf_len = read_header_size - bytes_received_;
|
| handshake_buf_ = new IOBuffer(handshake_buf_len);
|
| - return transport_->socket()
|
| - ->Read(handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| + return transport_->socket()->Read(
|
| + handshake_buf_.get(), handshake_buf_len, io_callback_);
|
| }
|
|
|
| int SOCKS5ClientSocket::DoHandshakeReadComplete(int result) {
|
|
|