OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signaling/xmpp_signal_strategy.h" | 5 #include "remoting/signaling/xmpp_signal_strategy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 void XmppSignalStrategy::Core::Disconnect() { | 185 void XmppSignalStrategy::Core::Disconnect() { |
186 DCHECK(thread_checker_.CalledOnValidThread()); | 186 DCHECK(thread_checker_.CalledOnValidThread()); |
187 | 187 |
188 if (socket_) { | 188 if (socket_) { |
189 login_handler_.reset(); | 189 login_handler_.reset(); |
190 stream_parser_.reset(); | 190 stream_parser_.reset(); |
191 writer_.reset(); | 191 writer_.reset(); |
192 socket_.reset(); | 192 socket_.reset(); |
193 tls_state_ = TlsState::NOT_REQUESTED; | 193 tls_state_ = TlsState::NOT_REQUESTED; |
| 194 read_pending_ = false; |
194 | 195 |
195 FOR_EACH_OBSERVER(Listener, listeners_, | 196 FOR_EACH_OBSERVER(Listener, listeners_, |
196 OnSignalStrategyStateChange(DISCONNECTED)); | 197 OnSignalStrategyStateChange(DISCONNECTED)); |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 SignalStrategy::State XmppSignalStrategy::Core::GetState() const { | 201 SignalStrategy::State XmppSignalStrategy::Core::GetState() const { |
201 DCHECK(thread_checker_.CalledOnValidThread()); | 202 DCHECK(thread_checker_.CalledOnValidThread()); |
202 | 203 |
203 if (stream_parser_) { | 204 if (stream_parser_) { |
(...skipping 23 matching lines...) Expand all Loading... |
227 | 228 |
228 void XmppSignalStrategy::Core::RemoveListener(Listener* listener) { | 229 void XmppSignalStrategy::Core::RemoveListener(Listener* listener) { |
229 DCHECK(thread_checker_.CalledOnValidThread()); | 230 DCHECK(thread_checker_.CalledOnValidThread()); |
230 listeners_.RemoveObserver(listener); | 231 listeners_.RemoveObserver(listener); |
231 } | 232 } |
232 | 233 |
233 bool XmppSignalStrategy::Core::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { | 234 bool XmppSignalStrategy::Core::SendStanza(scoped_ptr<buzz::XmlElement> stanza) { |
234 DCHECK(thread_checker_.CalledOnValidThread()); | 235 DCHECK(thread_checker_.CalledOnValidThread()); |
235 | 236 |
236 if (!stream_parser_) { | 237 if (!stream_parser_) { |
237 VLOG(0) << "Dropping signalling message because XMPP " | 238 VLOG(0) << "Dropping signalling message because XMPP is not connected."; |
238 "connection has been terminated."; | |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 SendMessage(stanza->Str()); | 242 SendMessage(stanza->Str()); |
243 return true; | 243 |
| 244 // Return false if the SendMessage() call above resulted in the SignalStrategy |
| 245 // being disconnected. |
| 246 return stream_parser_ != nullptr; |
244 } | 247 } |
245 | 248 |
246 void XmppSignalStrategy::Core::SetAuthInfo(const std::string& username, | 249 void XmppSignalStrategy::Core::SetAuthInfo(const std::string& username, |
247 const std::string& auth_token) { | 250 const std::string& auth_token) { |
248 DCHECK(thread_checker_.CalledOnValidThread()); | 251 DCHECK(thread_checker_.CalledOnValidThread()); |
249 xmpp_server_config_.username = username; | 252 xmpp_server_config_.username = username; |
250 xmpp_server_config_.auth_token = auth_token; | 253 xmpp_server_config_.auth_token = auth_token; |
251 } | 254 } |
252 | 255 |
253 void XmppSignalStrategy::Core::SendMessage(const std::string& message) { | 256 void XmppSignalStrategy::Core::SendMessage(const std::string& message) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 std::string XmppSignalStrategy::GetNextId() { | 528 std::string XmppSignalStrategy::GetNextId() { |
526 return base::Uint64ToString(base::RandUint64()); | 529 return base::Uint64ToString(base::RandUint64()); |
527 } | 530 } |
528 | 531 |
529 void XmppSignalStrategy::SetAuthInfo(const std::string& username, | 532 void XmppSignalStrategy::SetAuthInfo(const std::string& username, |
530 const std::string& auth_token) { | 533 const std::string& auth_token) { |
531 core_->SetAuthInfo(username, auth_token); | 534 core_->SetAuthInfo(username, auth_token); |
532 } | 535 } |
533 | 536 |
534 } // namespace remoting | 537 } // namespace remoting |
OLD | NEW |