diff options
Diffstat (limited to 'remoting/client')
-rw-r--r-- | remoting/client/DEPS | 2 | ||||
-rw-r--r-- | remoting/client/ipc_host_resolver.cc | 69 | ||||
-rw-r--r-- | remoting/client/ipc_host_resolver.h | 35 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 7 |
4 files changed, 110 insertions, 3 deletions
diff --git a/remoting/client/DEPS b/remoting/client/DEPS index ab0c15a..2a3269f 100644 --- a/remoting/client/DEPS +++ b/remoting/client/DEPS @@ -1,7 +1,7 @@ include_rules = [ "+ppapi", "+jingle/glue", - "+third_party/npapi", + "+net", "+ui/gfx", "+remoting/protocol", diff --git a/remoting/client/ipc_host_resolver.cc b/remoting/client/ipc_host_resolver.cc new file mode 100644 index 0000000..7bac609 --- /dev/null +++ b/remoting/client/ipc_host_resolver.cc @@ -0,0 +1,69 @@ +// 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. + +#include "remoting/client/ipc_host_resolver.h" + +#include "base/bind.h" +#include "content/renderer/p2p/host_address_request.h" +#include "content/renderer/p2p/socket_dispatcher.h" +#include "net/base/ip_endpoint.h" +#include "jingle/glue/utils.h" + +namespace remoting { + +class IpcHostResolver : public HostResolver { + public: + IpcHostResolver(P2PSocketDispatcher* socket_dispatcher) + : socket_dispatcher_(socket_dispatcher) { + } + + virtual ~IpcHostResolver() { + if (request_) + request_->Cancel(); + } + + virtual void Resolve(const talk_base::SocketAddress& address) OVERRIDE { + if (address.IsUnresolved()) { + port_ = address.port(); + request_ = new P2PHostAddressRequest(socket_dispatcher_); + request_->Request(address.hostname(), base::Bind( + &IpcHostResolver::OnDone, base::Unretained(this))); + } else { + SignalDone(this, address); + } + } + + private: + void OnDone(const net::IPAddressNumber& address) { + talk_base::SocketAddress socket_address; + if (address.empty() || + !jingle_glue::IPEndPointToSocketAddress( + net::IPEndPoint(address, port_), &socket_address)) { + // Return nil address if the request has failed. + SignalDone(this, talk_base::SocketAddress()); + return; + } + + request_ = NULL; + SignalDone(this, socket_address); + } + + P2PSocketDispatcher* socket_dispatcher_; + scoped_refptr<P2PHostAddressRequest> request_; + uint16 port_; +}; + +IpcHostResolverFactory::IpcHostResolverFactory( + P2PSocketDispatcher* socket_dispatcher) + : socket_dispatcher_(socket_dispatcher) { +} + +IpcHostResolverFactory::~IpcHostResolverFactory() { +} + +HostResolver* IpcHostResolverFactory::CreateHostResolver() { + return new IpcHostResolver(socket_dispatcher_); +} + +} // namespace remoting diff --git a/remoting/client/ipc_host_resolver.h b/remoting/client/ipc_host_resolver.h new file mode 100644 index 0000000..8bcb028 --- /dev/null +++ b/remoting/client/ipc_host_resolver.h @@ -0,0 +1,35 @@ +// 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. + +#ifndef REMOTING_CLIENT_IPC_HOST_RESOLVER_H_ +#define REMOTING_CLIENT_IPC_HOST_ADDRESS_RESOLVER_H_ + +#include "base/compiler_specific.h" +#include "remoting/jingle_glue/host_resolver.h" + +class P2PSocketDispatcher; + +namespace remoting { + +// Implementation of HostResolverFactory interface that works in +// renderer. +// +// TODO(sergeyu): Move this class to content/renderer/p2p after +// HostResolver interface is moved to libjingle. +class IpcHostResolverFactory : public HostResolverFactory { + public: + IpcHostResolverFactory(P2PSocketDispatcher* socket_dispatcher); + virtual ~IpcHostResolverFactory(); + + virtual HostResolver* CreateHostResolver() OVERRIDE; + + private: + P2PSocketDispatcher* socket_dispatcher_; + + DISALLOW_COPY_AND_ASSIGN(IpcHostResolverFactory); +}; + +} // namespace remoting + +#endif // REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_ diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index efc5e78..cbbfa1e 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -32,7 +32,7 @@ #include "remoting/base/util.h" #include "remoting/client/client_config.h" #include "remoting/client/chromoting_client.h" -#include "remoting/client/rectangle_update_decoder.h" +#include "remoting/client/ipc_host_resolver.h" #include "remoting/client/plugin/chromoting_scriptable_object.h" #include "remoting/client/plugin/pepper_input_handler.h" #include "remoting/client/plugin/pepper_port_allocator_session.h" @@ -40,6 +40,7 @@ #include "remoting/client/plugin/pepper_view_proxy.h" #include "remoting/client/plugin/pepper_util.h" #include "remoting/client/plugin/pepper_xmpp_proxy.h" +#include "remoting/client/rectangle_update_decoder.h" #include "remoting/proto/auth.pb.h" #include "remoting/protocol/connection_to_host.h" #include "remoting/protocol/host_stub.h" @@ -180,6 +181,7 @@ void ChromotingInstance::Connect(const ClientConfig& config) { IpcNetworkManager* network_manager = NULL; IpcPacketSocketFactory* socket_factory = NULL; + HostResolverFactory* host_resolver_factory = NULL; PortAllocatorSessionFactory* session_factory = CreatePepperPortAllocatorSessionFactory(this); @@ -189,11 +191,12 @@ void ChromotingInstance::Connect(const ClientConfig& config) { VLOG(1) << "Creating IpcNetworkManager and IpcPacketSocketFactory."; network_manager = new IpcNetworkManager(socket_dispatcher); socket_factory = new IpcPacketSocketFactory(socket_dispatcher); + host_resolver_factory = new IpcHostResolverFactory(socket_dispatcher); } host_connection_.reset(new protocol::ConnectionToHost( context_.network_message_loop(), network_manager, socket_factory, - session_factory, enable_client_nat_traversal_)); + host_resolver_factory, session_factory, enable_client_nat_traversal_)); input_handler_.reset(new PepperInputHandler(&context_, host_connection_.get(), view_proxy_)); |