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

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

Issue 2026123002: [Chromoting] Use google:remoting namespace to export remoting specific error codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 6 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 (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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 DCHECK(thread_checker_.CalledOnValidThread()); 238 DCHECK(thread_checker_.CalledOnValidThread());
239 239
240 if (is_session_active()) { 240 if (is_session_active()) {
241 // Send session-terminate message with the appropriate error code. 241 // Send session-terminate message with the appropriate error code.
242 JingleMessage::Reason reason; 242 JingleMessage::Reason reason;
243 switch (error) { 243 switch (error) {
244 case OK: 244 case OK:
245 reason = JingleMessage::SUCCESS; 245 reason = JingleMessage::SUCCESS;
246 break; 246 break;
247 case SESSION_REJECTED: 247 case SESSION_REJECTED:
248 reason = JingleMessage::DECLINE;
248 case AUTHENTICATION_FAILED: 249 case AUTHENTICATION_FAILED:
249 reason = JingleMessage::DECLINE; 250 reason = JingleMessage::DECLINE;
250 break; 251 break;
251 case INVALID_ACCOUNT: 252 case INVALID_ACCOUNT:
252 // TODO(zijiehe): Instead of using SECURITY_ERROR Jingle reason, add a 253 reason = JingleMessage::DECLINE;
Sergey Ulanov 2016/06/07 16:22:23 This is the same as the case above, so you can jus
Hzj_jie 2016/06/07 19:29:57 Done.
253 // new tag under crd namespace to export detail error reason to client.
254 reason = JingleMessage::SECURITY_ERROR;
255 break; 254 break;
256 case INCOMPATIBLE_PROTOCOL: 255 case INCOMPATIBLE_PROTOCOL:
257 reason = JingleMessage::INCOMPATIBLE_PARAMETERS; 256 reason = JingleMessage::INCOMPATIBLE_PARAMETERS;
258 break; 257 break;
259 case HOST_OVERLOAD: 258 case HOST_OVERLOAD:
260 reason = JingleMessage::CANCEL; 259 reason = JingleMessage::CANCEL;
261 break; 260 break;
262 case MAX_SESSION_LENGTH: 261 case MAX_SESSION_LENGTH:
263 reason = JingleMessage::EXPIRED; 262 reason = JingleMessage::EXPIRED;
264 break; 263 break;
265 case HOST_CONFIGURATION_ERROR: 264 case HOST_CONFIGURATION_ERROR:
266 reason = JingleMessage::FAILED_APPLICATION; 265 reason = JingleMessage::FAILED_APPLICATION;
267 break; 266 break;
268 default: 267 default:
269 reason = JingleMessage::GENERAL_ERROR; 268 reason = JingleMessage::GENERAL_ERROR;
270 } 269 }
271 270
272 JingleMessage message(peer_address_, JingleMessage::SESSION_TERMINATE, 271 JingleMessage message(peer_address_, JingleMessage::SESSION_TERMINATE,
273 session_id_); 272 session_id_);
274 message.reason = reason; 273 message.reason = reason;
274 message.error_code = error;
275 SendMessage(message); 275 SendMessage(message);
276 } 276 }
277 277
278 error_ = error; 278 error_ = error;
279 279
280 if (state_ != FAILED && state_ != CLOSED) { 280 if (state_ != FAILED && state_ != CLOSED) {
281 if (error != OK) { 281 if (error != OK) {
282 SetState(FAILED); 282 SetState(FAILED);
283 } else { 283 } else {
284 SetState(CLOSED); 284 SetState(CLOSED);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 void JingleSession::OnTerminate(const JingleMessage& message, 474 void JingleSession::OnTerminate(const JingleMessage& message,
475 const ReplyCallback& reply_callback) { 475 const ReplyCallback& reply_callback) {
476 if (!is_session_active()) { 476 if (!is_session_active()) {
477 LOG(WARNING) << "Received unexpected session-terminate message."; 477 LOG(WARNING) << "Received unexpected session-terminate message.";
478 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); 478 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
479 return; 479 return;
480 } 480 }
481 481
482 reply_callback.Run(JingleMessageReply::NONE); 482 reply_callback.Run(JingleMessageReply::NONE);
483 483
484 switch (message.reason) { 484 error_ = message.error_code;
485 case JingleMessage::SUCCESS: 485 if (error_ == UNKNOWN_ERROR) {
486 if (state_ == CONNECTING) { 486 // For legacy hosts, which do not provide message.error_code.
Sergey Ulanov 2016/06/07 16:22:23 This code is not specific to client, so needs to b
Hzj_jie 2016/06/07 19:29:57 Done.
487 error_ = SESSION_REJECTED; 487 switch (message.reason) {
488 } else { 488 case JingleMessage::SUCCESS:
489 error_ = OK; 489 if (state_ == CONNECTING) {
490 } 490 error_ = SESSION_REJECTED;
491 break; 491 } else {
492 case JingleMessage::DECLINE: 492 error_ = OK;
493 error_ = AUTHENTICATION_FAILED; 493 }
494 break; 494 break;
495 case JingleMessage::SECURITY_ERROR: 495 case JingleMessage::DECLINE:
496 error_ = INVALID_ACCOUNT; 496 error_ = AUTHENTICATION_FAILED;
497 break; 497 break;
498 case JingleMessage::CANCEL: 498 case JingleMessage::CANCEL:
499 error_ = HOST_OVERLOAD; 499 error_ = HOST_OVERLOAD;
500 break; 500 break;
501 case JingleMessage::EXPIRED: 501 case JingleMessage::EXPIRED:
502 error_ = MAX_SESSION_LENGTH; 502 error_ = MAX_SESSION_LENGTH;
503 break; 503 break;
504 case JingleMessage::INCOMPATIBLE_PARAMETERS: 504 case JingleMessage::INCOMPATIBLE_PARAMETERS:
505 error_ = INCOMPATIBLE_PROTOCOL; 505 error_ = INCOMPATIBLE_PROTOCOL;
506 break; 506 break;
507 case JingleMessage::FAILED_APPLICATION: 507 case JingleMessage::FAILED_APPLICATION:
508 error_ = HOST_CONFIGURATION_ERROR; 508 error_ = HOST_CONFIGURATION_ERROR;
509 break; 509 break;
510 case JingleMessage::GENERAL_ERROR: 510 case JingleMessage::GENERAL_ERROR:
511 error_ = CHANNEL_CONNECTION_ERROR; 511 error_ = CHANNEL_CONNECTION_ERROR;
512 break; 512 break;
513 default: 513 default:
514 error_ = UNKNOWN_ERROR; 514 error_ = UNKNOWN_ERROR;
515 }
516 } else if (error_ == SESSION_REJECTED) {
517 // For backward compatibility, we still use AUTHENTICATION_FAILED for
518 // SESSION_REJECTED error.
519 // TODO(zijiehe): Handle SESSION_REJECTED error in WebApp.
Sergey Ulanov 2016/06/07 16:22:23 Please file a bug for this.
Hzj_jie 2016/06/07 19:29:57 Done.
520 error_ = AUTHENTICATION_FAILED;
515 } 521 }
516 522
517 if (error_ != OK) { 523 if (error_ != OK) {
518 SetState(FAILED); 524 SetState(FAILED);
519 } else { 525 } else {
520 SetState(CLOSED); 526 SetState(CLOSED);
521 } 527 }
522 } 528 }
523 529
524 bool JingleSession::InitializeConfigFromDescription( 530 bool JingleSession::InitializeConfigFromDescription(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 607 }
602 } 608 }
603 609
604 bool JingleSession::is_session_active() { 610 bool JingleSession::is_session_active() {
605 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED || 611 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED ||
606 state_ == AUTHENTICATING || state_ == AUTHENTICATED; 612 state_ == AUTHENTICATING || state_ == AUTHENTICATED;
607 } 613 }
608 614
609 } // namespace protocol 615 } // namespace protocol
610 } // namespace remoting 616 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698