diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:23:24 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:23:24 +0000 |
commit | c351e829e6f49069abf0f50adde2aa657807a812 (patch) | |
tree | 7d6a59ed100b5b43561fe91cce6c5a4bd667ce01 /remoting | |
parent | 7d4371feab049f5cd443f49e819b3e4f9b98b667 (diff) | |
download | chromium_src-c351e829e6f49069abf0f50adde2aa657807a812.zip chromium_src-c351e829e6f49069abf0f50adde2aa657807a812.tar.gz chromium_src-c351e829e6f49069abf0f50adde2aa657807a812.tar.bz2 |
Provided a way to update auth info for XmppSignalStrategy.
Also provided a way to override the default resource name.
BUG=None
TEST=Manual
Review URL: http://codereview.chromium.org/9159022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/jingle_glue/xmpp_signal_strategy.cc | 21 | ||||
-rw-r--r-- | remoting/jingle_glue/xmpp_signal_strategy.h | 12 |
2 files changed, 32 insertions, 1 deletions
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc index fe7e2fe..2df898e 100644 --- a/remoting/jingle_glue/xmpp_signal_strategy.cc +++ b/remoting/jingle_glue/xmpp_signal_strategy.cc @@ -12,6 +12,10 @@ #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" +namespace { +const char kDefaultResourceName[] = "chromoting"; +} // namespace + namespace remoting { XmppSignalStrategy::XmppSignalStrategy(JingleThread* jingle_thread, @@ -22,6 +26,7 @@ XmppSignalStrategy::XmppSignalStrategy(JingleThread* jingle_thread, username_(username), auth_token_(auth_token), auth_token_service_(auth_token_service), + resource_name_(kDefaultResourceName), xmpp_client_(NULL), state_(DISCONNECTED) { } @@ -41,7 +46,7 @@ void XmppSignalStrategy::Connect() { buzz::Jid login_jid(username_); settings.set_user(login_jid.node()); settings.set_host(login_jid.domain()); - settings.set_resource("chromoting"); + settings.set_resource(resource_name_); settings.set_use_tls(buzz::TLS_ENABLED); settings.set_token_service(auth_token_service_); settings.set_auth_cookie(auth_token_); @@ -127,6 +132,20 @@ bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) { return false; } +void XmppSignalStrategy::SetAuthInfo(const std::string& username, + const std::string& auth_token, + const std::string& auth_token_service) { + DCHECK(CalledOnValidThread()); + username_ = username; + auth_token_ = auth_token; + auth_token_service_ = auth_token_service; +} + +void XmppSignalStrategy::SetResourceName(const std::string &resource_name) { + DCHECK(CalledOnValidThread()); + resource_name_ = resource_name; +} + void XmppSignalStrategy::OnConnectionStateChanged( buzz::XmppEngine::State state) { DCHECK(CalledOnValidThread()); diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h index 056c900..641d93d 100644 --- a/remoting/jingle_glue/xmpp_signal_strategy.h +++ b/remoting/jingle_glue/xmpp_signal_strategy.h @@ -48,6 +48,17 @@ class XmppSignalStrategy : public base::NonThreadSafe, // buzz::XmppStanzaHandler interface. virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE; + // This method is used to update the auth info (for example when the OAuth + // access token is renewed). It is OK to call this even when we are in the + // CONNECTED state. It will be used on the next Connect() call. + void SetAuthInfo(const std::string& username, + const std::string& auth_token, + const std::string& auth_token_service); + + // Use this method to override the default resource name used (optional). + // This will be used on the next Connect() call. + void SetResourceName(const std::string& resource_name); + private: static buzz::PreXmppAuth* CreatePreXmppAuth( const buzz::XmppClientSettings& settings); @@ -60,6 +71,7 @@ class XmppSignalStrategy : public base::NonThreadSafe, std::string username_; std::string auth_token_; std::string auth_token_service_; + std::string resource_name_; buzz::XmppClient* xmpp_client_; State state_; |