Chromium Code Reviews| Index: remoting/host/chromoting_host.h |
| diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h |
| index b1cd128ff929ab99f422acc66c4b9a4421f6b264..0e1d53dbf14b5b2c8b9b54c6bf70271c62cd5b4c 100644 |
| --- a/remoting/host/chromoting_host.h |
| +++ b/remoting/host/chromoting_host.h |
| @@ -12,6 +12,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/observer_list.h" |
| +#include "base/threading/non_thread_safe.h" |
| #include "base/threading/thread.h" |
| #include "net/base/backoff_entry.h" |
| #include "remoting/host/client_session.h" |
| @@ -59,14 +60,13 @@ class DesktopEnvironmentFactory; |
| // 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 ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| +class ChromotingHost : public base::NonThreadSafe, |
| public ClientSession::EventHandler, |
| public protocol::SessionManager::Listener, |
| public HostStatusMonitor { |
| public: |
| - // The caller must ensure that |signal_strategy| and |
| - // |desktop_environment_factory| remain valid at least until the |
| - // |shutdown_task| supplied to Shutdown() has been notified. |
| + // Both |signal_strategy| and |desktop_environment_factory| should outlive |
| + // this object. |
| ChromotingHost( |
| SignalStrategy* signal_strategy, |
| DesktopEnvironmentFactory* desktop_environment_factory, |
| @@ -77,8 +77,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
| scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| + virtual ~ChromotingHost(); |
| - // Asynchronously start the host process. |
| + // Asynchronously starts the host. |
| // |
| // After this is invoked, the host process will connect to the talk |
| // network and start listening for incoming connections. |
| @@ -86,10 +87,6 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| // This method can only be called once during the lifetime of this object. |
| void Start(const std::string& xmpp_login); |
| - // Asynchronously shutdown the host process. |shutdown_task| is |
| - // called after shutdown is completed. |
| - void Shutdown(const base::Closure& shutdown_task); |
| - |
| // HostStatusMonitor interface. |
| virtual void AddStatusObserver(HostStatusObserver* observer) OVERRIDE; |
| virtual void RemoveStatusObserver(HostStatusObserver* observer) OVERRIDE; |
| @@ -134,10 +131,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| // Sets desired configuration for the protocol. Must be called before Start(). |
| void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config); |
| - // Disconnects all active clients. Clients are disconnected |
| - // asynchronously when this method is called on a thread other than |
| - // the network thread. Potentically this may cause disconnection of |
| - // clients that were not connected when this method is called. |
| + // Disconnects all active clients synchronously. Sub-components might shutdown |
|
Wez
2013/04/15 19:50:04
nit: synchronously implies blocking. Suggest:
"I
alexeypa (please no reviews)
2013/04/15 20:04:42
Done.
|
| + // asynchronously (when they are running on different threads). No callbacks |
| + // will be posted to the host in any case. |
| void DisconnectAllClients(); |
| base::WeakPtr<ChromotingHost> AsWeakPtr() { |
| @@ -145,23 +141,10 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| } |
| private: |
| - friend class base::RefCountedThreadSafe<ChromotingHost>; |
| friend class ChromotingHostTest; |
| typedef std::list<ClientSession*> ClientList; |
| - enum State { |
| - kInitial, |
| - kStarted, |
| - kStopping, |
| - kStopped, |
| - }; |
| - |
| - virtual ~ChromotingHost(); |
| - |
| - // Called from Shutdown() to finish shutdown. |
| - void ShutdownFinish(); |
| - |
| // Unless specified otherwise all members of this class must be |
| // used on the network thread only. |
| @@ -184,8 +167,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| // The connections to remote clients. |
| ClientList clients_; |
| - // Tracks the internal state of the host. |
| - State state_; |
| + // True if the host has been started. |
| + bool started_; |
| // Configuration of the protocol. |
| scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; |
| @@ -197,10 +180,6 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| bool authenticating_client_; |
| bool reject_authenticating_client_; |
| - // Stores list of tasks that should be executed when we finish |
| - // shutdown. Used only while |state_| is set to kStopping. |
| - std::vector<base::Closure> shutdown_tasks_; |
| - |
| // The maximum duration of any session. |
| base::TimeDelta max_session_duration_; |