chromoting_host.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef REMOTING_HOST_CHROMOTING_HOST_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define REMOTING_HOST_CHROMOTING_HOST_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/observer_list.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/threading/thread.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/backoff_entry.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/host/client_session.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/host/host_key_pair.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/host/host_status_observer.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/host/mouse_move_observer.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/host/ui_strings.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/protocol/authenticator.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/protocol/session_manager.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "remoting/protocol/connection_to_client.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkSize.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SingleThreadTaskRunner;
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace base
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace remoting {
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace protocol {
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InputStub;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SessionConfig;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CandidateSessionConfig;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace protocol
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DesktopEnvironmentFactory;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A class to implement the functionality of a host process.
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Here's the work flow of this class:
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1. We should load the saved GAIA ID token or if this is the first
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    time the host process runs we should prompt user for the
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    credential. We will use this token or credentials to authenicate
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    and register the host.
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2. We listen for incoming connection using libjingle. We will create
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    a ConnectionToClient object that wraps around linjingle for transport.
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    A ScreenRecorder is created with an Encoder and a VideoFrameCapturer.
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    A ConnectionToClient is added to the ScreenRecorder for transporting
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    the screen captures. An InputStub is created and registered with the
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    ConnectionToClient to receive mouse / keyboard events from the remote
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    client.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    After we have done all the initialization we'll start the ScreenRecorder.
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    We'll then enter the running state of the host process.
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 3. When the user is disconnected, we will pause the ScreenRecorder
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    and try to terminate the threads we have created. This will allow
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    all pending tasks to complete. After all of that completed we
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    return to the idle state. We then go to step (2) if there a new
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    incoming connection.
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       public ClientSession::EventHandler,
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       public protocol::SessionManager::Listener,
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       public MouseMoveObserver {
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The caller must ensure that |signal_strategy| and
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |desktop_environment_factory| remain valid at least until the
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |shutdown_task| supplied to Shutdown() has been notified.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ChromotingHost(
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      SignalStrategy* signal_strategy,
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      DesktopEnvironmentFactory* desktop_environment_factory,
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_ptr<protocol::SessionManager> session_manager,
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Asynchronously start the host process.
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // After this is invoked, the host process will connect to the talk
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // network and start listening for incoming connections.
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method can only be called once during the lifetime of this object.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Start(const std::string& xmpp_login);
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Asynchronously shutdown the host process. |shutdown_task| is
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // called after shutdown is completed.
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Shutdown(const base::Closure& shutdown_task);
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Add/Remove |observer| to/from the list of status observers. Both
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // methods can be called on the network thread only.
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddStatusObserver(HostStatusObserver* observer);
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RemoveStatusObserver(HostStatusObserver* observer);
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method may be called only from
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // HostStatusObserver::OnClientAuthenticated() to reject the new
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // client.
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void RejectAuthenticatingClient();
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the authenticator factory to use for incoming
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // connections. Incoming connections are rejected until
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // authenticator factory is set. Must be called on the network
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // thread after the host is started. Must not be called more than
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // once per host instance because it may not be safe to delete
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // factory before all authenticators it created are deleted.
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetAuthenticatorFactory(
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory);
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the maximum duration of any session. By default, a session has no
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // maximum duration.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetMaximumSessionDuration(const base::TimeDelta& max_session_duration);
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ////////////////////////////////////////////////////////////////////////////
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ClientSession::EventHandler implementation.
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE;
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionChannelsConnected(ClientSession* client) OVERRIDE;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE;
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionClosed(ClientSession* session) OVERRIDE;
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionSequenceNumber(ClientSession* session,
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       int64 sequence_number) OVERRIDE;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionRouteChange(
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      ClientSession* session,
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::string& channel_name,
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const protocol::TransportRoute& route) OVERRIDE;
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnClientDimensionsChanged(ClientSession* session,
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         const SkISize& size) OVERRIDE;
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // SessionManager::Listener implementation.
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnSessionManagerReady() OVERRIDE;
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnIncomingSession(
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      protocol::Session* session,
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE;
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // MouseMoveObserver interface.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnLocalMouseMoved(const SkIPoint& new_pos) OVERRIDE;
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets desired configuration for the protocol. Must be called before Start().
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config);
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Pause or unpause the session. While the session is paused, remote input
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is ignored. Can be called from any thread.
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PauseSession(bool pause);
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Disconnects all active clients. Clients are disconnected
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // asynchronously when this method is called on a thread other than
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the network thread. Potentically this may cause disconnection of
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // clients that were not connected when this method is called.
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DisconnectAllClients();
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Disconnects the client that is using |desktop_environment|, if any.
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DisconnectClient(DesktopEnvironment* desktop_environment);
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const UiStrings& ui_strings() { return ui_strings_; }
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set localized strings. Must be called before host is started.
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetUiStrings(const UiStrings& ui_strings);
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class base::RefCountedThreadSafe<ChromotingHost>;
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class ChromotingHostTest;
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef std::vector<scoped_refptr<ClientSession> > ClientList;
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum State {
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    kInitial,
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    kStarted,
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    kStopping,
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    kStopped,
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~ChromotingHost();
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a client session is stopped completely.
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnClientStopped();
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called from Shutdown() to finish shutdown.
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ShutdownFinish();
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Unless specified otherwise all members of this class must be
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used on the network thread only.
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Parameters specified when the host was created.
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DesktopEnvironmentFactory* desktop_environment_factory_;
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<protocol::SessionManager> session_manager_;
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Connection objects.
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SignalStrategy* signal_strategy_;
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Must be used on the network thread only.
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ObserverList<HostStatusObserver> status_observers_;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The connections to remote clients.
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ClientList clients_;
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The number of allocated |ClientSession| objects. |clients_count_| can be
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // greater than |clients_.size()| because it also includes the objects that
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // are about to be deleted.
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int clients_count_;
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tracks the internal state of the host.
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  State state_;
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Configuration of the protocol.
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<protocol::CandidateSessionConfig> protocol_config_;
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Login backoff state.
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  net::BackoffEntry login_backoff_;
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Flags used for RejectAuthenticatingClient().
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool authenticating_client_;
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool reject_authenticating_client_;
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Stores list of tasks that should be executed when we finish
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // shutdown. Used only while |state_| is set to kStopping.
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<base::Closure> shutdown_tasks_;
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sergeyu): The following members do not belong to
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ChromotingHost and should be moved elsewhere.
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  UiStrings ui_strings_;
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The maximum duration of any session.
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::TimeDelta max_session_duration_;
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace remoting
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // REMOTING_HOST_CHROMOTING_HOST_H_
236