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

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 9 years 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
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..b2d69c24578bb6e14135e8edf69f105be4f8523d 100644
--- a/remoting/jingle_glue/signal_strategy.h
+++ b/remoting/jingle_glue/signal_strategy.h
@@ -17,30 +17,46 @@ 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.
+ CLOSED,
Wez 2011/12/21 23:35:30 CONNECTED -> DISCONNECTED, or OPEN -> CLOSED
Sergey Ulanov 2011/12/22 21:45:10 Done.
};
class Listener {
public:
+ virtual ~Listener() {}
+
+ // Called after state of the connection has changed.
+ virtual void OnSignalStrategyStateChange(State state) = 0;
Wez 2011/12/21 23:35:30 Is it safe to tear-down the SignallingStrategy fro
Wez 2011/12/21 23:35:30 Consider giving this a default empty implementatio
Sergey Ulanov 2011/12/22 21:45:10 Done.
Sergey Ulanov 2011/12/22 21:45:10 Done.
+
// Must return true if the stanza was handled, false otherwise.
- virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) = 0;
+ virtual bool OnSignalStrategyIncomingStanza(
Wez 2011/12/21 23:35:30 Same here?
Sergey Ulanov 2011/12/22 21:45:10 Done.
+ const buzz::XmlElement* stanza) = 0;
};
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. Connection is finished
Wez 2011/12/21 23:35:30 Will the implicit disconnect trigger a CLOSED noti
Sergey Ulanov 2011/12/22 21:45:10 Done.
+ // asynchronously.
+ virtual void Connect() = 0;
+
+ // Disconnects current connection.
+ virtual void Disconnect() = 0;
Wez 2011/12/21 23:35:30 Will the Listeners see CLOSED notifications?
Sergey Ulanov 2011/12/22 21:45:10 Done.
+
+ // Returns current state.
+ virtual State GetState() const = 0;
+
+ // Returns local JID or an empty string when not connected.
+ virtual std::string GetLocalJid() const = 0;
Wez 2011/12/21 23:35:30 nit: GetLocalEndpointId? This interface is notion
Sergey Ulanov 2011/12/22 21:45:10 This interface is specific to XMPP signalling mess
// Add a |listener| that can listen to all incoming
// messages. Doesn't take ownership of the |listener|.
Wez 2011/12/21 23:35:30 Do Listeners need removing before teardown?
Sergey Ulanov 2011/12/22 21:45:10 Done.

Powered by Google App Engine
This is Rietveld 408576698