| 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().
|
|
|