| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 scoped_ptr<jingle_glue::XmppClientSocketFactory> socket_factory( | 85 scoped_ptr<jingle_glue::XmppClientSocketFactory> socket_factory( |
| 86 new jingle_glue::XmppClientSocketFactory( | 86 new jingle_glue::XmppClientSocketFactory( |
| 87 net::ClientSocketFactory::GetDefaultFactory(), | 87 net::ClientSocketFactory::GetDefaultFactory(), |
| 88 net::SSLConfig(), request_context_getter_, false)); | 88 net::SSLConfig(), request_context_getter_, false)); |
| 89 buzz::AsyncSocket* socket = new jingle_glue::ChromeAsyncSocket( | 89 buzz::AsyncSocket* socket = new jingle_glue::ChromeAsyncSocket( |
| 90 socket_factory.release(), kReadBufferSize, kWriteBufferSize); | 90 socket_factory.release(), kReadBufferSize, kWriteBufferSize); |
| 91 | 91 |
| 92 task_runner_.reset(new jingle_glue::TaskPump()); | 92 task_runner_.reset(new jingle_glue::TaskPump()); |
| 93 xmpp_client_ = new buzz::XmppClient(task_runner_.get()); | 93 xmpp_client_ = new buzz::XmppClient(task_runner_.get()); |
| 94 xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); | 94 xmpp_client_->Connect( |
| 95 xmpp_client_->SignalStateChange.connect( | 95 settings, std::string(), socket, CreatePreXmppAuth(settings)); |
| 96 this, &XmppSignalStrategy::OnConnectionStateChanged); | 96 xmpp_client_->SignalStateChange |
| 97 .connect(this, &XmppSignalStrategy::OnConnectionStateChanged); |
| 97 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); | 98 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); |
| 98 xmpp_client_->Start(); | 99 xmpp_client_->Start(); |
| 99 | 100 |
| 100 SetState(CONNECTING); | 101 SetState(CONNECTING); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void XmppSignalStrategy::Disconnect() { | 104 void XmppSignalStrategy::Disconnect() { |
| 104 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
| 105 | 106 |
| 106 if (xmpp_client_) { | 107 if (xmpp_client_) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 150 |
| 150 buzz::XmppReturnStatus status = xmpp_client_->SendStanza(stanza.release()); | 151 buzz::XmppReturnStatus status = xmpp_client_->SendStanza(stanza.release()); |
| 151 return status == buzz::XMPP_RETURN_OK || status == buzz::XMPP_RETURN_PENDING; | 152 return status == buzz::XMPP_RETURN_OK || status == buzz::XMPP_RETURN_PENDING; |
| 152 } | 153 } |
| 153 | 154 |
| 154 std::string XmppSignalStrategy::GetNextId() { | 155 std::string XmppSignalStrategy::GetNextId() { |
| 155 DCHECK(CalledOnValidThread()); | 156 DCHECK(CalledOnValidThread()); |
| 156 if (!xmpp_client_) { | 157 if (!xmpp_client_) { |
| 157 // If the connection has been terminated then it doesn't matter | 158 // If the connection has been terminated then it doesn't matter |
| 158 // what Id we return. | 159 // what Id we return. |
| 159 return ""; | 160 return std::string(); |
| 160 } | 161 } |
| 161 return xmpp_client_->NextId(); | 162 return xmpp_client_->NextId(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) { | 165 bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) { |
| 165 DCHECK(CalledOnValidThread()); | 166 DCHECK(CalledOnValidThread()); |
| 166 ObserverListBase<Listener>::Iterator it(listeners_); | 167 ObserverListBase<Listener>::Iterator it(listeners_); |
| 167 Listener* listener; | 168 Listener* listener; |
| 168 while ((listener = it.GetNext()) != NULL) { | 169 while ((listener = it.GetNext()) != NULL) { |
| 169 if (listener->OnSignalStrategyIncomingStanza(stanza)) | 170 if (listener->OnSignalStrategyIncomingStanza(stanza)) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; | 243 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; |
| 243 if (settings.token_service() == "oauth2") { | 244 if (settings.token_service() == "oauth2") { |
| 244 mechanism = "X-OAUTH2"; | 245 mechanism = "X-OAUTH2"; |
| 245 } | 246 } |
| 246 | 247 |
| 247 return new notifier::GaiaTokenPreXmppAuth( | 248 return new notifier::GaiaTokenPreXmppAuth( |
| 248 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); | 249 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace remoting | 252 } // namespace remoting |
| OLD | NEW |