diff options
author | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 05:10:43 +0000 |
---|---|---|
committer | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 05:10:43 +0000 |
commit | 49aa8fa463615a4d4ad345b492fab72aba0f8a27 (patch) | |
tree | 53fb835d6b2e51fcc05bd6529352d09492f15260 /remoting/host/host_change_notification_listener.h | |
parent | dc1f8546772aaaf0460afedd894c0c1c270b8890 (diff) | |
download | chromium_src-49aa8fa463615a4d4ad345b492fab72aba0f8a27.zip chromium_src-49aa8fa463615a4d4ad345b492fab72aba0f8a27.tar.gz chromium_src-49aa8fa463615a4d4ad345b492fab72aba0f8a27.tar.bz2 |
Implement a listener for host deletion notifications.
The directory server notifies the host (via the bot) when an entry is deleted (e.g. by clicking X on the webapp), and the host exits immediately (rather than up to 5 minutes later, when its next heartbeat failed).
BUG=163572
Review URL: https://chromiumcodereview.appspot.com/12045085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/host_change_notification_listener.h')
-rw-r--r-- | remoting/host/host_change_notification_listener.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/remoting/host/host_change_notification_listener.h b/remoting/host/host_change_notification_listener.h new file mode 100644 index 0000000..19ee106 --- /dev/null +++ b/remoting/host/host_change_notification_listener.h @@ -0,0 +1,59 @@ +// Copyright (c) 2013 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_HOST_HOST_CHANGE_NOTIFICATION_LISTENER_H +#define REMOTING_HOST_HOST_CHANGE_NOTIFICATION_LISTENER_H + +#include <string> + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "remoting/jingle_glue/signal_strategy.h" + +namespace buzz { +class XmlElement; +} // namespace buzz + +namespace remoting { + +// HostChangeNotificationListener listens for messages from the remoting bot +// indicating that its host entry has been changed in the directory. +// If a message is received indicating that the host was deleted, it uses the +// OnHostDeleted callback to shut down the host. +class HostChangeNotificationListener : public SignalStrategy::Listener { + public: + class Listener { + protected: + virtual ~Listener() {} + // Invoked when a notification that the host was deleted is received. + public: + virtual void OnHostDeleted() = 0; + }; + + // Both listener and signal_strategy are expected to outlive this object. + HostChangeNotificationListener(Listener* listener, + const std::string& host_id, + SignalStrategy* signal_strategy); + virtual ~HostChangeNotificationListener(); + + // SignalStrategy::Listener interface. + virtual void OnSignalStrategyStateChange( + SignalStrategy::State state) OVERRIDE; + virtual bool OnSignalStrategyIncomingStanza( + const buzz::XmlElement* stanza) OVERRIDE; + + private: + void OnHostDeleted(); + + Listener* listener_; + std::string host_id_; + SignalStrategy* signal_strategy_; + base::WeakPtrFactory<HostChangeNotificationListener> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(HostChangeNotificationListener); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_HOST_CHANGE_NOTIFICATION_LISTENER_H |