| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/client/chromoting_client.h" | 5 #include "remoting/client/chromoting_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "remoting/base/logger.h" | |
| 10 #include "remoting/base/tracer.h" | 9 #include "remoting/base/tracer.h" |
| 11 #include "remoting/client/chromoting_view.h" | 10 #include "remoting/client/chromoting_view.h" |
| 12 #include "remoting/client/client_context.h" | 11 #include "remoting/client/client_context.h" |
| 13 #include "remoting/client/input_handler.h" | 12 #include "remoting/client/input_handler.h" |
| 14 #include "remoting/client/rectangle_update_decoder.h" | 13 #include "remoting/client/rectangle_update_decoder.h" |
| 15 #include "remoting/protocol/connection_to_host.h" | 14 #include "remoting/protocol/connection_to_host.h" |
| 16 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
| 17 | 16 |
| 18 namespace remoting { | 17 namespace remoting { |
| 19 | 18 |
| 20 ChromotingClient::ChromotingClient(const ClientConfig& config, | 19 ChromotingClient::ChromotingClient(const ClientConfig& config, |
| 21 ClientContext* context, | 20 ClientContext* context, |
| 22 protocol::ConnectionToHost* connection, | 21 protocol::ConnectionToHost* connection, |
| 23 ChromotingView* view, | 22 ChromotingView* view, |
| 24 RectangleUpdateDecoder* rectangle_decoder, | 23 RectangleUpdateDecoder* rectangle_decoder, |
| 25 InputHandler* input_handler, | 24 InputHandler* input_handler, |
| 26 Logger* logger, | |
| 27 Task* client_done) | 25 Task* client_done) |
| 28 : config_(config), | 26 : config_(config), |
| 29 context_(context), | 27 context_(context), |
| 30 connection_(connection), | 28 connection_(connection), |
| 31 view_(view), | 29 view_(view), |
| 32 rectangle_decoder_(rectangle_decoder), | 30 rectangle_decoder_(rectangle_decoder), |
| 33 input_handler_(input_handler), | 31 input_handler_(input_handler), |
| 34 logger_(logger), | |
| 35 client_done_(client_done), | 32 client_done_(client_done), |
| 36 state_(CREATED), | 33 state_(CREATED), |
| 37 packet_being_processed_(false), | 34 packet_being_processed_(false), |
| 38 last_sequence_number_(0) { | 35 last_sequence_number_(0) { |
| 39 } | 36 } |
| 40 | 37 |
| 41 ChromotingClient::~ChromotingClient() { | 38 ChromotingClient::~ChromotingClient() { |
| 42 } | 39 } |
| 43 | 40 |
| 44 void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { | 41 void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 base::Time decode_start; | 149 base::Time decode_start; |
| 153 if (last_packet) | 150 if (last_packet) |
| 154 decode_start = base::Time::Now(); | 151 decode_start = base::Time::Now(); |
| 155 | 152 |
| 156 rectangle_decoder_->DecodePacket( | 153 rectangle_decoder_->DecodePacket( |
| 157 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, | 154 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, |
| 158 last_packet, decode_start)); | 155 last_packet, decode_start)); |
| 159 } | 156 } |
| 160 | 157 |
| 161 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { | 158 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { |
| 162 logger_->VLog(1, "ChromotingClient::OnConnectionOpened"); | 159 VLOG(1) << "ChromotingClient::OnConnectionOpened"; |
| 163 Initialize(); | 160 Initialize(); |
| 164 SetConnectionState(CONNECTED); | 161 SetConnectionState(CONNECTED); |
| 165 } | 162 } |
| 166 | 163 |
| 167 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { | 164 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { |
| 168 logger_->VLog(1, "ChromotingClient::OnConnectionClosed"); | 165 VLOG(1) << "ChromotingClient::OnConnectionClosed"; |
| 169 SetConnectionState(DISCONNECTED); | 166 SetConnectionState(DISCONNECTED); |
| 170 } | 167 } |
| 171 | 168 |
| 172 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { | 169 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { |
| 173 logger_->VLog(1, "ChromotingClient::OnConnectionFailed"); | 170 VLOG(1) << "ChromotingClient::OnConnectionFailed"; |
| 174 SetConnectionState(FAILED); | 171 SetConnectionState(FAILED); |
| 175 } | 172 } |
| 176 | 173 |
| 177 MessageLoop* ChromotingClient::message_loop() { | 174 MessageLoop* ChromotingClient::message_loop() { |
| 178 return context_->jingle_thread()->message_loop(); | 175 return context_->jingle_thread()->message_loop(); |
| 179 } | 176 } |
| 180 | 177 |
| 181 void ChromotingClient::SetConnectionState(ConnectionState s) { | 178 void ChromotingClient::SetConnectionState(ConnectionState s) { |
| 182 // TODO(ajwong): We actually may want state to be a shared variable. Think | 179 // TODO(ajwong): We actually may want state to be a shared variable. Think |
| 183 // through later. | 180 // through later. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 void ChromotingClient::BeginSessionResponse( | 244 void ChromotingClient::BeginSessionResponse( |
| 248 const protocol::LocalLoginStatus* msg, Task* done) { | 245 const protocol::LocalLoginStatus* msg, Task* done) { |
| 249 if (message_loop() != MessageLoop::current()) { | 246 if (message_loop() != MessageLoop::current()) { |
| 250 message_loop()->PostTask( | 247 message_loop()->PostTask( |
| 251 FROM_HERE, | 248 FROM_HERE, |
| 252 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, | 249 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, |
| 253 msg, done)); | 250 msg, done)); |
| 254 return; | 251 return; |
| 255 } | 252 } |
| 256 | 253 |
| 257 logger_->Log(logging::LOG_INFO, "BeginSessionResponse received"); | 254 LOG(INFO) << "BeginSessionResponse received"; |
| 258 | 255 |
| 259 // Inform the connection that the client has been authenticated. This will | 256 // Inform the connection that the client has been authenticated. This will |
| 260 // enable the communication channels. | 257 // enable the communication channels. |
| 261 if (msg->success()) { | 258 if (msg->success()) { |
| 262 connection_->OnClientAuthenticated(); | 259 connection_->OnClientAuthenticated(); |
| 263 } | 260 } |
| 264 | 261 |
| 265 view_->UpdateLoginStatus(msg->success(), msg->error_info()); | 262 view_->UpdateLoginStatus(msg->success(), msg->error_info()); |
| 266 done->Run(); | 263 done->Run(); |
| 267 delete done; | 264 delete done; |
| 268 } | 265 } |
| 269 | 266 |
| 270 } // namespace remoting | 267 } // namespace remoting |
| OLD | NEW |