diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 22:23:36 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 22:23:36 +0000 |
commit | 3b2109ae1f15a87df412995ab61691d901487b65 (patch) | |
tree | 9159f0e2c3eb6665cdaaaadf78b16eb28c1628e9 | |
parent | 077478b5a7391bc3ace75c2a0d84cb2f470a4d98 (diff) | |
download | chromium_src-3b2109ae1f15a87df412995ab61691d901487b65.zip chromium_src-3b2109ae1f15a87df412995ab61691d901487b65.tar.gz chromium_src-3b2109ae1f15a87df412995ab61691d901487b65.tar.bz2 |
Switch client to Pepper UDP API instead of Transport API.
BUG=109630
Review URL: https://chromiumcodereview.appspot.com/10284008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136692 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/client/chromoting_client.cc | 9 | ||||
-rw-r--r-- | remoting/client/chromoting_client.h | 7 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 14 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_packet_socket_factory.cc | 6 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_port_allocator.cc | 1 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 4 |
7 files changed, 34 insertions, 14 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 723af04..4dabdd2 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -13,6 +13,7 @@ #include "remoting/protocol/negotiating_authenticator.h" #include "remoting/protocol/v1_authenticator.h" #include "remoting/protocol/session_config.h" +#include "remoting/protocol/transport.h" namespace remoting { @@ -46,7 +47,9 @@ ChromotingClient::ChromotingClient(const ClientConfig& config, ChromotingClient::~ChromotingClient() { } -void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { +void ChromotingClient::Start( + scoped_refptr<XmppProxy> xmpp_proxy, + scoped_ptr<protocol::TransportFactory> transport_factory) { DCHECK(message_loop()->BelongsToCurrentThread()); scoped_ptr<protocol::Authenticator> authenticator; @@ -60,8 +63,8 @@ void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { } connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, - config_.host_public_key, authenticator.Pass(), - this, this, this, this); + config_.host_public_key, transport_factory.Pass(), + authenticator.Pass(), this, this, this, this); if (!view_->Initialize()) { ClientDone(); diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index 7df0816..765b523 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -26,6 +26,10 @@ class MessageLoop; namespace remoting { +namespace protocol { +class TransportFactory; +} // namespace protocol + class ClientContext; class RectangleUpdateDecoder; @@ -44,7 +48,8 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, const base::Closure& client_done); virtual ~ChromotingClient(); - void Start(scoped_refptr<XmppProxy> xmpp_proxy); + void Start(scoped_refptr<XmppProxy> xmpp_proxy, + scoped_ptr<protocol::TransportFactory> transport_factory); void Stop(const base::Closure& shutdown_task); void ClientDone(); diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index d1b673f..c4d143f 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -19,6 +19,7 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "base/values.h" +#include "jingle/glue/thread_wrapper.h" #include "media/base/media.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/input_event.h" @@ -32,12 +33,14 @@ #include "remoting/client/frame_consumer_proxy.h" #include "remoting/client/plugin/chromoting_scriptable_object.h" #include "remoting/client/plugin/pepper_input_handler.h" +#include "remoting/client/plugin/pepper_port_allocator.h" #include "remoting/client/plugin/pepper_view.h" #include "remoting/client/plugin/pepper_xmpp_proxy.h" #include "remoting/client/rectangle_update_decoder.h" #include "remoting/protocol/connection_to_host.h" #include "remoting/protocol/host_stub.h" #include "remoting/protocol/input_event_tracker.h" +#include "remoting/protocol/libjingle_transport_factory.h" #include "remoting/protocol/mouse_input_filter.h" // Windows defines 'PostMessage', so we have to undef it. @@ -396,8 +399,10 @@ ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { void ChromotingInstance::Connect(const ClientConfig& config) { DCHECK(plugin_message_loop_->BelongsToCurrentThread()); + jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); + host_connection_.reset(new protocol::ConnectionToHost( - context_.network_message_loop(), this, true)); + context_.network_message_loop(), true)); client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), view_.get(), rectangle_decoder_.get(), base::Closure())); @@ -430,8 +435,13 @@ void ChromotingInstance::Connect(const ClientConfig& config) { plugin_message_loop_, context_.network_message_loop()); + scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator( + PepperPortAllocator::Create(this)); + scoped_ptr<protocol::TransportFactory> transport_factory( + new protocol::LibjingleTransportFactory(port_allocator.Pass(), false)); + // Kick off the connection. - client_->Start(xmpp_proxy_); + client_->Start(xmpp_proxy_, transport_factory.Pass()); // Start timer that periodically sends perf stats. plugin_message_loop_->PostDelayedTask( diff --git a/remoting/client/plugin/pepper_packet_socket_factory.cc b/remoting/client/plugin/pepper_packet_socket_factory.cc index b80102f..e007351 100644 --- a/remoting/client/plugin/pepper_packet_socket_factory.cc +++ b/remoting/client/plugin/pepper_packet_socket_factory.cc @@ -259,7 +259,11 @@ int UdpPacketSocket::Send(const void* data, size_t data_size) { int UdpPacketSocket::SendTo(const void* data, size_t data_size, const talk_base::SocketAddress& address) { - DCHECK_EQ(state_, STATE_BOUND); + if (state_ != STATE_BOUND) { + // TODO(sergeyu): StunPort may try to send stun request before we + // are bound. Fix that problem and change this to DCHECK. + return EINVAL; + } if (error_ != 0) { return error_; diff --git a/remoting/client/plugin/pepper_port_allocator.cc b/remoting/client/plugin/pepper_port_allocator.cc index e999f54..3c89655 100644 --- a/remoting/client/plugin/pepper_port_allocator.cc +++ b/remoting/client/plugin/pepper_port_allocator.cc @@ -66,6 +66,7 @@ PepperPortAllocatorSession::PepperPortAllocatorSession( : HttpPortAllocatorSessionBase( allocator, channel_name, component, stun_hosts, relay_hosts, relay, ""), instance_(instance) { + set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); } PepperPortAllocatorSession::~PepperPortAllocatorSession() { diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 802d010..25a8949 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -29,10 +29,8 @@ namespace protocol { ConnectionToHost::ConnectionToHost( base::MessageLoopProxy* message_loop, - pp::Instance* pp_instance, bool allow_nat_traversal) : message_loop_(message_loop), - pp_instance_(pp_instance), allow_nat_traversal_(allow_nat_traversal), event_callback_(NULL), client_stub_(NULL), @@ -62,6 +60,7 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, const std::string& local_jid, const std::string& host_jid, const std::string& host_public_key, + scoped_ptr<TransportFactory> transport_factory, scoped_ptr<Authenticator> authenticator, HostEventCallback* event_callback, ClientStub* client_stub, @@ -84,10 +83,8 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, signal_strategy_->AddListener(this); signal_strategy_->Connect(); - scoped_ptr<TransportFactory> transport_factory( - new PepperTransportFactory(pp_instance_)); session_manager_.reset(new JingleSessionManager( - transport_factory.Pass(), true)); + transport_factory.Pass(), allow_nat_traversal_)); session_manager_->Init(signal_strategy_.get(), this); } diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index 45e1f9a..9deb3b69 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -42,6 +42,7 @@ class ClipboardStub; class HostStub; class InputStub; class SessionConfig; +class TransportFactory; class VideoReader; class VideoStub; @@ -64,7 +65,6 @@ class ConnectionToHost : public SignalStrategy::Listener, }; ConnectionToHost(base::MessageLoopProxy* message_loop, - pp::Instance* pp_instance, bool allow_nat_traversal); virtual ~ConnectionToHost(); @@ -72,6 +72,7 @@ class ConnectionToHost : public SignalStrategy::Listener, const std::string& local_jid, const std::string& host_jid, const std::string& host_public_key, + scoped_ptr<TransportFactory> transport_factory, scoped_ptr<Authenticator> authenticator, HostEventCallback* event_callback, ClientStub* client_stub, @@ -122,7 +123,6 @@ class ConnectionToHost : public SignalStrategy::Listener, void SetState(State state, ErrorCode error); scoped_refptr<base::MessageLoopProxy> message_loop_; - pp::Instance* pp_instance_; bool allow_nat_traversal_; std::string host_jid_; |