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 "remoting/client/chromoting_view.h" | 8 #include "remoting/client/chromoting_view.h" |
9 #include "remoting/client/client_context.h" | 9 #include "remoting/client/client_context.h" |
10 #include "remoting/client/input_handler.h" | 10 #include "remoting/client/input_handler.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { | 22 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { |
23 } | 23 } |
24 | 24 |
25 ChromotingClient::ChromotingClient(const ClientConfig& config, | 25 ChromotingClient::ChromotingClient(const ClientConfig& config, |
26 ClientContext* context, | 26 ClientContext* context, |
27 protocol::ConnectionToHost* connection, | 27 protocol::ConnectionToHost* connection, |
28 ChromotingView* view, | 28 ChromotingView* view, |
29 RectangleUpdateDecoder* rectangle_decoder, | 29 RectangleUpdateDecoder* rectangle_decoder, |
30 InputHandler* input_handler, | 30 InputHandler* input_handler, |
31 Task* client_done) | 31 const base::Closure& client_done) |
32 : config_(config), | 32 : config_(config), |
33 context_(context), | 33 context_(context), |
34 connection_(connection), | 34 connection_(connection), |
35 view_(view), | 35 view_(view), |
36 rectangle_decoder_(rectangle_decoder), | 36 rectangle_decoder_(rectangle_decoder), |
37 input_handler_(input_handler), | 37 input_handler_(input_handler), |
38 client_done_(client_done), | 38 client_done_(client_done), |
39 packet_being_processed_(false), | 39 packet_being_processed_(false), |
40 last_sequence_number_(0), | 40 last_sequence_number_(0), |
41 thread_proxy_(context_->network_message_loop()) { | 41 thread_proxy_(context_->network_message_loop()) { |
(...skipping 26 matching lines...) Expand all Loading... |
68 base::Unretained(this), shutdown_task)); | 68 base::Unretained(this), shutdown_task)); |
69 } | 69 } |
70 | 70 |
71 void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { | 71 void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { |
72 view_->TearDown(); | 72 view_->TearDown(); |
73 | 73 |
74 shutdown_task.Run(); | 74 shutdown_task.Run(); |
75 } | 75 } |
76 | 76 |
77 void ChromotingClient::ClientDone() { | 77 void ChromotingClient::ClientDone() { |
78 if (client_done_ != NULL) { | 78 if (!client_done_.is_null()) { |
79 message_loop()->PostTask(FROM_HERE, client_done_); | 79 message_loop()->PostTask(FROM_HERE, client_done_); |
| 80 client_done_.Reset(); |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 ChromotingStats* ChromotingClient::GetStats() { | 84 ChromotingStats* ChromotingClient::GetStats() { |
84 return &stats_; | 85 return &stats_; |
85 } | 86 } |
86 | 87 |
87 void ChromotingClient::Repaint() { | 88 void ChromotingClient::Repaint() { |
88 DCHECK(message_loop()->BelongsToCurrentThread()); | 89 DCHECK(message_loop()->BelongsToCurrentThread()); |
89 view_->Paint(); | 90 view_->Paint(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const VideoPacket* packet = received_packets_.front().packet; | 140 const VideoPacket* packet = received_packets_.front().packet; |
140 packet_being_processed_ = true; | 141 packet_being_processed_ = true; |
141 | 142 |
142 // Measure the latency between the last packet being received and presented. | 143 // Measure the latency between the last packet being received and presented. |
143 bool last_packet = (packet->flags() & VideoPacket::LAST_PACKET) != 0; | 144 bool last_packet = (packet->flags() & VideoPacket::LAST_PACKET) != 0; |
144 base::Time decode_start; | 145 base::Time decode_start; |
145 if (last_packet) | 146 if (last_packet) |
146 decode_start = base::Time::Now(); | 147 decode_start = base::Time::Now(); |
147 | 148 |
148 rectangle_decoder_->DecodePacket( | 149 rectangle_decoder_->DecodePacket( |
149 packet, NewRunnableMethod(this, &ChromotingClient::OnPacketDone, | 150 packet, base::Bind(&ChromotingClient::OnPacketDone, |
150 last_packet, decode_start)); | 151 base::Unretained(this), last_packet, decode_start)); |
151 } | 152 } |
152 | 153 |
153 void ChromotingClient::OnConnectionState( | 154 void ChromotingClient::OnConnectionState( |
154 protocol::ConnectionToHost::State state, | 155 protocol::ConnectionToHost::State state, |
155 protocol::ConnectionToHost::Error error) { | 156 protocol::ConnectionToHost::Error error) { |
156 DCHECK(message_loop()->BelongsToCurrentThread()); | 157 DCHECK(message_loop()->BelongsToCurrentThread()); |
157 VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")"; | 158 VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")"; |
158 if (state == protocol::ConnectionToHost::CONNECTED || | 159 if (state == protocol::ConnectionToHost::CONNECTED || |
159 state == protocol::ConnectionToHost::AUTHENTICATED) | 160 state == protocol::ConnectionToHost::AUTHENTICATED) |
160 Initialize(); | 161 Initialize(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 199 } |
199 | 200 |
200 // Initialize the decoder. | 201 // Initialize the decoder. |
201 rectangle_decoder_->Initialize(connection_->config()); | 202 rectangle_decoder_->Initialize(connection_->config()); |
202 | 203 |
203 // Schedule the input handler to process the event queue. | 204 // Schedule the input handler to process the event queue. |
204 input_handler_->Initialize(); | 205 input_handler_->Initialize(); |
205 } | 206 } |
206 | 207 |
207 } // namespace remoting | 208 } // namespace remoting |
OLD | NEW |