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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "remoting/base/tracer.h" | 8 #include "remoting/base/tracer.h" |
9 #include "remoting/client/chromoting_view.h" | 9 #include "remoting/client/chromoting_view.h" |
10 #include "remoting/client/client_context.h" | 10 #include "remoting/client/client_context.h" |
| 11 #include "remoting/client/client_logger.h" |
11 #include "remoting/client/input_handler.h" | 12 #include "remoting/client/input_handler.h" |
12 #include "remoting/client/rectangle_update_decoder.h" | 13 #include "remoting/client/rectangle_update_decoder.h" |
13 #include "remoting/protocol/connection_to_host.h" | 14 #include "remoting/protocol/connection_to_host.h" |
14 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
15 | 16 |
16 namespace remoting { | 17 namespace remoting { |
17 | 18 |
18 ChromotingClient::ChromotingClient(const ClientConfig& config, | 19 ChromotingClient::ChromotingClient(const ClientConfig& config, |
19 ClientContext* context, | 20 ClientContext* context, |
20 protocol::ConnectionToHost* connection, | 21 protocol::ConnectionToHost* connection, |
21 ChromotingView* view, | 22 ChromotingView* view, |
22 RectangleUpdateDecoder* rectangle_decoder, | 23 RectangleUpdateDecoder* rectangle_decoder, |
23 InputHandler* input_handler, | 24 InputHandler* input_handler, |
| 25 ClientLogger* logger, |
24 Task* client_done) | 26 Task* client_done) |
25 : config_(config), | 27 : config_(config), |
26 context_(context), | 28 context_(context), |
27 connection_(connection), | 29 connection_(connection), |
28 view_(view), | 30 view_(view), |
29 rectangle_decoder_(rectangle_decoder), | 31 rectangle_decoder_(rectangle_decoder), |
30 input_handler_(input_handler), | 32 input_handler_(input_handler), |
| 33 logger_(logger), |
31 client_done_(client_done), | 34 client_done_(client_done), |
32 state_(CREATED), | 35 state_(CREATED), |
33 packet_being_processed_(false), | 36 packet_being_processed_(false), |
34 last_sequence_number_(0) { | 37 last_sequence_number_(0) { |
35 } | 38 } |
36 | 39 |
37 ChromotingClient::~ChromotingClient() { | 40 ChromotingClient::~ChromotingClient() { |
38 } | 41 } |
39 | 42 |
40 void ChromotingClient::Start() { | 43 void ChromotingClient::Start() { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 base::Time decode_start; | 178 base::Time decode_start; |
176 if (last_packet) | 179 if (last_packet) |
177 decode_start = base::Time::Now(); | 180 decode_start = base::Time::Now(); |
178 | 181 |
179 rectangle_decoder_->DecodePacket( | 182 rectangle_decoder_->DecodePacket( |
180 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, | 183 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, |
181 last_packet, decode_start)); | 184 last_packet, decode_start)); |
182 } | 185 } |
183 | 186 |
184 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { | 187 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { |
185 VLOG(1) << "ChromotingClient::OnConnectionOpened"; | 188 logger_->VLog(1, "ChromotingClient::OnConnectionOpened"); |
186 Initialize(); | 189 Initialize(); |
187 SetConnectionState(CONNECTED); | 190 SetConnectionState(CONNECTED); |
188 } | 191 } |
189 | 192 |
190 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { | 193 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { |
191 VLOG(1) << "ChromotingClient::OnConnectionClosed"; | 194 logger_->VLog(1, "ChromotingClient::OnConnectionClosed"); |
192 SetConnectionState(DISCONNECTED); | 195 SetConnectionState(DISCONNECTED); |
193 } | 196 } |
194 | 197 |
195 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { | 198 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { |
196 VLOG(1) << "ChromotingClient::OnConnectionFailed"; | 199 logger_->VLog(1, "ChromotingClient::OnConnectionFailed"); |
197 SetConnectionState(FAILED); | 200 SetConnectionState(FAILED); |
198 } | 201 } |
199 | 202 |
200 MessageLoop* ChromotingClient::message_loop() { | 203 MessageLoop* ChromotingClient::message_loop() { |
201 return context_->jingle_thread()->message_loop(); | 204 return context_->jingle_thread()->message_loop(); |
202 } | 205 } |
203 | 206 |
204 void ChromotingClient::SetConnectionState(ConnectionState s) { | 207 void ChromotingClient::SetConnectionState(ConnectionState s) { |
205 // TODO(ajwong): We actually may want state to be a shared variable. Think | 208 // TODO(ajwong): We actually may want state to be a shared variable. Think |
206 // through later. | 209 // through later. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return; | 257 return; |
255 } | 258 } |
256 | 259 |
257 TraceContext::tracer()->PrintString("Initializing client."); | 260 TraceContext::tracer()->PrintString("Initializing client."); |
258 | 261 |
259 const protocol::SessionConfig* config = connection_->config(); | 262 const protocol::SessionConfig* config = connection_->config(); |
260 | 263 |
261 // Resize the window. | 264 // Resize the window. |
262 int width = config->initial_resolution().width; | 265 int width = config->initial_resolution().width; |
263 int height = config->initial_resolution().height; | 266 int height = config->initial_resolution().height; |
264 VLOG(1) << "Initial screen geometry: " << width << "x" << height; | 267 logger_->VLog(1, "Initial screen geometry: %dx%d", width, height); |
265 | 268 |
266 // TODO(ajwong): What to do here? Does the decoder actually need to request | 269 // TODO(ajwong): What to do here? Does the decoder actually need to request |
267 // the right frame size? This is mainly an optimization right? | 270 // the right frame size? This is mainly an optimization right? |
268 // rectangle_decoder_->SetOutputFrameSize(width, height); | 271 // rectangle_decoder_->SetOutputFrameSize(width, height); |
269 view_->SetViewport(0, 0, width, height); | 272 view_->SetViewport(0, 0, width, height); |
270 | 273 |
271 // Initialize the decoder. | 274 // Initialize the decoder. |
272 rectangle_decoder_->Initialize(config); | 275 rectangle_decoder_->Initialize(config); |
273 | 276 |
274 // Schedule the input handler to process the event queue. | 277 // Schedule the input handler to process the event queue. |
275 input_handler_->Initialize(); | 278 input_handler_->Initialize(); |
276 } | 279 } |
277 | 280 |
278 //////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////// |
279 // ClientStub control channel interface. | 282 // ClientStub control channel interface. |
280 void ChromotingClient::NotifyResolution( | 283 void ChromotingClient::NotifyResolution( |
281 const protocol::NotifyResolutionRequest* msg, Task* done) { | 284 const protocol::NotifyResolutionRequest* msg, Task* done) { |
| 285 logger_->Log(logging::LOG_INFO, "NotifyResolution change"); |
282 NOTIMPLEMENTED(); | 286 NOTIMPLEMENTED(); |
283 done->Run(); | 287 done->Run(); |
284 delete done; | 288 delete done; |
285 } | 289 } |
286 | 290 |
287 void ChromotingClient::BeginSessionResponse( | 291 void ChromotingClient::BeginSessionResponse( |
288 const protocol::LocalLoginStatus* msg, Task* done) { | 292 const protocol::LocalLoginStatus* msg, Task* done) { |
289 if (message_loop() != MessageLoop::current()) { | 293 if (message_loop() != MessageLoop::current()) { |
290 message_loop()->PostTask( | 294 message_loop()->PostTask( |
291 FROM_HERE, | 295 FROM_HERE, |
292 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, | 296 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, |
293 msg, done)); | 297 msg, done)); |
294 return; | 298 return; |
295 } | 299 } |
296 | 300 |
| 301 logger_->Log(logging::LOG_INFO, "BeginSessionResponse received"); |
| 302 |
297 // Inform the connection that the client has been authenticated. This will | 303 // Inform the connection that the client has been authenticated. This will |
298 // enable the communication channels. | 304 // enable the communication channels. |
299 if (msg->success()) { | 305 if (msg->success()) { |
300 connection_->OnClientAuthenticated(); | 306 connection_->OnClientAuthenticated(); |
301 } | 307 } |
302 | 308 |
303 view_->UpdateLoginStatus(msg->success(), msg->error_info()); | 309 view_->UpdateLoginStatus(msg->success(), msg->error_info()); |
304 done->Run(); | 310 done->Run(); |
305 delete done; | 311 delete done; |
306 } | 312 } |
307 | 313 |
308 } // namespace remoting | 314 } // namespace remoting |
OLD | NEW |