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

Unified Diff: remoting/jingle_glue/signal_strategy.h

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 12 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/jingle_glue/mock_objects.h ('k') | remoting/jingle_glue/xmpp_signal_strategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/jingle_glue/signal_strategy.h
diff --git a/remoting/jingle_glue/signal_strategy.h b/remoting/jingle_glue/signal_strategy.h
index c4bfabee1226562055182499720df6cc04671a26..a71e3c721a01f9346e5d1ec0743098d9162ab514 100644
--- a/remoting/jingle_glue/signal_strategy.h
+++ b/remoting/jingle_glue/signal_strategy.h
@@ -17,33 +17,55 @@ namespace remoting {
class SignalStrategy {
public:
- class StatusObserver {
- public:
- enum State {
- START,
- CONNECTING,
- CONNECTED,
- CLOSED,
- };
-
- // Called when state of the connection is changed.
- virtual void OnStateChange(State state) = 0;
- virtual void OnJidChange(const std::string& full_jid) = 0;
+ enum State {
+ // Connection is being established.
+ CONNECTING,
+
+ // Signalling is connected.
+ CONNECTED,
+
+ // Connection is closed due to an error or because Disconnect()
+ // was called.
+ DISCONNECTED,
};
+ // Callback interface for signaling event. Event handlers are not
+ // allowed to destroy SignalStrategy, but may add or remove other
+ // listeners.
class Listener {
public:
+ virtual ~Listener() {}
+
+ // Called after state of the connection has changed.
+ virtual void OnSignalStrategyStateChange(State state) {}
+
// Must return true if the stanza was handled, false otherwise.
- virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) = 0;
+ virtual bool OnSignalStrategyIncomingStanza(
+ const buzz::XmlElement* stanza) { return false; }
};
SignalStrategy() {}
virtual ~SignalStrategy() {}
- virtual void Init(StatusObserver* observer) = 0;
- virtual void Close() = 0;
+
+ // Starts connection attempt. If connection is currently active
+ // disconnects it and opens a new connection (implicit disconnect
+ // triggers CLOSED notification). Connection is finished
+ // asynchronously.
+ virtual void Connect() = 0;
+
+ // Disconnects current connection if connected. Triggers CLOSED
+ // notification.
+ virtual void Disconnect() = 0;
+
+ // Returns current state.
+ virtual State GetState() const = 0;
+
+ // Returns local JID or an empty string when not connected.
+ virtual std::string GetLocalJid() const = 0;
// Add a |listener| that can listen to all incoming
- // messages. Doesn't take ownership of the |listener|.
+ // messages. Doesn't take ownership of the |listener|. All listeners
+ // must be removed before this object is destroyed.
virtual void AddListener(Listener* listener) = 0;
// Remove a |listener| previously added with AddListener().
« no previous file with comments | « remoting/jingle_glue/mock_objects.h ('k') | remoting/jingle_glue/xmpp_signal_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698