diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 21:08:15 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 21:08:15 +0000 |
commit | 7b1c0376a17429471d2163c31ed4dbb05a9e819f (patch) | |
tree | 84018eceec973388732f768a6db69e901ea70b7e /remoting | |
parent | 5b54a5c0327ea3ac2c13cff37573ccd4e7f41e57 (diff) | |
download | chromium_src-7b1c0376a17429471d2163c31ed4dbb05a9e819f.zip chromium_src-7b1c0376a17429471d2163c31ed4dbb05a9e819f.tar.gz chromium_src-7b1c0376a17429471d2163c31ed4dbb05a9e819f.tar.bz2 |
Integrate P2P Sockets IPC with chromoting plugin.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6624020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/DEPS | 4 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 30 | ||||
-rw-r--r-- | remoting/client/x11_client.cc | 3 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 29 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.h | 11 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 14 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 10 | ||||
-rw-r--r-- | remoting/remoting.gyp | 9 |
8 files changed, 96 insertions, 14 deletions
diff --git a/remoting/client/DEPS b/remoting/client/DEPS index 4a5a738..73df734 100644 --- a/remoting/client/DEPS +++ b/remoting/client/DEPS @@ -5,4 +5,8 @@ include_rules = [ "+remoting/protocol", "+remoting/jingle_glue", + + # TODO(sergeyu): Remove this dependency: crbug.com/74951 . + "+webkit/plugins/ppapi", + "+chrome/renderer/p2p", ] diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 0cdfe62..9c07782 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -11,6 +11,11 @@ #include "base/string_util.h" #include "base/task.h" #include "base/threading/thread.h" +// TODO(sergeyu): We should not depend on renderer here. Instead P2P +// Pepper API should be used. Remove this dependency. +// crbug.com/74951 +#include "chrome/renderer/p2p/ipc_network_manager.h" +#include "chrome/renderer/p2p/ipc_socket_factory.h" #include "ppapi/c/pp_input_event.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/rect.h" @@ -25,6 +30,13 @@ #include "remoting/jingle_glue/jingle_thread.h" #include "remoting/proto/auth.pb.h" #include "remoting/protocol/connection_to_host.h" +// TODO(sergeyu): This is a hack: plugin should not depend on webkit +// glue. It is used here to get P2PPacketDispatcher corresponding to +// the current RenderView. Use P2P Pepper API for connection and +// remove these includes. +// crbug.com/74951 +#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" +#include "webkit/plugins/ppapi/resource_tracker.h" namespace remoting { @@ -68,9 +80,25 @@ bool ChromotingInstance::Init(uint32_t argc, // Start all the threads. context_.Start(); + webkit::ppapi::PluginInstance* plugin_instance = + webkit::ppapi::ResourceTracker::Get()->GetInstance(pp_instance()); + + P2PSocketDispatcher* socket_dispatcher = + plugin_instance->delegate()->GetP2PSocketDispatcher(); + IpcNetworkManager* network_manager = NULL; + IpcPacketSocketFactory* socket_factory = NULL; + + // If we don't have socket dispatcher for IPC (e.g. P2P API is + // disabled), then JingleClient will try to use physical sockets. + if (socket_dispatcher) { + VLOG(1) << "Creating IpcNetworkManager and IpcPacketSocketFactory."; + network_manager = new IpcNetworkManager(socket_dispatcher); + socket_factory = new IpcPacketSocketFactory(socket_dispatcher); + } + // Create the chromoting objects. host_connection_.reset(new protocol::ConnectionToHost( - context_.jingle_thread())); + context_.jingle_thread(), network_manager, socket_factory)); view_.reset(new PepperView(this, &context_)); view_proxy_ = new PepperViewProxy(this, view_.get()); rectangle_decoder_ = new RectangleUpdateDecoder( diff --git a/remoting/client/x11_client.cc b/remoting/client/x11_client.cc index 5d0867f..bed2e55 100644 --- a/remoting/client/x11_client.cc +++ b/remoting/client/x11_client.cc @@ -32,7 +32,8 @@ int main(int argc, char** argv) { MessageLoop ui_loop; remoting::ClientContext context; - remoting::protocol::ConnectionToHost connection(context.jingle_thread()); + remoting::protocol::ConnectionToHost connection(context.jingle_thread(), + NULL, NULL); remoting::X11View view; scoped_refptr<remoting::RectangleUpdateDecoder> rectangle_decoder = new remoting::RectangleUpdateDecoder(context.decode_message_loop(), diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index 20d4057..691548d 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -192,6 +192,21 @@ JingleClient::JingleClient(JingleThread* thread, signal_strategy_(signal_strategy) { } +JingleClient::JingleClient(JingleThread* thread, + SignalStrategy* signal_strategy, + talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_factory, + Callback* callback) + : thread_(thread), + state_(START), + initialized_(false), + closed_(false), + callback_(callback), + signal_strategy_(signal_strategy), + network_manager_(network_manager), + socket_factory_(socket_factory) { +} + JingleClient::~JingleClient() { base::AutoLock auto_lock(state_lock_); DCHECK(!initialized_ || closed_); @@ -211,11 +226,15 @@ void JingleClient::Init() { void JingleClient::DoInitialize() { DCHECK_EQ(message_loop(), MessageLoop::current()); - network_manager_.reset(new talk_base::NetworkManager()); - // TODO(sergeyu): Use IpcPacketSocketFactory here when it is - // implemented. - socket_factory_.reset(new talk_base::BasicPacketSocketFactory( - talk_base::Thread::Current())); + if (!network_manager_.get()) { + VLOG(1) << "Creating talk_base::NetworkManager."; + network_manager_.reset(new talk_base::NetworkManager()); + } + if (!socket_factory_.get()) { + VLOG(1) << "Creating talk_base::BasicPacketSocketFactory."; + socket_factory_.reset(new talk_base::BasicPacketSocketFactory( + talk_base::Thread::Current())); + } port_allocator_.reset( new cricket::HttpPortAllocator(network_manager_.get(), diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h index 4d877b5..6b49e24 100644 --- a/remoting/jingle_glue/jingle_client.h +++ b/remoting/jingle_glue/jingle_client.h @@ -139,7 +139,16 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>, virtual void OnStateChange(JingleClient* client, State state) = 0; }; - JingleClient(JingleThread* thread, SignalStrategy* signal_strategy, + // Physical sockets are used if |network_manager| and + // |socket_factory| are not specified. Otherwise ownership of these + // objects is given to JingleClient. + JingleClient(JingleThread* thread, + SignalStrategy* signal_strategy, + Callback* callback); + JingleClient(JingleThread* thread, + SignalStrategy* signal_strategy, + talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_factory, Callback* callback); ~JingleClient(); diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 27d2da1..3d34997 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -21,8 +21,13 @@ namespace remoting { namespace protocol { -ConnectionToHost::ConnectionToHost(JingleThread* thread) +ConnectionToHost::ConnectionToHost( + JingleThread* thread, + talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_factory) : thread_(thread), + network_manager_(network_manager), + socket_factory_(socket_factory), event_callback_(NULL), dispatcher_(new ClientMessageDispatcher()) { } @@ -61,7 +66,9 @@ void ConnectionToHost::Connect(const std::string& username, kChromotingTokenServiceName)); } - jingle_client_ = new JingleClient(thread_, signal_strategy_.get(), this); + jingle_client_ = new JingleClient(thread_, signal_strategy_.get(), + network_manager_.release(), + socket_factory_.release(), this); jingle_client_->Init(); // Save jid of the host. The actual connection is created later after @@ -72,8 +79,7 @@ void ConnectionToHost::Connect(const std::string& username, void ConnectionToHost::Disconnect() { if (MessageLoop::current() != message_loop()) { message_loop()->PostTask( - FROM_HERE, NewRunnableMethod(this, - &ConnectionToHost::Disconnect)); + FROM_HERE, NewRunnableMethod(this, &ConnectionToHost::Disconnect)); return; } diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index 0869a7b..2f661ca 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -50,8 +50,13 @@ class ConnectionToHost : public JingleClient::Callback { virtual void OnConnectionFailed(ConnectionToHost* conn) = 0; }; + // Takes ownership of |network_manager| and |socket_factory|. Both + // |network_manager| and |socket_factory| may be set to NULL. + // // TODO(sergeyu): Constructor shouldn't need thread here. - explicit ConnectionToHost(JingleThread* thread); + ConnectionToHost(JingleThread* thread, + talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_factory); virtual ~ConnectionToHost(); // TODO(ajwong): We need to generalize this API. @@ -98,6 +103,9 @@ class ConnectionToHost : public JingleClient::Callback { JingleThread* thread_; + scoped_ptr<talk_base::NetworkManager> network_manager_; + scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; + scoped_ptr<SignalStrategy> signal_strategy_; scoped_refptr<JingleClient> jingle_client_; scoped_refptr<SessionManager> session_manager_; diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index fcdc5a0..81a9867 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -73,7 +73,14 @@ 'chromoting_base', 'chromoting_client', 'chromoting_jingle_glue', - '../ppapi/ppapi.gyp:ppapi_cpp_objects', + '<(DEPTH)/ppapi/ppapi.gyp:ppapi_cpp_objects', + + # TODO(sergeyu): This is a hack: plugin should not depend on + # webkit glue. Skia is needed here to add include path webkit glue + # depends on. See comments in chromoting_instance.cc for details. + # crbug.com/74951 + '<(DEPTH)/webkit/support/webkit_support.gyp:glue', + '<(DEPTH)/skia/skia.gyp:skia', ], 'sources': [ 'client/plugin/chromoting_instance.cc', |