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

Side by Side Diff: remoting/protocol/jingle_session.cc

Issue 493573002: Fix JingleSession class to avoid bogus incompatible protocol error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/protocol/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } else { 336 } else {
337 LOG(ERROR) << "Failed to send a " 337 LOG(ERROR) << "Failed to send a "
338 << JingleMessage::GetActionName(message.action) << " message"; 338 << JingleMessage::GetActionName(message.action) << " message";
339 } 339 }
340 } 340 }
341 341
342 void JingleSession::OnMessageResponse( 342 void JingleSession::OnMessageResponse(
343 JingleMessage::ActionType request_type, 343 JingleMessage::ActionType request_type,
344 IqRequest* request, 344 IqRequest* request,
345 const buzz::XmlElement* response) { 345 const buzz::XmlElement* response) {
346 std::string type_str = JingleMessage::GetActionName(request_type);
347
348 // Delete the request from the list of pending requests. 346 // Delete the request from the list of pending requests.
349 pending_requests_.erase(request); 347 pending_requests_.erase(request);
350 delete request; 348 delete request;
351 349
350 if (state_ == CLOSED || state_ == FAILED) {
351 // Ignore all responses after session was closed.
Wez 2014/08/20 01:45:23 nit: Suggest moving this comment outside the if()
Sergey Ulanov 2014/08/25 17:28:08 Done.
352 return;
353 }
354
355 std::string type_str = JingleMessage::GetActionName(request_type);
356
352 // |response| will be NULL if the request timed out. 357 // |response| will be NULL if the request timed out.
353 if (!response) { 358 if (!response) {
354 LOG(ERROR) << type_str << " request timed out."; 359 LOG(ERROR) << type_str << " request timed out.";
355 CloseInternal(SIGNALING_TIMEOUT); 360 CloseInternal(SIGNALING_TIMEOUT);
356 return; 361 return;
357 } else { 362 } else {
358 const std::string& type = 363 const std::string& type =
359 response->Attr(buzz::QName(std::string(), "type")); 364 response->Attr(buzz::QName(std::string(), "type"));
360 if (type != "result") { 365 if (type != "result") {
361 LOG(ERROR) << "Received error in response to " << type_str 366 LOG(ERROR) << "Received error in response to " << type_str
362 << " message: \"" << response->Str() 367 << " message: \"" << response->Str()
363 << "\". Terminating the session."; 368 << "\". Terminating the session.";
364 369
365 switch (request_type) { 370 // TODO(sergeyu): There may be different reasons for error
366 case JingleMessage::SESSION_INFO: 371 // here. Parse the response stanza to find failure reason.
Wez 2014/08/20 01:45:23 nit: Please file a bug for that work and add a lin
Sergey Ulanov 2014/08/25 17:28:08 This is not a new TODO. I don't think we need a bu
367 // session-info is used for the new authentication protocol, 372 CloseInternal(PEER_IS_OFFLINE);
368 // and wasn't previously supported.
369 CloseInternal(INCOMPATIBLE_PROTOCOL);
Wez 2014/08/20 01:45:23 Does this mean we can't ever return INCOMPATIBLE_P
Sergey Ulanov 2014/08/25 17:28:07 No, there are some placed where INCOMPATIBLE_PROTO
370 break;
371
372 default:
373 // TODO(sergeyu): There may be different reasons for error
374 // here. Parse the response stanza to find failure reason.
375 CloseInternal(PEER_IS_OFFLINE);
376 }
377 } 373 }
378 } 374 }
379 } 375 }
380 376
381 void JingleSession::SendTransportInfo() { 377 void JingleSession::SendTransportInfo() {
382 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_); 378 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_);
383 message.candidates.swap(pending_candidates_); 379 message.candidates.swap(pending_candidates_);
384 380
385 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq( 381 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq(
386 message.ToXml(), 382 message.ToXml(),
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 676 }
681 } 677 }
682 678
683 bool JingleSession::is_session_active() { 679 bool JingleSession::is_session_active() {
684 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED || 680 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED ||
685 state_ == AUTHENTICATING || state_ == AUTHENTICATED; 681 state_ == AUTHENTICATING || state_ == AUTHENTICATED;
686 } 682 }
687 683
688 } // namespace protocol 684 } // namespace protocol
689 } // namespace remoting 685 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698