diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-26 00:55:13 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-26 00:55:13 +0000 |
commit | 70774c27b2ceba320fd579b964da7c27c2ae807c (patch) | |
tree | b91dc1fa91a9a961cc97ed060bf70715cdbdad45 /remoting/protocol | |
parent | 24d2b17dff7c4044839e1b5abd5baf83f4eb3b1d (diff) | |
download | chromium_src-70774c27b2ceba320fd579b964da7c27c2ae807c.zip chromium_src-70774c27b2ceba320fd579b964da7c27c2ae807c.tar.gz chromium_src-70774c27b2ceba320fd579b964da7c27c2ae807c.tar.bz2 |
Remove Pepper Transport API transport.
BUG=109630
Review URL: https://chromiumcodereview.appspot.com/10442040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 2 | ||||
-rw-r--r-- | remoting/protocol/pepper_transport_factory.cc | 299 | ||||
-rw-r--r-- | remoting/protocol/pepper_transport_factory.h | 38 | ||||
-rw-r--r-- | remoting/protocol/pepper_transport_socket_adapter.cc | 295 | ||||
-rw-r--r-- | remoting/protocol/pepper_transport_socket_adapter.h | 110 |
5 files changed, 1 insertions, 743 deletions
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 970bcaa..93c722a 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -18,7 +18,7 @@ #include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/errors.h" #include "remoting/protocol/jingle_session_manager.h" -#include "remoting/protocol/pepper_transport_factory.h" +#include "remoting/protocol/transport.h" #include "remoting/protocol/video_reader.h" #include "remoting/protocol/video_stub.h" #include "remoting/protocol/util.h" diff --git a/remoting/protocol/pepper_transport_factory.cc b/remoting/protocol/pepper_transport_factory.cc deleted file mode 100644 index 315981a..0000000 --- a/remoting/protocol/pepper_transport_factory.cc +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright (c) 2012 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. - -#include "remoting/protocol/pepper_transport_factory.h" - -#include "base/bind.h" -#include "crypto/hmac.h" -#include "jingle/glue/utils.h" -#include "net/base/cert_status_flags.h" -#include "net/base/cert_verifier.h" -#include "net/base/host_port_pair.h" -#include "net/base/ssl_config_service.h" -#include "net/socket/ssl_client_socket.h" -#include "net/socket/client_socket_factory.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/dev/transport_dev.h" -#include "ppapi/cpp/var.h" -#include "remoting/protocol/channel_authenticator.h" -#include "remoting/protocol/pepper_transport_socket_adapter.h" -#include "remoting/protocol/transport_config.h" -#include "third_party/libjingle/source/talk/p2p/base/candidate.h" - -namespace remoting { -namespace protocol { - -namespace { - -// Value is choosen to balance the extra latency against the reduced -// load due to ACK traffic. -const int kTcpAckDelayMilliseconds = 10; - -// Values for the TCP send and receive buffer size. This should be tuned to -// accomodate high latency network but not backlog the decoding pipeline. -const int kTcpReceiveBufferSize = 256 * 1024; -const int kTcpSendBufferSize = kTcpReceiveBufferSize + 30 * 1024; - -class PepperStreamTransport : public StreamTransport, - public PepperTransportSocketAdapter::Observer { - public: - PepperStreamTransport(pp::Instance* pp_instance, - const TransportConfig& config); - virtual ~PepperStreamTransport(); - - // StreamTransport interface. - virtual void Initialize( - const std::string& name, - Transport::EventHandler* event_handler, - scoped_ptr<ChannelAuthenticator> authenticator) OVERRIDE; - virtual void Connect( - const StreamTransport::ConnectedCallback& callback) OVERRIDE; - virtual void AddRemoteCandidate(const cricket::Candidate& candidate) OVERRIDE; - virtual const std::string& name() const OVERRIDE; - virtual bool is_connected() const OVERRIDE; - - // PepperTransportSocketAdapter::Observer interface. - virtual void OnChannelDeleted() OVERRIDE; - virtual void OnChannelNewLocalCandidate( - const std::string& candidate) OVERRIDE; - - private: - void OnP2PConnect(int result); - void OnAuthenticationDone(net::Error error, - scoped_ptr<net::StreamSocket> socket); - - void NotifyConnected(scoped_ptr<net::StreamSocket> socket); - void NotifyConnectFailed(); - - pp::Instance* pp_instance_; - TransportConfig config_; - std::string name_; - EventHandler* event_handler_; - StreamTransport::ConnectedCallback callback_; - scoped_ptr<ChannelAuthenticator> authenticator_; - - // We own |channel_| until it is connected. After that - // |authenticator_| owns it. - scoped_ptr<PepperTransportSocketAdapter> owned_channel_; - PepperTransportSocketAdapter* channel_; - - // Indicates that we've finished connecting. - bool connected_; - - DISALLOW_COPY_AND_ASSIGN(PepperStreamTransport); -}; - -PepperStreamTransport::PepperStreamTransport(pp::Instance* pp_instance, - const TransportConfig& config) - : pp_instance_(pp_instance), - config_(config), - event_handler_(NULL), - channel_(NULL), - connected_(false) { -} - -PepperStreamTransport::~PepperStreamTransport() { - DCHECK(event_handler_); - event_handler_->OnTransportDeleted(this); - // Channel should be already destroyed if we were connected. - DCHECK(!connected_ || channel_ == NULL); -} - -void PepperStreamTransport::Initialize( - const std::string& name, - Transport::EventHandler* event_handler, - scoped_ptr<ChannelAuthenticator> authenticator) { - DCHECK(CalledOnValidThread()); - - DCHECK(!name.empty()); - DCHECK(event_handler); - - // Can be initialized only once. - DCHECK(name_.empty()); - - name_ = name; - event_handler_ = event_handler; - authenticator_ = authenticator.Pass(); -} - -void PepperStreamTransport::Connect( - const StreamTransport::ConnectedCallback& callback) { - DCHECK(CalledOnValidThread()); - - // Initialize() must be called first. - DCHECK(!name_.empty()); - - callback_ = callback; - - pp::Transport_Dev* transport = - new pp::Transport_Dev(pp_instance_, name_.c_str(), - PP_TRANSPORTTYPE_STREAM); - - if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_RECEIVE_WINDOW, - pp::Var(kTcpReceiveBufferSize)) != PP_OK) { - LOG(ERROR) << "Failed to set TCP receive window"; - } - if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW, - pp::Var(kTcpSendBufferSize)) != PP_OK) { - LOG(ERROR) << "Failed to set TCP send window"; - } - - if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_NO_DELAY, - pp::Var(true)) != PP_OK) { - LOG(ERROR) << "Failed to set TCP_NODELAY"; - } - - if (transport->SetProperty(PP_TRANSPORTPROPERTY_TCP_ACK_DELAY, - pp::Var(kTcpAckDelayMilliseconds)) != PP_OK) { - LOG(ERROR) << "Failed to set TCP ACK delay."; - } - - if (transport->SetProperty( - PP_TRANSPORTPROPERTY_STUN_SERVER, - pp::Var(config_.stun_server)) != PP_OK) { - LOG(ERROR) << "Failed to set STUN server."; - } - - if (transport->SetProperty( - PP_TRANSPORTPROPERTY_RELAY_SERVER, - pp::Var(config_.relay_server)) != PP_OK) { - LOG(ERROR) << "Failed to set relay server."; - } - - if (transport->SetProperty( - PP_TRANSPORTPROPERTY_RELAY_USERNAME, - pp::Var("1")) != PP_OK) { - LOG(ERROR) << "Failed to set relay username."; - } - - if (transport->SetProperty( - PP_TRANSPORTPROPERTY_RELAY_PASSWORD, - pp::Var(config_.relay_token)) != PP_OK) { - LOG(ERROR) << "Failed to set relay token."; - } - - if (transport->SetProperty( - PP_TRANSPORTPROPERTY_RELAY_MODE, - pp::Var(PP_TRANSPORTRELAYMODE_GOOGLE)) != PP_OK) { - LOG(ERROR) << "Failed to set relay mode."; - } - - if (transport->SetProperty(PP_TRANSPORTPROPERTY_DISABLE_TCP_TRANSPORT, - pp::Var(true)) != PP_OK) { - LOG(ERROR) << "Failed to set DISABLE_TCP_TRANSPORT flag."; - } - - channel_ = new PepperTransportSocketAdapter(transport, name_, this); - owned_channel_.reset(channel_); - - int result = channel_->Connect( - base::Bind(&PepperStreamTransport::OnP2PConnect, base::Unretained(this))); - if (result != net::ERR_IO_PENDING) - OnP2PConnect(result); -} - -void PepperStreamTransport::AddRemoteCandidate( - const cricket::Candidate& candidate) { - DCHECK(CalledOnValidThread()); - if (channel_) - channel_->AddRemoteCandidate(jingle_glue::SerializeP2PCandidate(candidate)); -} - -const std::string& PepperStreamTransport::name() const { - DCHECK(CalledOnValidThread()); - return name_; -} - -bool PepperStreamTransport::is_connected() const { - DCHECK(CalledOnValidThread()); - return connected_; -} - -void PepperStreamTransport::OnChannelDeleted() { - if (connected_) { - channel_ = NULL; - // The PepperTransportSocketAdapter is being deleted, so delete - // the channel too. - delete this; - } -} - -void PepperStreamTransport::OnChannelNewLocalCandidate( - const std::string& candidate) { - DCHECK(CalledOnValidThread()); - - cricket::Candidate candidate_value; - if (!jingle_glue::DeserializeP2PCandidate(candidate, &candidate_value)) { - LOG(ERROR) << "Failed to parse candidate " << candidate; - } - event_handler_->OnTransportCandidate(this, candidate_value); -} - -void PepperStreamTransport::OnP2PConnect(int result) { - DCHECK(CalledOnValidThread()); - - if (result != net::OK) { - NotifyConnectFailed(); - return; - } - - authenticator_->SecureAndAuthenticate( - owned_channel_.PassAs<net::StreamSocket>(), - base::Bind(&PepperStreamTransport::OnAuthenticationDone, - base::Unretained(this))); -} - -void PepperStreamTransport::OnAuthenticationDone( - net::Error error, scoped_ptr<net::StreamSocket> socket) { - DCHECK(CalledOnValidThread()); - if (error != net::OK) { - NotifyConnectFailed(); - return; - } - - NotifyConnected(socket.Pass()); -} - -void PepperStreamTransport::NotifyConnected( - scoped_ptr<net::StreamSocket> socket) { - DCHECK(!connected_); - connected_ = true; - callback_.Run(socket.Pass()); -} - -void PepperStreamTransport::NotifyConnectFailed() { - channel_ = NULL; - owned_channel_.reset(); - authenticator_.reset(); - - NotifyConnected(scoped_ptr<net::StreamSocket>(NULL)); -} - -} // namespace - -PepperTransportFactory::PepperTransportFactory( - pp::Instance* pp_instance) - : pp_instance_(pp_instance) { -} - -PepperTransportFactory::~PepperTransportFactory() { -} - -void PepperTransportFactory::SetTransportConfig(const TransportConfig& config) { - config_ = config; -} - -scoped_ptr<StreamTransport> PepperTransportFactory::CreateStreamTransport() { - return scoped_ptr<StreamTransport>( - new PepperStreamTransport(pp_instance_, config_)); -} - -scoped_ptr<DatagramTransport> -PepperTransportFactory::CreateDatagramTransport() { - NOTIMPLEMENTED(); - return scoped_ptr<DatagramTransport>(NULL); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/pepper_transport_factory.h b/remoting/protocol/pepper_transport_factory.h deleted file mode 100644 index 4678df9..0000000 --- a/remoting/protocol/pepper_transport_factory.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef REMOTING_PROTOCOL_PEPPER_TRANSPORT_FACTORY_H_ -#define REMOTING_PROTOCOL_PEPPER_TRANSPORT_FACTORY_H_ - -#include "remoting/protocol/transport.h" -#include "remoting/protocol/transport_config.h" - -namespace pp { -class Instance; -} // namespace pp - -namespace remoting { -namespace protocol { - -class PepperTransportFactory : public TransportFactory { - public: - PepperTransportFactory(pp::Instance* pp_instance); - virtual ~PepperTransportFactory(); - - // TransportFactory interface. - virtual void SetTransportConfig(const TransportConfig& config) OVERRIDE; - virtual scoped_ptr<StreamTransport> CreateStreamTransport() OVERRIDE; - virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() OVERRIDE; - - private: - pp::Instance* pp_instance_; - TransportConfig config_; - - DISALLOW_COPY_AND_ASSIGN(PepperTransportFactory); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PEPPER_TRANSPORT_FACTORY_H_ diff --git a/remoting/protocol/pepper_transport_socket_adapter.cc b/remoting/protocol/pepper_transport_socket_adapter.cc deleted file mode 100644 index e4e47d5..0000000 --- a/remoting/protocol/pepper_transport_socket_adapter.cc +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) 2012 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. - -#include "remoting/protocol/pepper_transport_socket_adapter.h" - -#include "base/logging.h" -#include "net/base/address_list.h" -#include "net/base/io_buffer.h" -#include "net/base/net_errors.h" -#include "net/base/net_util.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/dev/transport_dev.h" -#include "ppapi/cpp/var.h" - -namespace remoting { -namespace protocol { - -namespace { - -const char kTcpProtocol[] = "tcp"; - -// Maps value returned by Recv() and Send() Pepper methods to net::Error. -int PPErrorToNetError(int result) { - if (result > 0) - return result; - - switch (result) { - case PP_OK: - return net::OK; - case PP_OK_COMPLETIONPENDING: - return net::ERR_IO_PENDING; - case PP_ERROR_NOTSUPPORTED: - case PP_ERROR_NOINTERFACE: - return net::ERR_NOT_IMPLEMENTED; - default: - return net::ERR_FAILED; - } -} - -} // namespace - -PepperTransportSocketAdapter::PepperTransportSocketAdapter( - pp::Transport_Dev* transport, - const std::string& name, - Observer* observer) - : name_(name), - observer_(observer), - transport_(transport), - connected_(false), - get_address_pending_(false) { - callback_factory_.Initialize(this); -} - -PepperTransportSocketAdapter::~PepperTransportSocketAdapter() { - observer_->OnChannelDeleted(); -} - -void PepperTransportSocketAdapter::AddRemoteCandidate( - const std::string& candidate) { - DCHECK(CalledOnValidThread()); - if (transport_.get()) - transport_->ReceiveRemoteAddress(candidate); -} - -int PepperTransportSocketAdapter::Read( - net::IOBuffer* buf, int buf_len, - const net::CompletionCallback& callback) { - DCHECK(CalledOnValidThread()); - DCHECK(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) { - read_callback_ = callback; - read_buffer_ = buf; - } - - return result; -} - -int PepperTransportSocketAdapter::Write( - net::IOBuffer* buf, int buf_len, - const net::CompletionCallback& callback) { - DCHECK(CalledOnValidThread()); - DCHECK(write_callback_.is_null()); - DCHECK(!write_buffer_); - - if (!transport_.get()) - return net::ERR_SOCKET_NOT_CONNECTED; - - int result = PPErrorToNetError(transport_->Send( - buf->data(), buf_len, - callback_factory_.NewOptionalCallback( - &PepperTransportSocketAdapter::OnWrite))); - - if (result == net::ERR_IO_PENDING) { - write_callback_ = callback; - write_buffer_ = buf; - } - - return result; -} - -bool PepperTransportSocketAdapter::SetReceiveBufferSize(int32 size) { - DCHECK(CalledOnValidThread()); - // TODO(sergeyu): Implement this: crbug.com/91439. - NOTIMPLEMENTED(); - return false; -} - -bool PepperTransportSocketAdapter::SetSendBufferSize(int32 size) { - DCHECK(CalledOnValidThread()); - // TODO(sergeyu): Implement this: crbug.com/91439. - NOTIMPLEMENTED(); - return false; -} - -int PepperTransportSocketAdapter::Connect( - const net::CompletionCallback& callback) { - DCHECK(CalledOnValidThread()); - - if (!transport_.get()) - return net::ERR_UNEXPECTED; - - 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_.NewCallback(&PepperTransportSocketAdapter::OnConnect)); - DCHECK_EQ(result, PP_OK_COMPLETIONPENDING); - - return net::ERR_IO_PENDING; -} - -void PepperTransportSocketAdapter::Disconnect() { - DCHECK(CalledOnValidThread()); - transport_.reset(); -} - -bool PepperTransportSocketAdapter::IsConnected() const { - DCHECK(CalledOnValidThread()); - return connected_; -} - -bool PepperTransportSocketAdapter::IsConnectedAndIdle() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return false; -} - -int PepperTransportSocketAdapter::GetPeerAddress( - net::AddressList* address) const { - DCHECK(CalledOnValidThread()); - - // We don't have a meaningful peer address, but we can't return an - // error, so we return a INADDR_ANY instead. - net::IPAddressNumber ip_address(4); - *address = net::AddressList::CreateFromIPAddress(ip_address, 0); - return net::OK; -} - -int PepperTransportSocketAdapter::GetLocalAddress( - net::IPEndPoint* address) const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return net::ERR_FAILED; -} - -const net::BoundNetLog& PepperTransportSocketAdapter::NetLog() const { - DCHECK(CalledOnValidThread()); - return net_log_; -} - -void PepperTransportSocketAdapter::SetSubresourceSpeculation() { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); -} - -void PepperTransportSocketAdapter::SetOmniboxSpeculation() { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); -} - -bool PepperTransportSocketAdapter::WasEverUsed() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return true; -} - -bool PepperTransportSocketAdapter::UsingTCPFastOpen() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return true; -} - -int64 PepperTransportSocketAdapter::NumBytesRead() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return 0; -} - -base::TimeDelta PepperTransportSocketAdapter::GetConnectTimeMicros() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return base::TimeDelta(); -} - -net::NextProto PepperTransportSocketAdapter::GetNegotiatedProtocol() const { - DCHECK(CalledOnValidThread()); - NOTIMPLEMENTED(); - return net::kProtoUnknown; -} - -int PepperTransportSocketAdapter::ProcessCandidates() { - DCHECK(CalledOnValidThread()); - DCHECK(!get_address_pending_); - DCHECK(transport_.get()); - - while (true) { - pp::Var address; - int result = transport_->GetNextAddress( - &address, callback_factory_.NewOptionalCallback( - &PepperTransportSocketAdapter::OnNextAddress)); - if (result == PP_OK_COMPLETIONPENDING) { - get_address_pending_ = true; - break; - } - - if (result == PP_OK) { - observer_->OnChannelNewLocalCandidate(address.AsString()); - } else { - LOG(ERROR) << "GetNextAddress() returned an error " << result; - return PPErrorToNetError(result); - } - } - return net::OK; -} - -void PepperTransportSocketAdapter::OnNextAddress(int32_t result) { - DCHECK(CalledOnValidThread()); - - get_address_pending_ = false; - ProcessCandidates(); -} - -void PepperTransportSocketAdapter::OnConnect(int result) { - DCHECK(CalledOnValidThread()); - DCHECK(!connect_callback_.is_null()); - - if (result == PP_OK) - connected_ = true; - - net::CompletionCallback callback = connect_callback_; - connect_callback_.Reset(); - callback.Run(PPErrorToNetError(result)); -} - -void PepperTransportSocketAdapter::OnRead(int32_t result) { - DCHECK(CalledOnValidThread()); - DCHECK(!read_callback_.is_null()); - DCHECK(read_buffer_); - - 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_.is_null()); - DCHECK(write_buffer_); - - net::CompletionCallback callback = write_callback_; - write_callback_.Reset(); - write_buffer_ = NULL; - callback.Run(PPErrorToNetError(result)); -} - -} // namespace protocol -} // namespace remoting diff --git a/remoting/protocol/pepper_transport_socket_adapter.h b/remoting/protocol/pepper_transport_socket_adapter.h deleted file mode 100644 index ef19458..0000000 --- a/remoting/protocol/pepper_transport_socket_adapter.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTER_H_ -#define REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTER_H_ - -#include <string> - -#include "base/callback.h" -#include "base/memory/scoped_ptr.h" -#include "base/threading/non_thread_safe.h" -#include "net/base/completion_callback.h" -#include "net/base/net_log.h" -#include "net/socket/stream_socket.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/utility/completion_callback_factory.h" - -namespace pp { -class Transport_Dev; -} // namespace pp - -namespace remoting { -namespace protocol { - -// This class implements net::StreamSocket interface on top of the the -// Pepper P2P Transport API. -class PepperTransportSocketAdapter : public base::NonThreadSafe, - public net::StreamSocket { - public: - // Observer is used to notify about new local candidates and - // deletion of the adapter. - class Observer { - public: - Observer() { } - virtual ~Observer() { } - virtual void OnChannelDeleted() = 0; - virtual void OnChannelNewLocalCandidate(const std::string& candidate) = 0; - }; - - PepperTransportSocketAdapter(pp::Transport_Dev* transport, - const std::string& name, - Observer* observer); - virtual ~PepperTransportSocketAdapter(); - - const std::string& name() { return name_; } - - // Adds candidate received from the peer. - void AddRemoteCandidate(const std::string& candidate); - - // net::Socket implementation. - virtual int Read(net::IOBuffer* buf, int buf_len, - const net::CompletionCallback& callback) OVERRIDE; - virtual int Write(net::IOBuffer* buf, int buf_len, - const net::CompletionCallback& callback) OVERRIDE; - virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; - virtual bool SetSendBufferSize(int32 size) OVERRIDE; - - // net::StreamSocket implementation. - virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; - virtual void Disconnect() OVERRIDE; - virtual bool IsConnected() const OVERRIDE; - virtual bool IsConnectedAndIdle() const OVERRIDE; - virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; - virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; - virtual const net::BoundNetLog& NetLog() const OVERRIDE; - virtual void SetSubresourceSpeculation() OVERRIDE; - virtual void SetOmniboxSpeculation() OVERRIDE; - virtual bool WasEverUsed() const OVERRIDE; - virtual bool UsingTCPFastOpen() const OVERRIDE; - virtual int64 NumBytesRead() const OVERRIDE; - virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; - virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; - - private: - // Callbacks for PPAPI calls. - void OnConnect(int result); - void OnNextAddress(int32_t result); - void OnRead(int32_t result); - void OnWrite(int32_t result); - - int ProcessCandidates(); - - std::string name_; - Observer* observer_; - - scoped_ptr<pp::Transport_Dev> transport_; - - net::CompletionCallback connect_callback_; - bool connected_; - - bool get_address_pending_; - - net::CompletionCallback read_callback_; - scoped_refptr<net::IOBuffer> read_buffer_; - - net::CompletionCallback write_callback_; - scoped_refptr<net::IOBuffer> write_buffer_; - - net::BoundNetLog net_log_; - - pp::CompletionCallbackFactory<PepperTransportSocketAdapter> callback_factory_; - - DISALLOW_COPY_AND_ASSIGN(PepperTransportSocketAdapter); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTER_H_ |