Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: remoting/host/simple_host.h

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/session_manager_unittest.cc ('k') | remoting/host/simple_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/simple_host.h
===================================================================
--- remoting/host/simple_host.h (revision 0)
+++ remoting/host/simple_host.h (revision 0)
@@ -0,0 +1,131 @@
+// 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.
+
+#ifndef REMOTING_SIMPLE_HOST_H_
+#define REMOTING_SIMPLE_HOST_H_
+
+#include <string>
+
+#include "base/thread.h"
+#include "remoting/host/capturer.h"
+#include "remoting/host/client_connection.h"
+#include "remoting/host/encoder.h"
+#include "remoting/host/event_executor.h"
+#include "remoting/host/heartbeat_sender.h"
+#include "remoting/host/session_manager.h"
+#include "remoting/jingle_glue/jingle_client.h"
+
+namespace remoting {
+
+// A class to implement the functionality of a host process.
+//
+// Here's the work flow of this class:
+// 1. We should load the saved GAIA ID token or if this is the first
+// time the host process runs we should prompt user for the
+// credential. We will use this token or credentials to authenicate
+// and register the host.
+//
+// 2. We listen for incoming connection using libjingle. We will create
+// a ClientConnection object that wraps around linjingle for transport. Also
+// create a SessionManager with appropriate Encoder and Capturer and
+// add the ClientConnection to this SessionManager for transporting the
+// screen captures. A EventExecutor is created and registered with the
+// ClientConnection to receive mouse / keyboard events from the remote
+// client.
+// This is also the right time to create multiple threads to host
+// the above objects. After we have done all the initialization
+// we'll start the SessionManager. We'll then enter the running state
+// of the host process.
+//
+// 3. When the user is disconencted, we will pause the SessionManager
+// and try to terminate the threads we have created. This will allow
+// all pending tasks to complete. After all of that completed we
+// return to the idle state. We then go to step (2) if there a new
+// incoming connection.
+class SimpleHost : public base::RefCountedThreadSafe<SimpleHost>,
+ public ClientConnection::EventHandler,
+ public JingleClient::Callback {
+ public:
+ SimpleHost(const std::string& username, const std::string& password,
+ Capturer* capturer, Encoder* encoder, EventExecutor* executor);
+
+ // Run the host porcess. This method returns only after the message loop
+ // of the host process exits.
+ void Run();
+
+ // This method is called when we need to the host process.
+ void DestroySession();
+
+ // This method talks to the cloud to register the host process. If
+ // successful we will start listening to network requests.
+ void RegisterHost();
+
+ // This method is called if a client is connected to this object.
+ void OnClientConnected(ClientConnection* client);
+
+ // This method is called if a client is disconnected from the host.
+ void OnClientDisconnected(ClientConnection* client);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // ClientConnection::EventHandler implementations
+ virtual void HandleMessages(ClientConnection* client,
+ ClientMessageList* messages);
+ virtual void OnConnectionOpened(ClientConnection* client);
+ virtual void OnConnectionClosed(ClientConnection* client);
+ virtual void OnConnectionFailed(ClientConnection* client);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // JingleClient::Callback implementations
+ virtual void OnStateChange(JingleClient* client, JingleClient::State state);
+ virtual bool OnAcceptConnection(
+ JingleClient* jingle, const std::string& jid,
+ JingleChannel::Callback** channel_callback);
+ virtual void OnNewConnection(
+ JingleClient* jingle,
+ scoped_refptr<JingleChannel> channel);
+
+ private:
+ // The message loop that this class runs on.
+ MessageLoop main_loop_;
+
+ // A thread that hosts capture operations.
+ base::Thread capture_thread_;
+
+ // A thread that hosts encode operations.
+ base::Thread encode_thread_;
+
+ std::string username_;
+ std::string password_;
+
+ // Capturer to be used by SessionManager. Once the SessionManager is
+ // constructed this is set to NULL.
+ scoped_ptr<Capturer> capturer_;
+
+ // Encoder to be used by the SessionManager. Once the SessionManager is
+ // constructed this is set to NULL.
+ scoped_ptr<Encoder> encoder_;
+
+ // EventExecutor executes input events received from the client.
+ scoped_ptr<EventExecutor> executor_;
+
+ // The libjingle client. This is used to connect to the talk network to
+ // receive connection requests from chromoting client.
+ scoped_refptr<JingleClient> jingle_client_;
+
+ // Objects that takes care of sending heartbeats to the chromoting bot.
+ scoped_refptr<HeartbeatSender> heartbeat_sender_;
+
+ // A ClientConnection manages the connectino to a remote client.
+ // TODO(hclam): Expand this to a list of clients.
+ scoped_refptr<ClientConnection> client_;
+
+ // Session manager for the host process.
+ scoped_refptr<SessionManager> session_;
+
+ DISALLOW_COPY_AND_ASSIGN(SimpleHost);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_SIMPLE_HOST_H_
Property changes on: remoting/host/simple_host.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « remoting/host/session_manager_unittest.cc ('k') | remoting/host/simple_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698