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

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: 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 LOG(ERROR) << "Failed to send a transport-info message"; 233 LOG(ERROR) << "Failed to send a transport-info message";
234 } 234 }
235 } 235 }
236 236
237 void JingleSession::Close(protocol::ErrorCode error) { 237 void JingleSession::Close(protocol::ErrorCode error) {
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 JingleMessage::ErrorCode error_code = JingleMessage::ErrorCode::UNKNOWN;
243 switch (error) { 244 switch (error) {
244 case OK: 245 case OK:
245 reason = JingleMessage::SUCCESS; 246 reason = JingleMessage::SUCCESS;
246 break; 247 break;
247 case SESSION_REJECTED: 248 case SESSION_REJECTED:
249 reason = JingleMessage::DECLINE;
250 error_code = JingleMessage::ErrorCode::SESSION_REJECTED;
248 case AUTHENTICATION_FAILED: 251 case AUTHENTICATION_FAILED:
249 reason = JingleMessage::DECLINE; 252 reason = JingleMessage::DECLINE;
253 error_code = JingleMessage::ErrorCode::AUTHENTICATION_FAILED;
250 break; 254 break;
251 case INVALID_ACCOUNT: 255 case INVALID_ACCOUNT:
252 // TODO(zijiehe): Instead of using SECURITY_ERROR Jingle reason, add a 256 reason = JingleMessage::DECLINE;
253 // new tag under crd namespace to export detail error reason to client. 257 error_code = JingleMessage::ErrorCode::INVALID_ACCOUNT;
254 reason = JingleMessage::SECURITY_ERROR;
255 break; 258 break;
256 case INCOMPATIBLE_PROTOCOL: 259 case INCOMPATIBLE_PROTOCOL:
257 reason = JingleMessage::INCOMPATIBLE_PARAMETERS; 260 reason = JingleMessage::INCOMPATIBLE_PARAMETERS;
258 break; 261 break;
259 case HOST_OVERLOAD: 262 case HOST_OVERLOAD:
260 reason = JingleMessage::CANCEL; 263 reason = JingleMessage::CANCEL;
261 break; 264 break;
262 case MAX_SESSION_LENGTH: 265 case MAX_SESSION_LENGTH:
263 reason = JingleMessage::EXPIRED; 266 reason = JingleMessage::EXPIRED;
264 break; 267 break;
265 case HOST_CONFIGURATION_ERROR: 268 case HOST_CONFIGURATION_ERROR:
266 reason = JingleMessage::FAILED_APPLICATION; 269 reason = JingleMessage::FAILED_APPLICATION;
267 break; 270 break;
268 default: 271 default:
269 reason = JingleMessage::GENERAL_ERROR; 272 reason = JingleMessage::GENERAL_ERROR;
270 } 273 }
271 274
272 JingleMessage message(peer_address_, JingleMessage::SESSION_TERMINATE, 275 JingleMessage message(peer_address_, JingleMessage::SESSION_TERMINATE,
273 session_id_); 276 session_id_);
274 message.reason = reason; 277 message.reason = reason;
278 message.error_code = error_code;
275 SendMessage(message); 279 SendMessage(message);
276 } 280 }
277 281
278 error_ = error; 282 error_ = error;
279 283
280 if (state_ != FAILED && state_ != CLOSED) { 284 if (state_ != FAILED && state_ != CLOSED) {
281 if (error != OK) { 285 if (error != OK) {
282 SetState(FAILED); 286 SetState(FAILED);
283 } else { 287 } else {
284 SetState(CLOSED); 288 SetState(CLOSED);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 487
484 switch (message.reason) { 488 switch (message.reason) {
485 case JingleMessage::SUCCESS: 489 case JingleMessage::SUCCESS:
486 if (state_ == CONNECTING) { 490 if (state_ == CONNECTING) {
487 error_ = SESSION_REJECTED; 491 error_ = SESSION_REJECTED;
488 } else { 492 } else {
489 error_ = OK; 493 error_ = OK;
490 } 494 }
491 break; 495 break;
492 case JingleMessage::DECLINE: 496 case JingleMessage::DECLINE:
493 error_ = AUTHENTICATION_FAILED; 497 switch (message.error_code) {
Sergey Ulanov 2016/06/01 08:52:47 I think we should use the <error-code> for any rea
Hzj_jie 2016/06/01 23:56:13 Done.
494 break; 498 case JingleMessage::ErrorCode::SESSION_REJECTED:
495 case JingleMessage::SECURITY_ERROR: 499 // For backward compatibility, we still use AUTHENTICATION_FAILED for
496 error_ = INVALID_ACCOUNT; 500 // SESSION_REJECTED error.
501 error_ = AUTHENTICATION_FAILED;
502 break;
503 case JingleMessage::ErrorCode::AUTHENTICATION_FAILED:
504 error_ = AUTHENTICATION_FAILED;
505 break;
506 case JingleMessage::ErrorCode::INVALID_ACCOUNT:
507 error_ = INVALID_ACCOUNT;
508 break;
509 default:
510 error_ = UNKNOWN_ERROR;
511 }
497 break; 512 break;
498 case JingleMessage::CANCEL: 513 case JingleMessage::CANCEL:
499 error_ = HOST_OVERLOAD; 514 error_ = HOST_OVERLOAD;
500 break; 515 break;
501 case JingleMessage::EXPIRED: 516 case JingleMessage::EXPIRED:
502 error_ = MAX_SESSION_LENGTH; 517 error_ = MAX_SESSION_LENGTH;
503 break; 518 break;
504 case JingleMessage::INCOMPATIBLE_PARAMETERS: 519 case JingleMessage::INCOMPATIBLE_PARAMETERS:
505 error_ = INCOMPATIBLE_PROTOCOL; 520 error_ = INCOMPATIBLE_PROTOCOL;
506 break; 521 break;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 616 }
602 } 617 }
603 618
604 bool JingleSession::is_session_active() { 619 bool JingleSession::is_session_active() {
605 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED || 620 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED ||
606 state_ == AUTHENTICATING || state_ == AUTHENTICATED; 621 state_ == AUTHENTICATING || state_ == AUTHENTICATED;
607 } 622 }
608 623
609 } // namespace protocol 624 } // namespace protocol
610 } // namespace remoting 625 } // namespace remoting
OLDNEW
« remoting/protocol/jingle_messages.cc ('K') | « remoting/protocol/jingle_messages_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698