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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 base::Time decode_start; | 157 base::Time decode_start; |
161 if (last_packet) | 158 if (last_packet) |
162 decode_start = base::Time::Now(); | 159 decode_start = base::Time::Now(); |
163 | 160 |
164 rectangle_decoder_->DecodePacket( | 161 rectangle_decoder_->DecodePacket( |
165 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, | 162 packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, |
166 last_packet, decode_start)); | 163 last_packet, decode_start)); |
167 } | 164 } |
168 | 165 |
169 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { | 166 void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { |
170 logger_->VLog(1, "ChromotingClient::OnConnectionOpened"); | 167 VLOG(1) << "ChromotingClient::OnConnectionOpened"; |
171 Initialize(); | 168 Initialize(); |
172 SetConnectionState(CONNECTED); | 169 SetConnectionState(CONNECTED); |
173 } | 170 } |
174 | 171 |
175 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { | 172 void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) { |
176 logger_->VLog(1, "ChromotingClient::OnConnectionClosed"); | 173 VLOG(1) << "ChromotingClient::OnConnectionClosed"; |
177 SetConnectionState(DISCONNECTED); | 174 SetConnectionState(DISCONNECTED); |
178 } | 175 } |
179 | 176 |
180 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { | 177 void ChromotingClient::OnConnectionFailed(protocol::ConnectionToHost* conn) { |
181 logger_->VLog(1, "ChromotingClient::OnConnectionFailed"); | 178 VLOG(1) << "ChromotingClient::OnConnectionFailed"; |
182 SetConnectionState(FAILED); | 179 SetConnectionState(FAILED); |
183 } | 180 } |
184 | 181 |
185 MessageLoop* ChromotingClient::message_loop() { | 182 MessageLoop* ChromotingClient::message_loop() { |
186 return context_->jingle_thread()->message_loop(); | 183 return context_->jingle_thread()->message_loop(); |
187 } | 184 } |
188 | 185 |
189 void ChromotingClient::SetConnectionState(ConnectionState s) { | 186 void ChromotingClient::SetConnectionState(ConnectionState s) { |
190 // TODO(ajwong): We actually may want state to be a shared variable. Think | 187 // TODO(ajwong): We actually may want state to be a shared variable. Think |
191 // through later. | 188 // through later. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 void ChromotingClient::BeginSessionResponse( | 252 void ChromotingClient::BeginSessionResponse( |
256 const protocol::LocalLoginStatus* msg, Task* done) { | 253 const protocol::LocalLoginStatus* msg, Task* done) { |
257 if (message_loop() != MessageLoop::current()) { | 254 if (message_loop() != MessageLoop::current()) { |
258 message_loop()->PostTask( | 255 message_loop()->PostTask( |
259 FROM_HERE, | 256 FROM_HERE, |
260 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, | 257 NewRunnableMethod(this, &ChromotingClient::BeginSessionResponse, |
261 msg, done)); | 258 msg, done)); |
262 return; | 259 return; |
263 } | 260 } |
264 | 261 |
265 logger_->Log(logging::LOG_INFO, "BeginSessionResponse received"); | 262 LOG(INFO) << "BeginSessionResponse received"; |
266 | 263 |
267 // Inform the connection that the client has been authenticated. This will | 264 // Inform the connection that the client has been authenticated. This will |
268 // enable the communication channels. | 265 // enable the communication channels. |
269 if (msg->success()) { | 266 if (msg->success()) { |
270 connection_->OnClientAuthenticated(); | 267 connection_->OnClientAuthenticated(); |
271 } | 268 } |
272 | 269 |
273 view_->UpdateLoginStatus(msg->success(), msg->error_info()); | 270 view_->UpdateLoginStatus(msg->success(), msg->error_info()); |
274 done->Run(); | 271 done->Run(); |
275 delete done; | 272 delete done; |
276 } | 273 } |
277 | 274 |
278 } // namespace remoting | 275 } // namespace remoting |
OLD | NEW |