summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/connection_to_host.h
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/protocol/connection_to_host.h')
-rw-r--r--remoting/protocol/connection_to_host.h70
1 files changed, 62 insertions, 8 deletions
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index c3b2c54..515b89a 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -9,18 +9,32 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "base/task.h"
+#include "remoting/jingle_glue/jingle_client.h"
#include "remoting/proto/internal.pb.h"
+#include "remoting/protocol/connection_to_host.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/input_stub.h"
+#include "remoting/protocol/message_reader.h"
+#include "remoting/protocol/session.h"
+#include "remoting/protocol/session_manager.h"
+
+class MessageLoop;
namespace remoting {
+
+class JingleThread;
+class VideoPacket;
+
namespace protocol {
+class ClientMessageDispatcher;
class ClientStub;
class SessionConfig;
+class VideoReader;
class VideoStub;
-class ConnectionToHost {
+class ConnectionToHost : public JingleClient::Callback {
public:
class HostEventCallback {
public:
@@ -36,6 +50,8 @@ class ConnectionToHost {
virtual void OnConnectionFailed(ConnectionToHost* conn) = 0;
};
+ // TODO(sergeyu): Constructor shouldn't need thread here.
+ explicit ConnectionToHost(JingleThread* thread);
virtual ~ConnectionToHost();
// TODO(ajwong): We need to generalize this API.
@@ -44,20 +60,56 @@ class ConnectionToHost {
const std::string& host_jid,
HostEventCallback* event_callback,
ClientStub* client_stub,
- VideoStub* video_stub) = 0;
- virtual void Disconnect() = 0;
+ VideoStub* video_stub);
+ virtual void Disconnect();
- virtual const SessionConfig* config() = 0;
+ virtual const SessionConfig* config();
virtual InputStub* input_stub();
virtual HostStub* host_stub();
- protected:
- ConnectionToHost();
+ // JingleClient::Callback interface.
+ virtual void OnStateChange(JingleClient* client, JingleClient::State state);
+
+ // Callback for chromotocol SessionManager.
+ void OnNewSession(
+ Session* connection,
+ SessionManager::IncomingSessionResponse* response);
+
+ // Callback for chromotocol Session.
+ void OnSessionStateChange(Session::State state);
+
+ private:
+ // The message loop for the jingle thread this object works on.
+ MessageLoop* message_loop();
+
+ // Called on the jingle thread after we've successfully to XMPP server. Starts
+ // P2P connection to the host.
+ void InitSession();
+
+ // Callback for |video_reader_|.
+ void OnVideoPacket(VideoPacket* packet);
+
+ // Used by Disconnect() to disconnect chromoting connection, stop chromoting
+ // server, and then disconnect XMPP connection.
+ void OnDisconnected();
+ void OnServerClosed();
+
+ JingleThread* thread_;
+
+ scoped_refptr<JingleClient> jingle_client_;
+ scoped_refptr<SessionManager> session_manager_;
+ scoped_refptr<Session> session_;
+
+ scoped_ptr<VideoReader> video_reader_;
+
+ HostEventCallback* event_callback_;
+
+ std::string host_jid_;
+
+ scoped_ptr<ClientMessageDispatcher> dispatcher_;
- //private: TODO(garykac). Merge jingle_connection_to_host up into this class
- // and then make these private again.
////////////////////////////////////////////////////////////////////////////
// User input event channel interface
@@ -86,4 +138,6 @@ class ConnectionToHost {
} // namespace protocol
} // namespace remoting
+DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::ConnectionToHost);
+
#endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_