diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-03 21:02:39 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-03 21:02:39 +0000 |
commit | 08128a313552198dce04295ad7e12071f4860161 (patch) | |
tree | 34d0682f03badf0e0b6c27ff2b78da4289dca650 /remoting/jingle_glue/signal_strategy.h | |
parent | 1e42174b401dbf8105ec4e5d864bad1c906c5717 (diff) | |
download | chromium_src-08128a313552198dce04295ad7e12071f4860161.zip chromium_src-08128a313552198dce04295ad7e12071f4860161.tar.gz chromium_src-08128a313552198dce04295ad7e12071f4860161.tar.bz2 |
Refactor SignalStrategy so that it can be reused for multiple connections.
Also updated SessionManager implementation so that session managers can
be created before signaling is connected.
BUG=107276
Review URL: http://codereview.chromium.org/9005034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue/signal_strategy.h')
-rw-r--r-- | remoting/jingle_glue/signal_strategy.h | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/remoting/jingle_glue/signal_strategy.h b/remoting/jingle_glue/signal_strategy.h index c4bfabe..a71e3c7 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(). |