| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Timeout for the transport-info messages. | 47 // Timeout for the transport-info messages. |
| 48 const int kTransportInfoTimeout = 10 * 60; | 48 const int kTransportInfoTimeout = 10 * 60; |
| 49 | 49 |
| 50 ErrorCode AuthRejectionReasonToErrorCode( | 50 ErrorCode AuthRejectionReasonToErrorCode( |
| 51 Authenticator::RejectionReason reason) { | 51 Authenticator::RejectionReason reason) { |
| 52 switch (reason) { | 52 switch (reason) { |
| 53 case Authenticator::INVALID_CREDENTIALS: | 53 case Authenticator::INVALID_CREDENTIALS: |
| 54 return AUTHENTICATION_FAILED; | 54 return AUTHENTICATION_FAILED; |
| 55 case Authenticator::PROTOCOL_ERROR: | 55 case Authenticator::PROTOCOL_ERROR: |
| 56 return INCOMPATIBLE_PROTOCOL; | 56 return INCOMPATIBLE_PROTOCOL; |
| 57 case Authenticator::INVALID_ACCOUNT: |
| 58 return INVALID_ACCOUNT; |
| 57 } | 59 } |
| 58 NOTREACHED(); | 60 NOTREACHED(); |
| 59 return UNKNOWN_ERROR; | 61 return UNKNOWN_ERROR; |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace | 64 } // namespace |
| 63 | 65 |
| 64 JingleSession::JingleSession(JingleSessionManager* session_manager) | 66 JingleSession::JingleSession(JingleSessionManager* session_manager) |
| 65 : session_manager_(session_manager), | 67 : session_manager_(session_manager), |
| 66 event_handler_(nullptr), | 68 event_handler_(nullptr), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // Send session-terminate message with the appropriate error code. | 240 // Send session-terminate message with the appropriate error code. |
| 239 JingleMessage::Reason reason; | 241 JingleMessage::Reason reason; |
| 240 switch (error) { | 242 switch (error) { |
| 241 case OK: | 243 case OK: |
| 242 reason = JingleMessage::SUCCESS; | 244 reason = JingleMessage::SUCCESS; |
| 243 break; | 245 break; |
| 244 case SESSION_REJECTED: | 246 case SESSION_REJECTED: |
| 245 case AUTHENTICATION_FAILED: | 247 case AUTHENTICATION_FAILED: |
| 246 reason = JingleMessage::DECLINE; | 248 reason = JingleMessage::DECLINE; |
| 247 break; | 249 break; |
| 250 case INVALID_ACCOUNT: |
| 251 // TODO(zijiehe): Instead of using SECURITY_ERROR Jingle reason, add a |
| 252 // new tag under crd namespace to export detail error reason to client. |
| 253 reason = JingleMessage::SECURITY_ERROR; |
| 254 break; |
| 248 case INCOMPATIBLE_PROTOCOL: | 255 case INCOMPATIBLE_PROTOCOL: |
| 249 reason = JingleMessage::INCOMPATIBLE_PARAMETERS; | 256 reason = JingleMessage::INCOMPATIBLE_PARAMETERS; |
| 250 break; | 257 break; |
| 251 case HOST_OVERLOAD: | 258 case HOST_OVERLOAD: |
| 252 reason = JingleMessage::CANCEL; | 259 reason = JingleMessage::CANCEL; |
| 253 break; | 260 break; |
| 254 case MAX_SESSION_LENGTH: | 261 case MAX_SESSION_LENGTH: |
| 255 reason = JingleMessage::EXPIRED; | 262 reason = JingleMessage::EXPIRED; |
| 256 break; | 263 break; |
| 257 case HOST_CONFIGURATION_ERROR: | 264 case HOST_CONFIGURATION_ERROR: |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 case JingleMessage::SUCCESS: | 484 case JingleMessage::SUCCESS: |
| 478 if (state_ == CONNECTING) { | 485 if (state_ == CONNECTING) { |
| 479 error_ = SESSION_REJECTED; | 486 error_ = SESSION_REJECTED; |
| 480 } else { | 487 } else { |
| 481 error_ = OK; | 488 error_ = OK; |
| 482 } | 489 } |
| 483 break; | 490 break; |
| 484 case JingleMessage::DECLINE: | 491 case JingleMessage::DECLINE: |
| 485 error_ = AUTHENTICATION_FAILED; | 492 error_ = AUTHENTICATION_FAILED; |
| 486 break; | 493 break; |
| 494 case JingleMessage::SECURITY_ERROR: |
| 495 error_ = INVALID_ACCOUNT; |
| 496 break; |
| 487 case JingleMessage::CANCEL: | 497 case JingleMessage::CANCEL: |
| 488 error_ = HOST_OVERLOAD; | 498 error_ = HOST_OVERLOAD; |
| 489 break; | 499 break; |
| 490 case JingleMessage::EXPIRED: | 500 case JingleMessage::EXPIRED: |
| 491 error_ = MAX_SESSION_LENGTH; | 501 error_ = MAX_SESSION_LENGTH; |
| 492 break; | 502 break; |
| 493 case JingleMessage::INCOMPATIBLE_PARAMETERS: | 503 case JingleMessage::INCOMPATIBLE_PARAMETERS: |
| 494 error_ = INCOMPATIBLE_PROTOCOL; | 504 error_ = INCOMPATIBLE_PROTOCOL; |
| 495 break; | 505 break; |
| 496 case JingleMessage::FAILED_APPLICATION: | 506 case JingleMessage::FAILED_APPLICATION: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 } | 599 } |
| 590 } | 600 } |
| 591 | 601 |
| 592 bool JingleSession::is_session_active() { | 602 bool JingleSession::is_session_active() { |
| 593 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED || | 603 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED || |
| 594 state_ == AUTHENTICATING || state_ == AUTHENTICATED; | 604 state_ == AUTHENTICATING || state_ == AUTHENTICATED; |
| 595 } | 605 } |
| 596 | 606 |
| 597 } // namespace protocol | 607 } // namespace protocol |
| 598 } // namespace remoting | 608 } // namespace remoting |
| OLD | NEW |