diff options
-rw-r--r-- | remoting/jingle_glue/http_port_allocator.cc | 28 | ||||
-rw-r--r-- | remoting/jingle_glue/http_port_allocator.h | 35 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 6 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
4 files changed, 68 insertions, 3 deletions
diff --git a/remoting/jingle_glue/http_port_allocator.cc b/remoting/jingle_glue/http_port_allocator.cc new file mode 100644 index 0000000..9079ff8 --- /dev/null +++ b/remoting/jingle_glue/http_port_allocator.cc @@ -0,0 +1,28 @@ +// 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 { + +HttpPortAllocator::HttpPortAllocator( + talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_factory, + const std::string &user_agent) + : cricket::HttpPortAllocator(network_manager, + socket_factory, + user_agent) { +} + +HttpPortAllocator::~HttpPortAllocator() { +} + +cricket::PortAllocatorSession *HttpPortAllocator::CreateSession( + const std::string& name, const std::string& session_type) { + 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 new file mode 100644 index 0000000..0dbc861 --- /dev/null +++ b/remoting/jingle_glue/http_port_allocator.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. + +// 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 "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" + +namespace remoting { + +class HttpPortAllocator : public cricket::HttpPortAllocator { + public: + HttpPortAllocator(talk_base::NetworkManager* network_manager, + talk_base::PacketSocketFactory* socket_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: + DISALLOW_COPY_AND_ASSIGN(HttpPortAllocator); +}; + +} // namespace remoting + +#endif // REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_ diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index fd0bd5b..3f89340 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h" +#include "remoting/jingle_glue/http_port_allocator.h" #include "remoting/jingle_glue/iq_request.h" #include "remoting/jingle_glue/jingle_info_task.h" #include "remoting/jingle_glue/jingle_thread.h" @@ -16,7 +17,6 @@ #include "third_party/libjingle/source/talk/base/ssladapter.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/p2p/client/sessionmanagertask.h" #include "third_party/libjingle/source/talk/session/tunnel/tunnelsessionclient.h" #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" @@ -239,8 +239,8 @@ void JingleClient::DoInitialize() { } port_allocator_.reset( - new cricket::HttpPortAllocator(network_manager_.get(), - socket_factory_.get(), "transp2")); + new HttpPortAllocator(network_manager_.get(), + socket_factory_.get(), "transp2")); // TODO(ajwong): The strategy needs a "start" command or something. Right // now, Init() implicitly starts processing events. Thus, we must have the // other fields of JingleClient initialized first, otherwise the state-change diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index ba5507d..f651a9c 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -344,6 +344,8 @@ 'sources': [ 'jingle_glue/channel_socket_adapter.cc', 'jingle_glue/channel_socket_adapter.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/jingle_client.cc', |