diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 18:11:26 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 18:11:26 +0000 |
commit | 33b7c47777e2b88e6a876cc48a562f03d5dddae4 (patch) | |
tree | 8a54c9b4970ae970d0df0bf8cd6d420fb3d1c3a2 /remoting/client/jingle_host_connection.h | |
parent | 8d5c43c4a9958b592565da16912fd44960aab906 (diff) | |
download | chromium_src-33b7c47777e2b88e6a876cc48a562f03d5dddae4.zip chromium_src-33b7c47777e2b88e6a876cc48a562f03d5dddae4.tar.gz chromium_src-33b7c47777e2b88e6a876cc48a562f03d5dddae4.tar.bz2 |
Separate out HostConnection into an interface and a jingle-based
implementation. Refactor to inject the running thread for Jingle.
Review URL: http://codereview.chromium.org/2753006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/jingle_host_connection.h')
-rw-r--r-- | remoting/client/jingle_host_connection.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/remoting/client/jingle_host_connection.h b/remoting/client/jingle_host_connection.h new file mode 100644 index 0000000..00faaa1 --- /dev/null +++ b/remoting/client/jingle_host_connection.h @@ -0,0 +1,83 @@ +// Copyright (c) 2010 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. + +// JingleHostConnection implements the HostConnection interface using +// libjingle as the transport protocol. +// +// Much of this class focuses on translating JingleClient and JingleChannel +// callbacks into HostConnection::HostEventCallback messages. +// +// The public API of this class is designed to be asynchronous, and thread +// safe for invocation from other threads. +// +// Internally though, all work delegeated to the |network_thread| given +// during construction. Any event handlers running on the |network_thread| +// should not block. + +#ifndef REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ +#define REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ + +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "remoting/base/protocol_decoder.h" +#include "remoting/client/host_connection.h" +#include "remoting/jingle_glue/jingle_channel.h" +#include "remoting/jingle_glue/jingle_client.h" + +class MessageLoop; + +namespace remoting { + +class JingleThread; + +class JingleHostConnection : + public base::RefCountedThreadSafe<JingleHostConnection>, + public HostConnection, + public JingleChannel::Callback, + public JingleClient::Callback { + public: + JingleHostConnection(JingleThread* network_thread, + HostEventCallback* event_callback); + virtual ~JingleHostConnection(); + + virtual void Connect(const std::string& username, + const std::string& auth_token, + const std::string& host_jid); + virtual void Disconnect(); + + // JingleChannel::Callback interface. + virtual void OnStateChange(JingleChannel* channel, + JingleChannel::State state); + virtual void OnPacketReceived(JingleChannel* channel, + scoped_refptr<media::DataBuffer> buffer); + + // JingleClient::Callback interface. + virtual void OnStateChange(JingleClient* client, JingleClient::State state); + virtual bool OnAcceptConnection(JingleClient* client, const std::string& jid, + JingleChannel::Callback** callback); + virtual void OnNewConnection(JingleClient* client, + scoped_refptr<JingleChannel> channel); + + private: + MessageLoop* message_loop(); + + void DoConnect(const std::string& username, + const std::string& auth_token, + const std::string& host_jid); + void DoDisconnect(); + + JingleThread* network_thread_; + + scoped_refptr<JingleClient> jingle_client_; + scoped_refptr<JingleChannel> jingle_channel_; + + ProtocolDecoder decoder_; + HostEventCallback* event_callback_; + + DISALLOW_COPY_AND_ASSIGN(JingleHostConnection); +}; + +} // namespace remoting + +#endif // REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ |