Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: remoting/signaling/xmpp_signal_strategy.cc

Issue 1258323003: Fix XmppSignalStrategy to return correct result from SendStanza(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_config
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « remoting/signaling/signal_strategy.h ('k') | remoting/signaling/xmpp_signal_strategy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698