summaryrefslogtreecommitdiffstats
path: root/remoting/host/chromoting_host.h
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 04:27:49 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 04:27:49 +0000
commit9cfb0c35a8ee5bb7f1ee22063e4b5d4bc2b62d3d (patch)
tree419e5567d6e33222e350438cc20809274a77d480 /remoting/host/chromoting_host.h
parent6efcdcd281eac224b621474f4a82bece49e94ba9 (diff)
downloadchromium_src-9cfb0c35a8ee5bb7f1ee22063e4b5d4bc2b62d3d.zip
chromium_src-9cfb0c35a8ee5bb7f1ee22063e4b5d4bc2b62d3d.tar.gz
chromium_src-9cfb0c35a8ee5bb7f1ee22063e4b5d4bc2b62d3d.tar.bz2
Moving host status events monitoring to a separate interface (HostStatusMonitor).
This CL unbinds the host status event observers from ChromotingHost. This is useful when, for instance, an observer resides in a different process where ChromotingHost is not available. Additionally, observers get HostStatusMonitor as a weak pointer, making sure that they do not need to worry about HostStatusMonitor's life time. BUG=178873 Review URL: https://chromiumcodereview.appspot.com/12386035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/chromoting_host.h')
-rw-r--r--remoting/host/chromoting_host.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index bfd4dca..d755744 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -10,11 +10,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/threading/thread.h"
#include "net/base/backoff_entry.h"
#include "remoting/host/client_session.h"
#include "remoting/host/host_key_pair.h"
+#include "remoting/host/host_status_monitor.h"
#include "remoting/host/host_status_observer.h"
#include "remoting/host/mouse_move_observer.h"
#include "remoting/protocol/authenticator.h"
@@ -62,6 +64,7 @@ class DesktopEnvironmentFactory;
class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
public ClientSession::EventHandler,
public protocol::SessionManager::Listener,
+ public HostStatusMonitor,
public MouseMoveObserver {
public:
// The caller must ensure that |signal_strategy| and
@@ -90,10 +93,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// called after shutdown is completed.
void Shutdown(const base::Closure& shutdown_task);
- // Add/Remove |observer| to/from the list of status observers. Both
- // methods can be called on the network thread only.
- void AddStatusObserver(HostStatusObserver* observer);
- void RemoveStatusObserver(HostStatusObserver* observer);
+ // HostStatusMonitor interface.
+ virtual void AddStatusObserver(HostStatusObserver* observer) OVERRIDE;
+ virtual void RemoveStatusObserver(HostStatusObserver* observer) OVERRIDE;
// This method may be called only from
// HostStatusObserver::OnClientAuthenticated() to reject the new
@@ -151,6 +153,10 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// clients that were not connected when this method is called.
void DisconnectAllClients();
+ base::WeakPtr<ChromotingHost> AsWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+ }
+
private:
friend class base::RefCountedThreadSafe<ChromotingHost>;
friend class ChromotingHostTest;
@@ -211,6 +217,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// The maximum duration of any session.
base::TimeDelta max_session_duration_;
+ base::WeakPtrFactory<ChromotingHost> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
};