diff options
Diffstat (limited to 'remoting/protocol')
19 files changed, 72 insertions, 212 deletions
diff --git a/remoting/protocol/buffered_socket_writer.cc b/remoting/protocol/buffered_socket_writer.cc index 2edba0b..b05f467 100644 --- a/remoting/protocol/buffered_socket_writer.cc +++ b/remoting/protocol/buffered_socket_writer.cc @@ -42,8 +42,6 @@ BufferedSocketWriterBase::BufferedSocketWriterBase( socket_(NULL), message_loop_(message_loop), write_pending_(false), - ALLOW_THIS_IN_INITIALIZER_LIST( - written_callback_(this, &BufferedSocketWriterBase::OnWritten)), closed_(false) { } @@ -93,8 +91,10 @@ void BufferedSocketWriterBase::DoWrite() { if (!current_packet) return; - int result = socket_->Write(current_packet, current_packet_size, - &written_callback_); + int result = socket_->Write( + current_packet, current_packet_size, + base::Bind(&BufferedSocketWriterBase::OnWritten, + base::Unretained(this))); if (result >= 0) { base::AutoLock auto_lock(lock_); AdvanceBufferPosition_Locked(result); diff --git a/remoting/protocol/buffered_socket_writer.h b/remoting/protocol/buffered_socket_writer.h index 762e045..7bc1b09 100644 --- a/remoting/protocol/buffered_socket_writer.h +++ b/remoting/protocol/buffered_socket_writer.h @@ -99,8 +99,6 @@ class BufferedSocketWriterBase bool write_pending_; - net::OldCompletionCallbackImpl<BufferedSocketWriterBase> written_callback_; - bool closed_; }; diff --git a/remoting/protocol/fake_session.cc b/remoting/protocol/fake_session.cc index f1a890a..c43b863 100644 --- a/remoting/protocol/fake_session.cc +++ b/remoting/protocol/fake_session.cc @@ -36,32 +36,12 @@ void FakeSocket::AppendInputData(const char* data, int data_size) { memcpy(read_buffer_->data(), &(*input_data_.begin()) + input_pos_, result); input_pos_ += result; - if (old_read_callback_) - old_read_callback_->Run(result); - else - read_callback_.Run(result); + read_callback_.Run(result); read_buffer_ = NULL; } } int FakeSocket::Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - EXPECT_EQ(message_loop_, MessageLoop::current()); - if (input_pos_ < static_cast<int>(input_data_.size())) { - int result = std::min(buf_len, - static_cast<int>(input_data_.size()) - input_pos_); - memcpy(buf->data(), &(*input_data_.begin()) + input_pos_, result); - input_pos_ += result; - return result; - } else { - read_pending_ = true; - read_buffer_ = buf; - read_buffer_size_ = buf_len; - old_read_callback_ = callback; - return net::ERR_IO_PENDING; - } -} -int FakeSocket::Read(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) { EXPECT_EQ(message_loop_, MessageLoop::current()); if (input_pos_ < static_cast<int>(input_data_.size())) { @@ -80,7 +60,7 @@ int FakeSocket::Read(net::IOBuffer* buf, int buf_len, } int FakeSocket::Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { + const net::CompletionCallback& callback) { EXPECT_EQ(message_loop_, MessageLoop::current()); written_data_.insert(written_data_.end(), buf->data(), buf->data() + buf_len); @@ -96,10 +76,6 @@ bool FakeSocket::SetSendBufferSize(int32 size) { return false; } -int FakeSocket::Connect(net::OldCompletionCallback* callback) { - EXPECT_EQ(message_loop_, MessageLoop::current()); - return net::OK; -} int FakeSocket::Connect(const net::CompletionCallback& callback) { EXPECT_EQ(message_loop_, MessageLoop::current()); return net::OK; @@ -166,7 +142,6 @@ base::TimeDelta FakeSocket::GetConnectTimeMicros() const { FakeUdpSocket::FakeUdpSocket() : read_pending_(false), - old_read_callback_(NULL), input_pos_(0), message_loop_(MessageLoop::current()) { } @@ -186,32 +161,12 @@ void FakeUdpSocket::AppendInputPacket(const char* data, int data_size) { int result = std::min(data_size, read_buffer_size_); memcpy(read_buffer_->data(), data, result); input_pos_ = input_packets_.size(); - if (old_read_callback_) - old_read_callback_->Run(result); - else - old_read_callback_->Run(result); + read_callback_.Run(result); read_buffer_ = NULL; } } int FakeUdpSocket::Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - EXPECT_EQ(message_loop_, MessageLoop::current()); - if (input_pos_ < static_cast<int>(input_packets_.size())) { - int result = std::min( - buf_len, static_cast<int>(input_packets_[input_pos_].size())); - memcpy(buf->data(), &(*input_packets_[input_pos_].begin()), result); - ++input_pos_; - return result; - } else { - read_pending_ = true; - read_buffer_ = buf; - read_buffer_size_ = buf_len; - old_read_callback_ = callback; - return net::ERR_IO_PENDING; - } -} -int FakeUdpSocket::Read(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) { EXPECT_EQ(message_loop_, MessageLoop::current()); if (input_pos_ < static_cast<int>(input_packets_.size())) { @@ -230,7 +185,7 @@ int FakeUdpSocket::Read(net::IOBuffer* buf, int buf_len, } int FakeUdpSocket::Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { + const net::CompletionCallback& callback) { EXPECT_EQ(message_loop_, MessageLoop::current()); written_packets_.push_back(std::string()); written_packets_.back().assign(buf->data(), buf->data() + buf_len); diff --git a/remoting/protocol/fake_session.h b/remoting/protocol/fake_session.h index a8239f5..90fe0c8 100644 --- a/remoting/protocol/fake_session.h +++ b/remoting/protocol/fake_session.h @@ -40,17 +40,14 @@ class FakeSocket : public net::StreamSocket { // net::Socket implementation. virtual int Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; - virtual int Read(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) OVERRIDE; virtual int Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; + const net::CompletionCallback& callback) OVERRIDE; virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; virtual bool SetSendBufferSize(int32 size) OVERRIDE; // net::StreamSocket implementation. - virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; virtual void Disconnect() OVERRIDE; virtual bool IsConnected() const OVERRIDE; @@ -69,7 +66,6 @@ class FakeSocket : public net::StreamSocket { bool read_pending_; scoped_refptr<net::IOBuffer> read_buffer_; int read_buffer_size_; - net::OldCompletionCallback* old_read_callback_; net::CompletionCallback read_callback_; std::string written_data_; @@ -100,11 +96,9 @@ class FakeUdpSocket : public net::Socket { // net::Socket implementation. virtual int Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; - virtual int Read(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) OVERRIDE; virtual int Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; + const net::CompletionCallback& callback) OVERRIDE; virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; virtual bool SetSendBufferSize(int32 size) OVERRIDE; @@ -113,7 +107,6 @@ class FakeUdpSocket : public net::Socket { bool read_pending_; scoped_refptr<net::IOBuffer> read_buffer_; int read_buffer_size_; - net::OldCompletionCallback* old_read_callback_; net::CompletionCallback read_callback_; std::vector<std::string> written_packets_; diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc index 44bfc4f..72fbb8b 100644 --- a/remoting/protocol/jingle_session_unittest.cc +++ b/remoting/protocol/jingle_session_unittest.cc @@ -463,10 +463,6 @@ class TCPChannelTester : public ChannelTesterBase { int message_size, int message_count) : ChannelTesterBase(host_session, client_session), - ALLOW_THIS_IN_INITIALIZER_LIST( - write_cb_(this, &TCPChannelTester::OnWritten)), - ALLOW_THIS_IN_INITIALIZER_LIST( - read_cb_(this, &TCPChannelTester::OnRead)), write_errors_(0), read_errors_(0), message_size_(message_size), @@ -540,7 +536,9 @@ class TCPChannelTester : public ChannelTesterBase { break; int bytes_to_write = std::min(output_buffer_->BytesRemaining(), message_size_); - result = sockets_[0]->Write(output_buffer_, bytes_to_write, &write_cb_); + result = sockets_[0]->Write(output_buffer_, bytes_to_write, + base::Bind(&TCPChannelTester::OnWritten, + base::Unretained(this))); HandleWriteResult(result); }; } @@ -564,7 +562,9 @@ class TCPChannelTester : public ChannelTesterBase { int result = 1; while (result > 0) { input_buffer_->SetCapacity(input_buffer_->offset() + message_size_); - result = sockets_[1]->Read(input_buffer_, message_size_, &read_cb_); + result = sockets_[1]->Read(input_buffer_, message_size_, + base::Bind(&TCPChannelTester::OnRead, + base::Unretained(this))); HandleReadResult(result); }; } @@ -593,8 +593,6 @@ class TCPChannelTester : public ChannelTesterBase { scoped_refptr<net::DrainableIOBuffer> output_buffer_; scoped_refptr<net::GrowableIOBuffer> input_buffer_; - net::OldCompletionCallbackImpl<TCPChannelTester> write_cb_; - net::OldCompletionCallbackImpl<TCPChannelTester> read_cb_; int write_errors_; int read_errors_; int message_size_; @@ -635,10 +633,6 @@ class UDPChannelTester : public ChannelTesterBase { UDPChannelTester(Session* host_session, Session* client_session) : ChannelTesterBase(host_session, client_session), - ALLOW_THIS_IN_INITIALIZER_LIST( - write_cb_(this, &UDPChannelTester::OnWritten)), - ALLOW_THIS_IN_INITIALIZER_LIST( - read_cb_(this, &UDPChannelTester::OnRead)), write_errors_(0), read_errors_(0), packets_sent_(0), @@ -705,7 +699,9 @@ class UDPChannelTester : public ChannelTesterBase { // Put index of this packet in the beginning of the packet body. memcpy(packet->data(), &packets_sent_, sizeof(packets_sent_)); - int result = sockets_[0]->Write(packet, kMessageSize, &write_cb_); + int result = sockets_[0]->Write(packet, kMessageSize, + base::Bind(&UDPChannelTester::OnWritten, + base::Unretained(this))); HandleWriteResult(result); } @@ -733,7 +729,9 @@ class UDPChannelTester : public ChannelTesterBase { int kReadSize = kMessageSize * 2; read_buffer_ = new net::IOBuffer(kReadSize); - result = sockets_[1]->Read(read_buffer_, kReadSize, &read_cb_); + result = sockets_[1]->Read(read_buffer_, kReadSize, + base::Bind(&UDPChannelTester::OnRead, + base::Unretained(this))); HandleReadResult(result); }; } @@ -775,8 +773,6 @@ class UDPChannelTester : public ChannelTesterBase { scoped_refptr<net::IOBuffer> sent_packets_[kMessages]; scoped_refptr<net::IOBuffer> read_buffer_; - net::OldCompletionCallbackImpl<UDPChannelTester> write_cb_; - net::OldCompletionCallbackImpl<UDPChannelTester> read_cb_; int write_errors_; int read_errors_; int packets_sent_; diff --git a/remoting/protocol/jingle_stream_connector.cc b/remoting/protocol/jingle_stream_connector.cc index 4eab85e..d7ce7fa 100644 --- a/remoting/protocol/jingle_stream_connector.cc +++ b/remoting/protocol/jingle_stream_connector.cc @@ -41,9 +41,7 @@ JingleStreamConnector::JingleStreamConnector( : session_(session), name_(name), callback_(callback), - raw_channel_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(tcp_connect_callback_( - this, &JingleStreamConnector::OnTCPConnect)) { + raw_channel_(NULL) { } JingleStreamConnector::~JingleStreamConnector() { @@ -83,11 +81,13 @@ bool JingleStreamConnector::EstablishTCPConnection(net::Socket* socket) { adapter->SetSendBufferSize(kTcpSendBufferSize); tcp_socket_.reset(adapter); - int result = tcp_socket_->Connect(&tcp_connect_callback_); + int result = tcp_socket_->Connect( + base::Bind(&JingleStreamConnector::OnTCPConnect, + base::Unretained(this))); if (result == net::ERR_IO_PENDING) { return true; } else if (result == net::OK) { - tcp_connect_callback_.Run(result); + OnTCPConnect(result); return true; } diff --git a/remoting/protocol/jingle_stream_connector.h b/remoting/protocol/jingle_stream_connector.h index f37a691..1dd0240b 100644 --- a/remoting/protocol/jingle_stream_connector.h +++ b/remoting/protocol/jingle_stream_connector.h @@ -63,9 +63,6 @@ class JingleStreamConnector : public JingleChannelConnector { scoped_ptr<ChannelAuthenticator> authenticator_; - // Callback called by the TCP and SSL layers. - net::OldCompletionCallbackImpl<JingleStreamConnector> tcp_connect_callback_; - DISALLOW_COPY_AND_ASSIGN(JingleStreamConnector); }; diff --git a/remoting/protocol/message_reader.cc b/remoting/protocol/message_reader.cc index 82a3c80..d52448d 100644 --- a/remoting/protocol/message_reader.cc +++ b/remoting/protocol/message_reader.cc @@ -22,9 +22,7 @@ MessageReader::MessageReader() : socket_(NULL), read_pending_(false), pending_messages_(0), - closed_(false), - ALLOW_THIS_IN_INITIALIZER_LIST( - read_callback_(this, &MessageReader::OnRead)) { + closed_(false) { } MessageReader::~MessageReader() { @@ -45,7 +43,8 @@ void MessageReader::DoRead() { while (!closed_ && !read_pending_ && pending_messages_ == 0) { read_buffer_ = new net::IOBuffer(kReadBufferSize); int result = socket_->Read( - read_buffer_, kReadBufferSize, &read_callback_); + read_buffer_, kReadBufferSize, base::Bind(&MessageReader::OnRead, + base::Unretained(this))); HandleReadResult(result); } } diff --git a/remoting/protocol/message_reader.h b/remoting/protocol/message_reader.h index fb89f91..3c33b5a 100644 --- a/remoting/protocol/message_reader.h +++ b/remoting/protocol/message_reader.h @@ -73,7 +73,6 @@ class MessageReader : public base::RefCountedThreadSafe<MessageReader> { bool closed_; scoped_refptr<net::IOBuffer> read_buffer_; - net::OldCompletionCallbackImpl<MessageReader> read_callback_; MessageDecoder message_decoder_; diff --git a/remoting/protocol/pepper_stream_channel.cc b/remoting/protocol/pepper_stream_channel.cc index e51d265..48d3a33 100644 --- a/remoting/protocol/pepper_stream_channel.cc +++ b/remoting/protocol/pepper_stream_channel.cc @@ -45,9 +45,7 @@ PepperStreamChannel::PepperStreamChannel( name_(name), callback_(callback), channel_(NULL), - connected_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(p2p_connect_callback_( - this, &PepperStreamChannel::OnP2PConnect)) { + connected_(false) { } PepperStreamChannel::~PepperStreamChannel() { @@ -122,7 +120,8 @@ void PepperStreamChannel::Connect(pp::Instance* pp_instance, channel_ = new PepperTransportSocketAdapter(transport, name_, this); owned_channel_.reset(channel_); - int result = channel_->Connect(&p2p_connect_callback_); + int result = channel_->Connect(base::Bind(&PepperStreamChannel::OnP2PConnect, + base::Unretained(this))); if (result != net::ERR_IO_PENDING) OnP2PConnect(result); } diff --git a/remoting/protocol/pepper_stream_channel.h b/remoting/protocol/pepper_stream_channel.h index 5c17e4f..ead43e9 100644 --- a/remoting/protocol/pepper_stream_channel.h +++ b/remoting/protocol/pepper_stream_channel.h @@ -67,9 +67,6 @@ class PepperStreamChannel : public PepperChannel, // Indicates that we've finished connecting. bool connected_; - // Callback called by the TCP layer. - net::OldCompletionCallbackImpl<PepperStreamChannel> p2p_connect_callback_; - DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); }; diff --git a/remoting/protocol/pepper_transport_socket_adapter.cc b/remoting/protocol/pepper_transport_socket_adapter.cc index 0385b9b..ca1c470 100644 --- a/remoting/protocol/pepper_transport_socket_adapter.cc +++ b/remoting/protocol/pepper_transport_socket_adapter.cc @@ -48,9 +48,7 @@ PepperTransportSocketAdapter::PepperTransportSocketAdapter( observer_(observer), transport_(transport), connected_(false), - get_address_pending_(false), - old_read_callback_(NULL), - write_callback_(NULL) { + get_address_pending_(false) { callback_factory_.Initialize(this); } @@ -65,32 +63,11 @@ void PepperTransportSocketAdapter::AddRemoteCandidate( transport_->ReceiveRemoteAddress(candidate); } -int PepperTransportSocketAdapter::Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - DCHECK(CalledOnValidThread()); - DCHECK(!old_read_callback_ && read_callback_.is_null()); - DCHECK(!read_buffer_); - - if (!transport_.get()) - return net::ERR_SOCKET_NOT_CONNECTED; - - int result = PPErrorToNetError(transport_->Recv( - buf->data(), buf_len, - callback_factory_.NewOptionalCallback( - &PepperTransportSocketAdapter::OnRead))); - - if (result == net::ERR_IO_PENDING) { - old_read_callback_ = callback; - read_buffer_ = buf; - } - - return result; -} int PepperTransportSocketAdapter::Read( net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) { DCHECK(CalledOnValidThread()); - DCHECK(!old_read_callback_ && read_callback_.is_null()); + DCHECK(read_callback_.is_null()); DCHECK(!read_buffer_); if (!transport_.get()) @@ -109,10 +86,11 @@ int PepperTransportSocketAdapter::Read( return result; } -int PepperTransportSocketAdapter::Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { +int PepperTransportSocketAdapter::Write( + net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback) { DCHECK(CalledOnValidThread()); - DCHECK(!write_callback_); + DCHECK(write_callback_.is_null()); DCHECK(!write_buffer_); if (!transport_.get()) @@ -146,29 +124,6 @@ bool PepperTransportSocketAdapter::SetSendBufferSize(int32 size) { } int PepperTransportSocketAdapter::Connect( - net::OldCompletionCallback* callback) { - DCHECK(CalledOnValidThread()); - - if (!transport_.get()) - return net::ERR_UNEXPECTED; - - old_connect_callback_ = callback; - - // This will return false when GetNextAddress() returns an - // error. This helps to detect when the P2P Transport API is not - // supported. - int result = ProcessCandidates(); - if (result != net::OK) - return result; - - result = transport_->Connect( - callback_factory_.NewRequiredCallback( - &PepperTransportSocketAdapter::OnConnect)); - DCHECK_EQ(result, PP_OK_COMPLETIONPENDING); - - return net::ERR_IO_PENDING; -} -int PepperTransportSocketAdapter::Connect( const net::CompletionCallback& callback) { DCHECK(CalledOnValidThread()); @@ -300,49 +255,36 @@ void PepperTransportSocketAdapter::OnNextAddress(int32_t result) { void PepperTransportSocketAdapter::OnConnect(int result) { DCHECK(CalledOnValidThread()); - DCHECK(old_connect_callback_ || !connect_callback_.is_null()); + DCHECK(!connect_callback_.is_null()); if (result == PP_OK) connected_ = true; - if (old_connect_callback_) { - net::OldCompletionCallback* callback = old_connect_callback_; - old_connect_callback_ = NULL; - callback->Run(PPErrorToNetError(result)); - } else { - net::CompletionCallback callback = connect_callback_; - connect_callback_.Reset(); - callback.Run(PPErrorToNetError(result)); - } + net::CompletionCallback callback = connect_callback_; + connect_callback_.Reset(); + callback.Run(PPErrorToNetError(result)); } void PepperTransportSocketAdapter::OnRead(int32_t result) { DCHECK(CalledOnValidThread()); - DCHECK(old_read_callback_ || read_callback_.is_null()); + DCHECK(!read_callback_.is_null()); DCHECK(read_buffer_); - if (old_read_callback_) { - net::OldCompletionCallback* callback = old_read_callback_; - old_read_callback_ = NULL; - read_buffer_ = NULL; - callback->Run(PPErrorToNetError(result)); - } else { - net::CompletionCallback callback = read_callback_; - read_callback_.Reset(); - read_buffer_ = NULL; - callback.Run(PPErrorToNetError(result)); - } + net::CompletionCallback callback = read_callback_; + read_callback_.Reset(); + read_buffer_ = NULL; + callback.Run(PPErrorToNetError(result)); } void PepperTransportSocketAdapter::OnWrite(int32_t result) { DCHECK(CalledOnValidThread()); - DCHECK(write_callback_); + DCHECK(!write_callback_.is_null()); DCHECK(write_buffer_); - net::OldCompletionCallback* callback = write_callback_; - write_callback_ = NULL; + net::CompletionCallback callback = write_callback_; + write_callback_.Reset(); write_buffer_ = NULL; - callback->Run(PPErrorToNetError(result)); + callback.Run(PPErrorToNetError(result)); } } // namespace protocol diff --git a/remoting/protocol/pepper_transport_socket_adapter.h b/remoting/protocol/pepper_transport_socket_adapter.h index 40b75ce..bd84bb8 100644 --- a/remoting/protocol/pepper_transport_socket_adapter.h +++ b/remoting/protocol/pepper_transport_socket_adapter.h @@ -50,16 +50,13 @@ class PepperTransportSocketAdapter : public base::NonThreadSafe, // net::Socket implementation. virtual int Read(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; - virtual int Read(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) OVERRIDE; virtual int Write(net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) OVERRIDE; + const net::CompletionCallback& callback) OVERRIDE; virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; virtual bool SetSendBufferSize(int32 size) OVERRIDE; // net::StreamSocket implementation. - virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE; virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; virtual void Disconnect() OVERRIDE; virtual bool IsConnected() const OVERRIDE; @@ -88,17 +85,15 @@ class PepperTransportSocketAdapter : public base::NonThreadSafe, scoped_ptr<pp::Transport_Dev> transport_; - net::OldCompletionCallback* old_connect_callback_; net::CompletionCallback connect_callback_; bool connected_; bool get_address_pending_; - net::OldCompletionCallback* old_read_callback_; net::CompletionCallback read_callback_; scoped_refptr<net::IOBuffer> read_buffer_; - net::OldCompletionCallback* write_callback_; + net::CompletionCallback write_callback_; scoped_refptr<net::IOBuffer> write_buffer_; net::BoundNetLog net_log_; diff --git a/remoting/protocol/socket_reader_base.cc b/remoting/protocol/socket_reader_base.cc index 743120d..bb315db 100644 --- a/remoting/protocol/socket_reader_base.cc +++ b/remoting/protocol/socket_reader_base.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,9 +17,7 @@ int kReadBufferSize = 4096; SocketReaderBase::SocketReaderBase() : socket_(NULL), - closed_(false), - ALLOW_THIS_IN_INITIALIZER_LIST( - read_callback_(this, &SocketReaderBase::OnRead)) { + closed_(false) { } SocketReaderBase::~SocketReaderBase() { } @@ -34,7 +32,8 @@ void SocketReaderBase::DoRead() { while (true) { read_buffer_ = new net::IOBuffer(kReadBufferSize); int result = socket_->Read( - read_buffer_, kReadBufferSize, &read_callback_); + read_buffer_, kReadBufferSize, base::Bind(&SocketReaderBase::OnRead, + base::Unretained(this))); HandleReadResult(result); if (result < 0) break; diff --git a/remoting/protocol/socket_reader_base.h b/remoting/protocol/socket_reader_base.h index a315217..3877f13 100644 --- a/remoting/protocol/socket_reader_base.h +++ b/remoting/protocol/socket_reader_base.h @@ -32,7 +32,6 @@ class SocketReaderBase { net::Socket* socket_; bool closed_; scoped_refptr<net::IOBuffer> read_buffer_; - net::OldCompletionCallbackImpl<SocketReaderBase> read_callback_; }; } // namespace remoting diff --git a/remoting/protocol/v1_client_channel_authenticator.cc b/remoting/protocol/v1_client_channel_authenticator.cc index 312403b..1f995fc 100644 --- a/remoting/protocol/v1_client_channel_authenticator.cc +++ b/remoting/protocol/v1_client_channel_authenticator.cc @@ -21,11 +21,7 @@ V1ClientChannelAuthenticator::V1ClientChannelAuthenticator( const std::string& shared_secret) : host_cert_(host_cert), shared_secret_(shared_secret), - socket_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( - this, &V1ClientChannelAuthenticator::OnConnected)), - ALLOW_THIS_IN_INITIALIZER_LIST(auth_write_callback_( - this, &V1ClientChannelAuthenticator::OnAuthBytesWritten)) { + socket_(NULL) { } V1ClientChannelAuthenticator::~V1ClientChannelAuthenticator() { @@ -59,7 +55,9 @@ void V1ClientChannelAuthenticator::SecureAndAuthenticate( net::ClientSocketFactory::GetDefaultFactory()->CreateSSLClientSocket( socket, host_and_port, ssl_config, NULL, context)); - int result = socket_->Connect(&connect_callback_); + int result = socket_->Connect( + base::Bind(&V1ClientChannelAuthenticator::OnConnected, + base::Unretained(this))); if (result == net::ERR_IO_PENDING) return; OnConnected(result); @@ -99,9 +97,10 @@ void V1ClientChannelAuthenticator::OnConnected(int result) { void V1ClientChannelAuthenticator::WriteAuthenticationBytes() { while (true) { - int result = socket_->Write(auth_write_buf_, - auth_write_buf_->BytesRemaining(), - &auth_write_callback_); + int result = socket_->Write( + auth_write_buf_, auth_write_buf_->BytesRemaining(), + base::Bind(&V1ClientChannelAuthenticator::OnAuthBytesWritten, + base::Unretained(this))); if (result == net::ERR_IO_PENDING) break; if (!HandleAuthBytesWritten(result)) diff --git a/remoting/protocol/v1_client_channel_authenticator.h b/remoting/protocol/v1_client_channel_authenticator.h index d8b2659..fcf4e89 100644 --- a/remoting/protocol/v1_client_channel_authenticator.h +++ b/remoting/protocol/v1_client_channel_authenticator.h @@ -49,11 +49,6 @@ class V1ClientChannelAuthenticator : public ChannelAuthenticator, scoped_ptr<net::CertVerifier> cert_verifier_; scoped_refptr<net::DrainableIOBuffer> auth_write_buf_; - net::OldCompletionCallbackImpl<V1ClientChannelAuthenticator> - connect_callback_; - net::OldCompletionCallbackImpl<V1ClientChannelAuthenticator> - auth_write_callback_; - DISALLOW_COPY_AND_ASSIGN(V1ClientChannelAuthenticator); }; diff --git a/remoting/protocol/v1_host_channel_authenticator.cc b/remoting/protocol/v1_host_channel_authenticator.cc index c124d47..c27340b 100644 --- a/remoting/protocol/v1_host_channel_authenticator.cc +++ b/remoting/protocol/v1_host_channel_authenticator.cc @@ -25,9 +25,7 @@ V1HostChannelAuthenticator::V1HostChannelAuthenticator( shared_secret_(shared_secret), socket_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( - this, &V1HostChannelAuthenticator::OnConnected)), - ALLOW_THIS_IN_INITIALIZER_LIST(auth_read_callback_( - this, &V1HostChannelAuthenticator::OnAuthBytesRead)) { + this, &V1HostChannelAuthenticator::OnConnected)) { } V1HostChannelAuthenticator::~V1HostChannelAuthenticator() { @@ -74,9 +72,11 @@ void V1HostChannelAuthenticator::OnConnected(int result) { void V1HostChannelAuthenticator::DoAuthRead(){ while (true) { - int result = socket_->Read(auth_read_buf_, - auth_read_buf_->RemainingCapacity(), - &auth_read_callback_); + int result = socket_->Read( + auth_read_buf_, + auth_read_buf_->RemainingCapacity(), + base::Bind(&V1HostChannelAuthenticator::OnAuthBytesRead, + base::Unretained(this))); if (result == net::ERR_IO_PENDING) break; if (!HandleAuthBytesRead(result)) diff --git a/remoting/protocol/v1_host_channel_authenticator.h b/remoting/protocol/v1_host_channel_authenticator.h index 081eff7..7820fae 100644 --- a/remoting/protocol/v1_host_channel_authenticator.h +++ b/remoting/protocol/v1_host_channel_authenticator.h @@ -55,8 +55,6 @@ class V1HostChannelAuthenticator : public ChannelAuthenticator, net::OldCompletionCallbackImpl<V1HostChannelAuthenticator> connect_callback_; - net::OldCompletionCallbackImpl<V1HostChannelAuthenticator> - auth_read_callback_; DISALLOW_COPY_AND_ASSIGN(V1HostChannelAuthenticator); }; |