summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/plugin/chromoting_instance.cc1
-rw-r--r--remoting/client/plugin/pepper_port_allocator_session.cc428
-rw-r--r--remoting/client/plugin/pepper_port_allocator_session.h76
-rw-r--r--remoting/host/chromoting_host.cc3
-rw-r--r--remoting/jingle_glue/host_resolver.cc13
-rw-r--r--remoting/jingle_glue/host_resolver.h45
-rw-r--r--remoting/jingle_glue/http_port_allocator.cc38
-rw-r--r--remoting/jingle_glue/http_port_allocator.h61
-rw-r--r--remoting/jingle_glue/jingle_info_request.cc44
-rw-r--r--remoting/jingle_glue/jingle_info_request.h14
-rw-r--r--remoting/protocol/connection_to_host.cc2
-rw-r--r--remoting/protocol/jingle_session_manager.cc42
-rw-r--r--remoting/protocol/jingle_session_manager.h24
-rw-r--r--remoting/protocol/jingle_session_unittest.cc4
-rw-r--r--remoting/protocol/pepper_session_manager.cc2
-rw-r--r--remoting/protocol/protocol_test_client.cc2
-rw-r--r--remoting/remoting.gyp6
17 files changed, 24 insertions, 781 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 4d9b2c5..7ab92c0 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -30,7 +30,6 @@
#include "remoting/client/chromoting_client.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"
#include "remoting/client/plugin/pepper_view.h"
#include "remoting/client/plugin/pepper_view_proxy.h"
#include "remoting/client/plugin/pepper_xmpp_proxy.h"
diff --git a/remoting/client/plugin/pepper_port_allocator_session.cc b/remoting/client/plugin/pepper_port_allocator_session.cc
deleted file mode 100644
index cf83a4c..0000000
--- a/remoting/client/plugin/pepper_port_allocator_session.cc
+++ /dev/null
@@ -1,428 +0,0 @@
-// 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/plugin/pepper_port_allocator_session.h"
-
-#include <map>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/logging.h"
-#include "base/message_loop_proxy.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "base/synchronization/lock.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
-#include "ppapi/cpp/url_loader.h"
-#include "ppapi/cpp/url_request_info.h"
-#include "ppapi/cpp/url_response_info.h"
-#include "remoting/jingle_glue/http_port_allocator.h"
-#include "remoting/client/plugin/chromoting_instance.h"
-#include "remoting/client/plugin/pepper_entrypoints.h"
-
-namespace {
-
-static const int kHostPort = 80;
-static const int kNumRetries = 5;
-
-// Define a SessionFactory in the anonymouse namespace so we have a
-// shorter name.
-// TODO(hclam): Move this to a separate file.
-class SessionFactory : public remoting::PortAllocatorSessionFactory {
- public:
- SessionFactory(remoting::ChromotingInstance* instance,
- base::MessageLoopProxy* pepper_message_loop,
- base::MessageLoopProxy* network_message_loop)
- : instance_(instance),
- pepper_message_loop_(pepper_message_loop),
- network_message_loop_(network_message_loop) {
- }
-
- virtual cricket::PortAllocatorSession* CreateSession(
- cricket::BasicPortAllocator* allocator,
- const std::string& name,
- const std::string& session_type,
- const std::vector<talk_base::SocketAddress>& stun_hosts,
- const std::vector<std::string>& relay_hosts,
- const std::string& relay,
- const std::string& agent) {
- return new remoting::PepperPortAllocatorSession(
- instance_, pepper_message_loop_, network_message_loop_, allocator,
- name, session_type, stun_hosts, relay_hosts, relay, agent);
- }
-
- private:
- remoting::ChromotingInstance* instance_;
-
- scoped_refptr<base::MessageLoopProxy> pepper_message_loop_;
- scoped_refptr<base::MessageLoopProxy> network_message_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(SessionFactory);
-};
-
-typedef Callback3<bool, int, const std::string&>::Type FetchCallback;
-
-// Parses the lines in the result of the HTTP request that are of the form
-// 'a=b' and returns them in a map.
-typedef std::map<std::string, std::string> StringMap;
-void ParseMap(const std::string& string, StringMap& map) {
- size_t start_of_line = 0;
- size_t end_of_line = 0;
-
- for (;;) { // for each line
- start_of_line = string.find_first_not_of("\r\n", end_of_line);
- if (start_of_line == std::string::npos)
- break;
-
- end_of_line = string.find_first_of("\r\n", start_of_line);
- if (end_of_line == std::string::npos) {
- end_of_line = string.length();
- }
-
- size_t equals = string.find('=', start_of_line);
- if ((equals >= end_of_line) || (equals == std::string::npos))
- continue;
-
- std::string key(string, start_of_line, equals - start_of_line);
- std::string value(string, equals + 1, end_of_line - equals - 1);
-
- TrimString(key, " \t\r\n", &key);
- TrimString(value, " \t\r\n", &value);
-
- if ((key.size() > 0) && (value.size() > 0))
- map[key] = value;
- }
-}
-
-} // namespace
-
-namespace remoting {
-
-// A URL Fetcher using Pepper.
-// TODO(hclam): Move this to a separate file.
-class PepperURLFetcher {
- public:
- PepperURLFetcher() : fetch_callback_(NULL) {
- callback_factory_.Initialize(this);
- }
-
- void Start(const pp::Instance& instance,
- pp::URLRequestInfo request,
- FetchCallback* fetch_callback) {
- loader_ = pp::URLLoader(instance);
-
- // Grant access to external origins.
- const struct PPB_URLLoaderTrusted* trusted_loader_interface =
- reinterpret_cast<const PPB_URLLoaderTrusted*>(
- PPP_GetBrowserInterface(PPB_URLLOADERTRUSTED_INTERFACE));
- trusted_loader_interface->GrantUniversalAccess(
- loader_.pp_resource());
-
- fetch_callback_.reset(fetch_callback);
-
- pp::CompletionCallback callback =
- callback_factory_.NewOptionalCallback(&PepperURLFetcher::DidOpen);
- int rv = loader_.Open(request, callback);
- if (rv != PP_OK_COMPLETIONPENDING)
- callback.Run(rv);
- }
-
- private:
- void ReadMore() {
- pp::CompletionCallback callback =
- callback_factory_.NewOptionalCallback(&PepperURLFetcher::DidRead);
- int rv = loader_.ReadResponseBody(buf_, sizeof(buf_), callback);
- if (rv != PP_OK_COMPLETIONPENDING)
- callback.Run(rv);
- }
-
- void DidOpen(int32_t result) {
- if (result == PP_OK) {
- ReadMore();
- } else {
- DidFinish(result);
- }
- }
-
- void DidRead(int32_t result) {
- if (result > 0) {
- data_.append(buf_, result);
- ReadMore();
- } else {
- DidFinish(result);
- }
- }
-
- void DidFinish(int32_t result) {
- if (fetch_callback_.get()) {
- bool success = result == PP_OK;
- int status_code = 0;
- if (success)
- status_code = loader_.GetResponseInfo().GetStatusCode();
- fetch_callback_->Run(success, status_code, data_);
- }
- }
-
- pp::CompletionCallbackFactory<PepperURLFetcher> callback_factory_;
- pp::URLLoader loader_;
- scoped_ptr<FetchCallback> fetch_callback_;
- char buf_[4096];
- std::string data_;
-};
-
-// A helper function to destruct |fetcher| on pepper thread.
-static void DeletePepperURLFetcher(PepperURLFetcher* fetcher) {
- delete fetcher;
-}
-
-// A helper class to do HTTP request on the pepper thread and then delegate the
-// result to PepperPortAllocatorSession on network thread safely.
-class PepperCreateSessionTask
- : public base::RefCountedThreadSafe<PepperCreateSessionTask> {
- public:
- PepperCreateSessionTask(
- base::MessageLoopProxy* plugin_message_loop,
- base::MessageLoopProxy* network_message_loop,
- PepperPortAllocatorSession* allocator_session,
- ChromotingInstance* instance,
- const std::string& host,
- int port,
- const std::string& relay_token,
- const std::string& session_type,
- const std::string& name)
- : plugin_message_loop_(plugin_message_loop),
- network_message_loop_(network_message_loop),
- allocator_session_(allocator_session),
- instance_(instance),
- host_(host),
- port_(port),
- relay_token_(relay_token),
- session_type_(session_type),
- name_(name) {
- }
-
- // Start doing the request. The request will start on the pepper thread.
- void Start() {
- if (!plugin_message_loop_->BelongsToCurrentThread()) {
- plugin_message_loop_->PostTask(
- FROM_HERE, base::Bind(&PepperCreateSessionTask::Start, this));
- return;
- }
-
- // Perform the request here.
- std::string url = base::StringPrintf("http://%s:%d/create_session",
- host_.c_str(), port_);
- pp::URLRequestInfo request(instance_);
- request.SetURL(url.c_str());
- request.SetMethod("GET");
- request.SetHeaders(base::StringPrintf(
- "X-Talk-Google-Relay-Auth: %s\r\n"
- "X-Google-Relay-Auth: %s\r\n"
- "X-Session-Type: %s\r\n"
- "X-Stream-Type: %s\r\n",
- relay_token_.c_str(), relay_token_.c_str(), session_type_.c_str(),
- name_.c_str()));
-
- url_fetcher_.reset(new PepperURLFetcher());
- url_fetcher_->Start(
- *instance_, request,
- NewCallback(this, &PepperCreateSessionTask::OnRequestDone));
- }
-
- // Detach this task. This class will not access PepperPortAllocatorSession
- // anymore.
- void Detach() {
- // Set the pointers to zero.
- {
- base::AutoLock auto_lock(lock_);
- network_message_loop_ = NULL;
- allocator_session_ = NULL;
- instance_ = NULL;
- }
-
- // IMPORTANT!
- // Destroy PepperURLFetcher only on pepper thread.
- plugin_message_loop_->PostTask(
- FROM_HERE, base::Bind(&DeletePepperURLFetcher, url_fetcher_.release()));
- }
-
- private:
- void OnRequestDone(bool success, int status_code,
- const std::string& response) {
- // IMPORTANT!
- // This method is called on the pepper thread and we want the response to
- // be delegated to the network thread. However jignle thread might have
- // been destroyed and |allocator_session_| might be dangling too. So we
- // put a lock here to access |network_message_loop_| and then do the
- // remaining work on the network thread.
- base::AutoLock auto_lock(lock_);
- if (!network_message_loop_)
- return;
-
- network_message_loop_->PostTask(
- FROM_HERE, base::Bind(&PepperCreateSessionTask::DelegateRequestDone,
- this, success, status_code, response));
- }
-
- void DelegateRequestDone(bool success, int status_code,
- const std::string& response) {
- if (!allocator_session_)
- return;
- allocator_session_->OnRequestDone(success, status_code, response);
- }
-
- // Protects |network_message_loop_| and |allocator_session_|.
- base::Lock lock_;
-
- scoped_refptr<base::MessageLoopProxy> plugin_message_loop_;
- scoped_refptr<base::MessageLoopProxy> network_message_loop_;
- PepperPortAllocatorSession* allocator_session_;
- ChromotingInstance* instance_;
- std::string host_;
- int port_;
- std::string relay_token_;
- std::string session_type_;
- std::string name_;
-
- // Pepper resources for URL fetching.
- scoped_ptr<PepperURLFetcher> url_fetcher_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperCreateSessionTask);
-};
-
-PepperPortAllocatorSession::PepperPortAllocatorSession(
- ChromotingInstance* instance,
- base::MessageLoopProxy* plugin_message_loop,
- base::MessageLoopProxy* network_message_loop,
- cricket::BasicPortAllocator* allocator,
- const std::string &name,
- const std::string& session_type,
- const std::vector<talk_base::SocketAddress>& stun_hosts,
- const std::vector<std::string>& relay_hosts,
- const std::string& relay_token,
- const std::string& user_agent)
- : BasicPortAllocatorSession(allocator, name, session_type),
- instance_(instance), plugin_message_loop_(plugin_message_loop),
- network_message_loop_(network_message_loop),
- relay_hosts_(relay_hosts), stun_hosts_(stun_hosts),
- relay_token_(relay_token), agent_(user_agent), attempts_(0) {
-}
-
-PepperPortAllocatorSession::~PepperPortAllocatorSession() {
- if (create_session_task_) {
- create_session_task_->Detach();
- create_session_task_ = NULL;
- }
-}
-
-void PepperPortAllocatorSession::GetPortConfigurations() {
- // Creating relay sessions can take time and is done asynchronously.
- // Creating stun sessions could also take time and could be done aysnc also,
- // but for now is done here and added to the initial config. Note any later
- // configs will have unresolved stun ips and will be discarded by the
- // AllocationSequence.
- cricket::PortConfiguration* config =
- new cricket::PortConfiguration(stun_hosts_[0], "", "", "");
- ConfigReady(config);
- TryCreateRelaySession();
-}
-
-void PepperPortAllocatorSession::TryCreateRelaySession() {
- if (attempts_ == kNumRetries) {
- LOG(ERROR) << "PepperPortAllocator: maximum number of requests reached; "
- << "giving up on relay.";
- return;
- }
-
- if (relay_hosts_.size() == 0) {
- LOG(ERROR) << "PepperPortAllocator: no relay hosts configured.";
- return;
- }
-
- // Choose the next host to try.
- std::string host = relay_hosts_[attempts_ % relay_hosts_.size()];
- attempts_++;
- LOG(INFO) << "PepperPortAllocator: sending to relay host " << host;
- if (relay_token_.empty()) {
- LOG(WARNING) << "No relay auth token found.";
- }
-
- SendSessionRequest(host, kHostPort);
-}
-
-void PepperPortAllocatorSession::SendSessionRequest(const std::string& host,
- int port) {
- // Destroy the old PepperCreateSessionTask first.
- if (create_session_task_) {
- create_session_task_->Detach();
- create_session_task_ = NULL;
- }
-
- // Construct a new one and start it. OnRequestDone() will be called when
- // task has completed.
- create_session_task_ = new PepperCreateSessionTask(
- plugin_message_loop_, network_message_loop_, this, instance_,
- host, port, relay_token_, session_type(), name());
- create_session_task_->Start();
-}
-
-void PepperPortAllocatorSession::OnRequestDone(bool success,
- int status_code,
- const std::string& response) {
- DCHECK(network_message_loop_->BelongsToCurrentThread());
-
- if (!success || status_code != 200) {
- LOG(WARNING) << "PepperPortAllocatorSession: failed.";
- TryCreateRelaySession();
- return;
- }
-
- LOG(INFO) << "PepperPortAllocatorSession: request succeeded.";
- ReceiveSessionResponse(response);
-}
-
-void PepperPortAllocatorSession::ReceiveSessionResponse(
- const std::string& response) {
- StringMap map;
- ParseMap(response, map);
-
- std::string username = map["username"];
- std::string password = map["password"];
- std::string magic_cookie = map["magic_cookie"];
-
- std::string relay_ip = map["relay.ip"];
- std::string relay_udp_port = map["relay.udp_port"];
- std::string relay_tcp_port = map["relay.tcp_port"];
- std::string relay_ssltcp_port = map["relay.ssltcp_port"];
-
- cricket::PortConfiguration* config =
- new cricket::PortConfiguration(stun_hosts_[0], username,
- password, magic_cookie);
-
- cricket::PortConfiguration::PortList ports;
- if (!relay_udp_port.empty()) {
- talk_base::SocketAddress address(relay_ip, atoi(relay_udp_port.c_str()));
- ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_UDP));
- }
- if (!relay_tcp_port.empty()) {
- talk_base::SocketAddress address(relay_ip, atoi(relay_tcp_port.c_str()));
- ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_TCP));
- }
- if (!relay_ssltcp_port.empty()) {
- talk_base::SocketAddress address(relay_ip, atoi(relay_ssltcp_port.c_str()));
- ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP));
- }
- config->AddRelay(ports, 0.0f);
- ConfigReady(config);
-}
-
-PortAllocatorSessionFactory* CreatePepperPortAllocatorSessionFactory(
- ChromotingInstance* instance, base::MessageLoopProxy* plugin_message_loop,
- base::MessageLoopProxy* network_message_loop) {
- return new SessionFactory(instance, plugin_message_loop,
- network_message_loop);
-}
-
-} // namespace remoting
diff --git a/remoting/client/plugin/pepper_port_allocator_session.h b/remoting/client/plugin/pepper_port_allocator_session.h
deleted file mode 100644
index fb1d9ab..0000000
--- a/remoting/client/plugin/pepper_port_allocator_session.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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_PLUGIN_PEPPER_PORT_ALLOCATOR_SESSION_H_
-#define REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_SESSION_H_
-
-#include "base/memory/ref_counted.h"
-#include "ppapi/cpp/completion_callback.h"
-#include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
-
-namespace base {
-class MessageLoopProxy;
-} // namespace base
-
-namespace remoting {
-
-class ChromotingInstance;
-class PepperCreateSessionTask;
-class PepperURLFetcher;
-class PortAllocatorSessionFactory;
-
-class PepperPortAllocatorSession : public cricket::BasicPortAllocatorSession {
- public:
- PepperPortAllocatorSession(
- ChromotingInstance* instance,
- base::MessageLoopProxy* plugin_message_loop,
- base::MessageLoopProxy* network_message_loop,
- cricket::BasicPortAllocator* allocator,
- const std::string& name,
- const std::string& session_type,
- const std::vector<talk_base::SocketAddress>& stun_hosts,
- const std::vector<std::string>& relay_hosts,
- const std::string& relay,
- const std::string& agent);
- virtual ~PepperPortAllocatorSession();
-
- const std::string& relay_token() const {
- return relay_token_;
- }
-
- // Overrides the implementations in BasicPortAllocatorSession to use
- // pepper's URLLoader as HTTP client.
- virtual void SendSessionRequest(const std::string& host, int port);
- virtual void ReceiveSessionResponse(const std::string& response);
-
- void OnRequestDone(bool success, int status_code,
- const std::string& response);
-
- private:
- virtual void GetPortConfigurations();
- void TryCreateRelaySession();
-
- ChromotingInstance* const instance_;
- scoped_refptr<base::MessageLoopProxy> plugin_message_loop_;
- scoped_refptr<base::MessageLoopProxy> network_message_loop_;
-
- std::vector<std::string> relay_hosts_;
- std::vector<talk_base::SocketAddress> stun_hosts_;
- std::string relay_token_;
- std::string agent_;
- int attempts_;
-
- scoped_refptr<PepperCreateSessionTask> create_session_task_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorSession);
-};
-
-PortAllocatorSessionFactory* CreatePepperPortAllocatorSessionFactory(
- ChromotingInstance* instance, base::MessageLoopProxy* plugin_message_loop,
- base::MessageLoopProxy* network_message_loop);
-
-
-} // namespace remoting
-
-#endif // REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_SESSION_H_
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index e2431b5..437a01c 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -198,8 +198,7 @@ void ChromotingHost::OnStateChange(
// Create and start session manager.
protocol::JingleSessionManager* server =
- protocol::JingleSessionManager::CreateNotSandboxed(
- context_->network_message_loop());
+ new protocol::JingleSessionManager(context_->network_message_loop());
// TODO(ajwong): Make this a command switch when we're more stable.
server->set_allow_local_ips(true);
diff --git a/remoting/jingle_glue/host_resolver.cc b/remoting/jingle_glue/host_resolver.cc
deleted file mode 100644
index 5ad3316..0000000
--- a/remoting/jingle_glue/host_resolver.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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/jingle_glue/host_resolver.h"
-
-namespace remoting {
-
-HostResolver::HostResolver() { }
-
-HostResolver::~HostResolver() { }
-
-} // namespace remoting
diff --git a/remoting/jingle_glue/host_resolver.h b/remoting/jingle_glue/host_resolver.h
deleted file mode 100644
index d74ae2b..0000000
--- a/remoting/jingle_glue/host_resolver.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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_JINGLE_GLUE_HOST_RESOLVER_H_
-#define REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "third_party/libjingle/source/talk/base/sigslot.h"
-#include "third_party/libjingle/source/talk/base/socketaddress.h"
-
-namespace remoting {
-
-// TODO(sergeyu): Move HostResolver and HostResolverFactory to
-// libjingle and use them in StunPort.
-
-class HostResolver {
- public:
- HostResolver();
- virtual ~HostResolver();
-
- virtual void Resolve(const talk_base::SocketAddress& address) = 0;
-
- sigslot::signal2<HostResolver*, const talk_base::SocketAddress&> SignalDone;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HostResolver);
-};
-
-class HostResolverFactory {
- public:
- HostResolverFactory() { }
- virtual ~HostResolverFactory() { }
-
- virtual HostResolver* CreateHostResolver() = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HostResolverFactory);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_
diff --git a/remoting/jingle_glue/http_port_allocator.cc b/remoting/jingle_glue/http_port_allocator.cc
deleted file mode 100644
index 06639da..0000000
--- a/remoting/jingle_glue/http_port_allocator.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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/jingle_glue/http_port_allocator.h"
-
-namespace remoting {
-
-PortAllocatorSessionFactory::~PortAllocatorSessionFactory() {
-}
-
-HttpPortAllocator::HttpPortAllocator(
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- PortAllocatorSessionFactory* session_factory,
- const std::string &user_agent)
- : cricket::HttpPortAllocator(network_manager,
- socket_factory,
- user_agent),
- session_factory_(session_factory) {
-}
-
-HttpPortAllocator::~HttpPortAllocator() {
-}
-
-cricket::PortAllocatorSession *HttpPortAllocator::CreateSession(
- const std::string& name, const std::string& session_type) {
- if (session_factory_) {
- return session_factory_->CreateSession(
- this, name, session_type, stun_hosts(), relay_hosts(), relay_token(),
- user_agent());
- }
- return new cricket::HttpPortAllocatorSession(
- this, name, session_type, stun_hosts(), relay_hosts(), relay_token(),
- user_agent());
-}
-
-} // namespace remoting
diff --git a/remoting/jingle_glue/http_port_allocator.h b/remoting/jingle_glue/http_port_allocator.h
deleted file mode 100644
index 07aa830..0000000
--- a/remoting/jingle_glue/http_port_allocator.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-// This file overrides HttpPortAllocator defined in
-// third_party/libjingle/talk/p2p/client/httpportallocator.h to inject a
-// custom HTTP client.
-
-#ifndef REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_
-#define REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_
-
-#include <string>
-#include <vector>
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
-
-namespace remoting {
-
-// A factory class to generate cricket::PortAllocatorSession.
-class PortAllocatorSessionFactory {
- public:
- PortAllocatorSessionFactory() {
- }
-
- virtual ~PortAllocatorSessionFactory();
-
- virtual cricket::PortAllocatorSession* CreateSession(
- cricket::BasicPortAllocator* allocator,
- const std::string& name,
- const std::string& session_type,
- const std::vector<talk_base::SocketAddress>& stun_hosts,
- const std::vector<std::string>& relay_hosts,
- const std::string& relay,
- const std::string& agent) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PortAllocatorSessionFactory);
-};
-
-class HttpPortAllocator : public cricket::HttpPortAllocator {
- public:
- HttpPortAllocator(talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- PortAllocatorSessionFactory* session_factory,
- const std::string& user_agent);
- virtual ~HttpPortAllocator();
-
- // Override CreateSession() to inject a custom HTTP session.
- virtual cricket::PortAllocatorSession* CreateSession(
- const std::string& name, const std::string& session_type);
-
- private:
- PortAllocatorSessionFactory* session_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(HttpPortAllocator);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_
diff --git a/remoting/jingle_glue/jingle_info_request.cc b/remoting/jingle_glue/jingle_info_request.cc
index 9a5d16d..148a65f 100644
--- a/remoting/jingle_glue/jingle_info_request.cc
+++ b/remoting/jingle_glue/jingle_info_request.cc
@@ -10,7 +10,6 @@
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "net/base/net_util.h"
-#include "remoting/jingle_glue/host_resolver.h"
#include "remoting/jingle_glue/iq_request.h"
#include "third_party/libjingle/source/talk/base/socketaddress.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
@@ -19,17 +18,13 @@
namespace remoting {
-JingleInfoRequest::JingleInfoRequest(IqRequest* request,
- HostResolverFactory* host_resolver_factory)
- : host_resolver_factory_(host_resolver_factory),
- request_(request) {
+JingleInfoRequest::JingleInfoRequest(IqRequest* request)
+ : request_(request) {
request_->set_callback(base::Bind(&JingleInfoRequest::OnResponse,
base::Unretained(this)));
}
JingleInfoRequest::~JingleInfoRequest() {
- STLDeleteContainerPointers(stun_dns_requests_.begin(),
- stun_dns_requests_.end());
}
void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) {
@@ -48,6 +43,7 @@ void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) {
return;
}
+ std::vector<talk_base::SocketAddress> stun_hosts;
const buzz::XmlElement* stun = query->FirstNamed(buzz::QN_JINGLE_INFO_STUN);
if (stun) {
for (const buzz::XmlElement* server =
@@ -63,49 +59,27 @@ void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) {
continue;
}
- if (host_resolver_factory_) {
- net::IPAddressNumber ip_number;
- HostResolver* resolver = host_resolver_factory_->CreateHostResolver();
- stun_dns_requests_.insert(resolver);
- resolver->SignalDone.connect(
- this, &JingleInfoRequest::OnStunAddressResponse);
- resolver->Resolve(talk_base::SocketAddress(host, port));
- } else {
- // If there is no |host_resolver_factory_|, we're not sandboxed, so
- // we can let libjingle itself do the DNS resolution.
- stun_hosts_.push_back(talk_base::SocketAddress(host, port));
- }
+ stun_hosts.push_back(talk_base::SocketAddress(host, port));
}
}
}
+ std::vector<std::string> relay_hosts;
+ std::string relay_token;
const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY);
if (relay) {
- relay_token_ = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN);
+ relay_token = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN);
for (const buzz::XmlElement* server =
relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER);
server != NULL;
server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) {
std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST);
if (host != buzz::STR_EMPTY)
- relay_hosts_.push_back(host);
+ relay_hosts.push_back(host);
}
}
- if (stun_dns_requests_.empty())
- on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_);
-}
-
-void JingleInfoRequest::OnStunAddressResponse(
- HostResolver* resolver, const talk_base::SocketAddress& address) {
- if (!address.IsNil())
- stun_hosts_.push_back(address);
-
- MessageLoop::current()->DeleteSoon(FROM_HERE, resolver);
- stun_dns_requests_.erase(resolver);
-
- if (stun_dns_requests_.empty())
- on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_);
+ on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts);
}
} // namespace remoting
diff --git a/remoting/jingle_glue/jingle_info_request.h b/remoting/jingle_glue/jingle_info_request.h
index df7552f..6d5bcf6 100644
--- a/remoting/jingle_glue/jingle_info_request.h
+++ b/remoting/jingle_glue/jingle_info_request.h
@@ -27,8 +27,6 @@ class SocketAddress;
namespace remoting {
class IqRequest;
-class HostResolver;
-class HostResolverFactory;
// JingleInfoRequest handles requesting STUN/Relay infromation from
// the Google Talk network. The query is made when Send() is
@@ -49,8 +47,7 @@ class JingleInfoRequest : public sigslot::has_slots<> {
const std::string&, const std::vector<std::string>&,
const std::vector<talk_base::SocketAddress>&)> OnJingleInfoCallback;
- explicit JingleInfoRequest(IqRequest* request,
- HostResolverFactory* host_resolver_factory);
+ explicit JingleInfoRequest(IqRequest* request);
virtual ~JingleInfoRequest();
void Send(const OnJingleInfoCallback& callback);
@@ -59,19 +56,10 @@ class JingleInfoRequest : public sigslot::has_slots<> {
struct PendingDnsRequest;
void OnResponse(const buzz::XmlElement* stanza);
- void OnStunAddressResponse(HostResolver* resolver,
- const talk_base::SocketAddress& address);
- HostResolverFactory* host_resolver_factory_;
scoped_ptr<IqRequest> request_;
OnJingleInfoCallback on_jingle_info_cb_;
- std::vector<std::string> relay_hosts_;
- std::vector<talk_base::SocketAddress> stun_hosts_;
- std::string relay_token_;
-
- std::set<HostResolver*> stun_dns_requests_;
-
DISALLOW_COPY_AND_ASSIGN(JingleInfoRequest);
};
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc
index 4a30688..742f4f5 100644
--- a/remoting/protocol/connection_to_host.cc
+++ b/remoting/protocol/connection_to_host.cc
@@ -9,8 +9,6 @@
#include "base/location.h"
#include "base/message_loop_proxy.h"
#include "remoting/base/constants.h"
-#include "remoting/jingle_glue/host_resolver.h"
-#include "remoting/jingle_glue/http_port_allocator.h"
#include "remoting/jingle_glue/javascript_signal_strategy.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/auth_token_utils.h"
diff --git a/remoting/protocol/jingle_session_manager.cc b/remoting/protocol/jingle_session_manager.cc
index cd81c21..9400afc 100644
--- a/remoting/protocol/jingle_session_manager.cc
+++ b/remoting/protocol/jingle_session_manager.cc
@@ -11,16 +11,14 @@
#include "base/string_util.h"
#include "base/task.h"
#include "remoting/base/constants.h"
-#include "remoting/jingle_glue/host_resolver.h"
-#include "remoting/jingle_glue/http_port_allocator.h"
#include "remoting/jingle_glue/jingle_info_request.h"
#include "remoting/jingle_glue/jingle_signaling_connector.h"
#include "remoting/jingle_glue/signal_strategy.h"
#include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
-#include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h"
-#include "third_party/libjingle/source/talk/p2p/base/transport.h"
#include "third_party/libjingle/source/talk/p2p/base/constants.h"
+#include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h"
#include "third_party/libjingle/source/talk/p2p/base/transport.h"
+#include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
using buzz::XmlElement;
@@ -28,35 +26,9 @@ using buzz::XmlElement;
namespace remoting {
namespace protocol {
-// static
-JingleSessionManager* JingleSessionManager::CreateNotSandboxed(
- base::MessageLoopProxy* message_loop) {
- return new JingleSessionManager(message_loop, NULL, NULL, NULL, NULL);
-}
-
-// static
-JingleSessionManager* JingleSessionManager::CreateSandboxed(
- base::MessageLoopProxy* message_loop,
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- HostResolverFactory* host_resolver_factory,
- PortAllocatorSessionFactory* port_allocator_session_factory) {
- return new JingleSessionManager(message_loop, network_manager, socket_factory,
- host_resolver_factory,
- port_allocator_session_factory);
-}
-
JingleSessionManager::JingleSessionManager(
- base::MessageLoopProxy* message_loop,
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- HostResolverFactory* host_resolver_factory,
- PortAllocatorSessionFactory* port_allocator_session_factory)
+ base::MessageLoopProxy* message_loop)
: message_loop_(message_loop),
- network_manager_(network_manager),
- socket_factory_(socket_factory),
- host_resolver_factory_(host_resolver_factory),
- port_allocator_session_factory_(port_allocator_session_factory),
signal_strategy_(NULL),
allow_nat_traversal_(false),
allow_local_ips_(false),
@@ -106,9 +78,8 @@ void JingleSessionManager::Init(
int port_allocator_flags = cricket::PORTALLOCATOR_DISABLE_TCP;
if (allow_nat_traversal) {
- http_port_allocator_ = new remoting::HttpPortAllocator(
- network_manager_.get(), socket_factory_.get(),
- port_allocator_session_factory_.get(), "transp2");
+ http_port_allocator_ = new cricket::HttpPortAllocator(
+ network_manager_.get(), socket_factory_.get(), "transp2");
port_allocator_.reset(http_port_allocator_);
} else {
port_allocator_flags |= cricket::PORTALLOCATOR_DISABLE_STUN |
@@ -130,8 +101,7 @@ void JingleSessionManager::Init(
// If NAT traversal is enabled then we need to request STUN/Relay info.
if (allow_nat_traversal) {
jingle_info_request_.reset(
- new JingleInfoRequest(signal_strategy_->CreateIqRequest(),
- host_resolver_factory_.get()));
+ new JingleInfoRequest(signal_strategy_->CreateIqRequest()));
jingle_info_request_->Send(base::Bind(
&JingleSessionManager::OnJingleInfo, base::Unretained(this)));
} else {
diff --git a/remoting/protocol/jingle_session_manager.h b/remoting/protocol/jingle_session_manager.h
index 35ad26d..f8326c7 100644
--- a/remoting/protocol/jingle_session_manager.h
+++ b/remoting/protocol/jingle_session_manager.h
@@ -16,17 +16,15 @@
#include "third_party/libjingle/source/talk/p2p/base/sessionclient.h"
namespace cricket {
+class HttpPortAllocator;
class PortAllocator;
class SessionManager;
} // namespace cricket
namespace remoting {
-class HostResolverFactory;
-class HttpPortAllocator;
class JingleInfoRequest;
class JingleSignalingConnector;
-class PortAllocatorSessionFactory;
namespace protocol {
@@ -39,14 +37,7 @@ class JingleSessionManager
public:
virtual ~JingleSessionManager();
- static JingleSessionManager* CreateNotSandboxed(
- base::MessageLoopProxy* message_loop);
- static JingleSessionManager* CreateSandboxed(
- base::MessageLoopProxy* message_loop,
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- HostResolverFactory* host_resolver_factory,
- PortAllocatorSessionFactory* port_allocator_session_factory);
+ JingleSessionManager(base::MessageLoopProxy* message_loop);
// SessionManager interface.
virtual void Init(const std::string& local_jid,
@@ -82,13 +73,6 @@ class JingleSessionManager
private:
friend class JingleSession;
- JingleSessionManager(
- base::MessageLoopProxy* message_loop,
- talk_base::NetworkManager* network_manager,
- talk_base::PacketSocketFactory* socket_factory,
- HostResolverFactory* host_resolver_factory,
- PortAllocatorSessionFactory* port_allocator_session_factory);
-
// Called by JingleSession when a new connection is
// initiated. Returns true if session is accepted.
bool AcceptConnection(JingleSession* jingle_session,
@@ -116,8 +100,6 @@ class JingleSessionManager
scoped_ptr<talk_base::NetworkManager> network_manager_;
scoped_ptr<talk_base::PacketSocketFactory> socket_factory_;
- scoped_ptr<HostResolverFactory> host_resolver_factory_;
- scoped_ptr<PortAllocatorSessionFactory> port_allocator_session_factory_;
std::string local_jid_; // Full jid for the local side of the session.
SignalStrategy* signal_strategy_;
@@ -129,7 +111,7 @@ class JingleSessionManager
bool allow_local_ips_;
scoped_ptr<cricket::PortAllocator> port_allocator_;
- remoting::HttpPortAllocator* http_port_allocator_;
+ cricket::HttpPortAllocator* http_port_allocator_;
scoped_ptr<cricket::SessionManager> cricket_session_manager_;
scoped_ptr<JingleInfoRequest> jingle_info_request_;
scoped_ptr<JingleSignalingConnector> jingle_signaling_connector_;
diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc
index adf1af2..745be77 100644
--- a/remoting/protocol/jingle_session_unittest.cc
+++ b/remoting/protocol/jingle_session_unittest.cc
@@ -177,7 +177,7 @@ class JingleSessionTest : public testing::Test {
EXPECT_CALL(host_server_listener_, OnSessionManagerInitialized())
.Times(1);
- host_server_.reset(JingleSessionManager::CreateNotSandboxed(
+ host_server_.reset(new JingleSessionManager(
base::MessageLoopProxy::current()));
host_server_->set_allow_local_ips(true);
host_server_->Init(
@@ -186,7 +186,7 @@ class JingleSessionTest : public testing::Test {
EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized())
.Times(1);
- client_server_.reset(JingleSessionManager::CreateNotSandboxed(
+ client_server_.reset(new JingleSessionManager(
base::MessageLoopProxy::current()));
client_server_->set_allow_local_ips(true);
client_server_->Init(
diff --git a/remoting/protocol/pepper_session_manager.cc b/remoting/protocol/pepper_session_manager.cc
index 28d979d..6eeed0c 100644
--- a/remoting/protocol/pepper_session_manager.cc
+++ b/remoting/protocol/pepper_session_manager.cc
@@ -47,7 +47,7 @@ void PepperSessionManager::Init(
// If NAT traversal is enabled then we need to request STUN/Relay info.
if (allow_nat_traversal) {
jingle_info_request_.reset(
- new JingleInfoRequest(signal_strategy_->CreateIqRequest(), NULL));
+ new JingleInfoRequest(signal_strategy_->CreateIqRequest()));
jingle_info_request_->Send(base::Bind(
&PepperSessionManager::OnJingleInfo, base::Unretained(this)));
} else {
diff --git a/remoting/protocol/protocol_test_client.cc b/remoting/protocol/protocol_test_client.cc
index 3ed5bb5..2029e31 100644
--- a/remoting/protocol/protocol_test_client.cc
+++ b/remoting/protocol/protocol_test_client.cc
@@ -223,7 +223,7 @@ void ProtocolTestClient::Run(const std::string& username,
new XmppSignalStrategy(&jingle_thread, username, auth_token,
auth_service));
signal_strategy_->Init(this);
- session_manager_.reset(JingleSessionManager::CreateNotSandboxed(
+ session_manager_.reset(new JingleSessionManager(
jingle_thread.message_loop_proxy()));
host_jid_ = host_jid;
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 12ace05..2a88d64 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -174,8 +174,6 @@
'client/plugin/pepper_entrypoints.h',
'client/plugin/pepper_input_handler.cc',
'client/plugin/pepper_input_handler.h',
- 'client/plugin/pepper_port_allocator_session.cc',
- 'client/plugin/pepper_port_allocator_session.h',
'client/plugin/pepper_plugin_thread_delegate.cc',
'client/plugin/pepper_plugin_thread_delegate.h',
'client/plugin/pepper_view.cc',
@@ -606,10 +604,6 @@
'../third_party/libjingle/libjingle.gyp:libjingle_p2p',
],
'sources': [
- 'jingle_glue/host_resolver.cc',
- 'jingle_glue/host_resolver.h',
- 'jingle_glue/http_port_allocator.cc',
- 'jingle_glue/http_port_allocator.h',
'jingle_glue/iq_request.cc',
'jingle_glue/iq_request.h',
'jingle_glue/javascript_iq_request.cc',