Chromium Code Reviews| 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/connection_to_host.h" | 5 #include "remoting/protocol/connection_to_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "remoting/base/constants.h" | 11 #include "remoting/base/constants.h" |
| 12 #include "remoting/jingle_glue/javascript_signal_strategy.h" | 12 #include "remoting/jingle_glue/javascript_signal_strategy.h" |
| 13 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 13 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 14 #include "remoting/protocol/auth_util.h" | 14 #include "remoting/protocol/auth_util.h" |
| 15 #include "remoting/protocol/authenticator.h" | 15 #include "remoting/protocol/authenticator.h" |
| 16 #include "remoting/protocol/client_control_dispatcher.h" | 16 #include "remoting/protocol/client_control_dispatcher.h" |
| 17 #include "remoting/protocol/client_event_dispatcher.h" | 17 #include "remoting/protocol/client_event_dispatcher.h" |
| 18 #include "remoting/protocol/client_stub.h" | 18 #include "remoting/protocol/client_stub.h" |
| 19 #include "remoting/protocol/errors.h" | |
| 19 #include "remoting/protocol/jingle_session_manager.h" | 20 #include "remoting/protocol/jingle_session_manager.h" |
| 20 #include "remoting/protocol/pepper_transport_factory.h" | 21 #include "remoting/protocol/pepper_transport_factory.h" |
| 21 #include "remoting/protocol/video_reader.h" | 22 #include "remoting/protocol/video_reader.h" |
| 22 #include "remoting/protocol/video_stub.h" | 23 #include "remoting/protocol/video_stub.h" |
| 23 #include "remoting/protocol/util.h" | 24 #include "remoting/protocol/util.h" |
| 24 | 25 |
| 25 namespace remoting { | 26 namespace remoting { |
| 26 namespace protocol { | 27 namespace protocol { |
| 27 | 28 |
| 28 ConnectionToHost::ConnectionToHost( | 29 ConnectionToHost::ConnectionToHost( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 event_dispatcher_->Init(session_.get(), base::Bind( | 170 event_dispatcher_->Init(session_.get(), base::Bind( |
| 170 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 171 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 171 break; | 172 break; |
| 172 | 173 |
| 173 case Session::CLOSED: | 174 case Session::CLOSED: |
| 174 CloseChannels(); | 175 CloseChannels(); |
| 175 SetState(CLOSED, OK); | 176 SetState(CLOSED, OK); |
| 176 break; | 177 break; |
| 177 | 178 |
| 178 case Session::FAILED: | 179 case Session::FAILED: |
| 179 switch (session_->error()) { | 180 // If we were connected then treat this error as if the |
| 180 case Session::PEER_IS_OFFLINE: | 181 // connection was closed by the peer. |
| 181 CloseOnError(HOST_IS_OFFLINE); | 182 // |
| 182 break; | 183 // TODO(sergeyu): This logic belongs to the webapp, but we |
| 183 case Session::SESSION_REJECTED: | 184 // currently don't expose this error code to the webapp, and it |
| 184 case Session::AUTHENTICATION_FAILED: | 185 // would hard to add it because client plugin and webapp |
| 185 CloseOnError(SESSION_REJECTED); | 186 // versions may not be in sync. It should be easy to do after we |
| 186 break; | 187 // are finished moving the client plugin to NaCl. |
|
Jamie
2012/03/02 00:48:12
Please add a similar comment to ConvertConnectErro
Sergey Ulanov
2012/03/02 01:04:54
Done.
| |
| 187 case Session::INCOMPATIBLE_PROTOCOL: | 188 if (state_ == CONNECTED || session_->error() == SIGNALING_TIMEOUT) { |
| 188 CloseOnError(INCOMPATIBLE_PROTOCOL); | 189 SetState(CLOSED, OK); |
| 189 break; | 190 } else { |
| 190 case Session::CHANNEL_CONNECTION_ERROR: | 191 CloseOnError(session_->error()); |
| 191 case Session::UNKNOWN_ERROR: | |
| 192 CloseOnError(NETWORK_FAILURE); | |
| 193 break; | |
| 194 case Session::OK: | |
| 195 DLOG(FATAL) << "Error code isn't set"; | |
| 196 CloseOnError(NETWORK_FAILURE); | |
| 197 } | 192 } |
| 198 break; | 193 break; |
| 199 } | 194 } |
| 200 } | 195 } |
| 201 | 196 |
| 202 void ConnectionToHost::OnChannelInitialized(bool successful) { | 197 void ConnectionToHost::OnChannelInitialized(bool successful) { |
| 203 if (!successful) { | 198 if (!successful) { |
| 204 LOG(ERROR) << "Failed to connect video channel"; | 199 LOG(ERROR) << "Failed to connect video channel"; |
| 205 CloseOnError(NETWORK_FAILURE); | 200 CloseOnError(NETWORK_FAILURE); |
| 206 return; | 201 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 | 234 |
| 240 if (state != state_) { | 235 if (state != state_) { |
| 241 state_ = state; | 236 state_ = state; |
| 242 error_ = error; | 237 error_ = error; |
| 243 event_callback_->OnConnectionState(state_, error_); | 238 event_callback_->OnConnectionState(state_, error_); |
| 244 } | 239 } |
| 245 } | 240 } |
| 246 | 241 |
| 247 } // namespace protocol | 242 } // namespace protocol |
| 248 } // namespace remoting | 243 } // namespace remoting |
| OLD | NEW |