diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-07 03:09:29 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-07 03:09:29 +0000 |
commit | 8f1f23544925516776eef5b6346107e08ef807e8 (patch) | |
tree | 652c06d265de2e11271c36942afd51e1d6414e95 /remoting/jingle_glue | |
parent | 4b5161550ea66a221a80a067a794eb13e0a904cd (diff) | |
download | chromium_src-8f1f23544925516776eef5b6346107e08ef807e8.zip chromium_src-8f1f23544925516776eef5b6346107e08ef807e8.tar.gz chromium_src-8f1f23544925516776eef5b6346107e08ef807e8.tar.bz2 |
Implement SignalingConnector that reconnects XMPP when necessary.
BUG=107276
TEST=Me2me host is reconnects XMPP after host network connection is reset.
Review URL: http://codereview.chromium.org/9053001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r-- | remoting/jingle_glue/xmpp_signal_strategy.cc | 32 | ||||
-rw-r--r-- | remoting/jingle_glue/xmpp_signal_strategy.h | 4 |
2 files changed, 14 insertions, 22 deletions
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc index 1e780e0..81a4683 100644 --- a/remoting/jingle_glue/xmpp_signal_strategy.cc +++ b/remoting/jingle_glue/xmpp_signal_strategy.cc @@ -55,6 +55,8 @@ void XmppSignalStrategy::Connect() { this, &XmppSignalStrategy::OnConnectionStateChanged); xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); xmpp_client_->Start(); + + SetState(CONNECTING); } void XmppSignalStrategy::Disconnect() { @@ -128,29 +130,17 @@ bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) { void XmppSignalStrategy::OnConnectionStateChanged( buzz::XmppEngine::State state) { DCHECK(CalledOnValidThread()); - State new_state; - - switch (state) { - case buzz::XmppEngine::STATE_START: - return; - - case buzz::XmppEngine::STATE_OPENING: - new_state = CONNECTING; - break; - case buzz::XmppEngine::STATE_OPEN: - new_state = CONNECTED; - break; - case buzz::XmppEngine::STATE_CLOSED: - // Client is destroyed by the TaskRunner after the client is - // closed. Reset the pointer so we don't try to use it later. - xmpp_client_ = NULL; - new_state = DISCONNECTED; - break; - default: - NOTREACHED(); - return; + if (state == buzz::XmppEngine::STATE_OPEN) { + SetState(CONNECTED); + } else if (state == buzz::XmppEngine::STATE_CLOSED) { + // Client is destroyed by the TaskRunner after the client is + // closed. Reset the pointer so we don't try to use it later. + xmpp_client_ = NULL; + SetState(DISCONNECTED); } +} +void XmppSignalStrategy::SetState(State new_state) { if (state_ != new_state) { state_ = new_state; FOR_EACH_OBSERVER(Listener, listeners_, diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h index 37d38bd..056c900 100644 --- a/remoting/jingle_glue/xmpp_signal_strategy.h +++ b/remoting/jingle_glue/xmpp_signal_strategy.h @@ -49,10 +49,12 @@ class XmppSignalStrategy : public base::NonThreadSafe, virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE; private: - void OnConnectionStateChanged(buzz::XmppEngine::State state); static buzz::PreXmppAuth* CreatePreXmppAuth( const buzz::XmppClientSettings& settings); + void OnConnectionStateChanged(buzz::XmppEngine::State state); + void SetState(State new_state); + JingleThread* thread_; std::string username_; |