Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: remoting/client/chromoting_client.cc

Issue 8116021: Switch remoting/protocol to new callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/client/chromoting_client.h ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "remoting/client/rectangle_update_decoder.h" 11 #include "remoting/client/rectangle_update_decoder.h"
12 #include "remoting/protocol/connection_to_host.h" 12 #include "remoting/protocol/connection_to_host.h"
13 #include "remoting/protocol/session_config.h" 13 #include "remoting/protocol/session_config.h"
14 14
15 namespace remoting { 15 namespace remoting {
16 16
17 ChromotingClient::QueuedVideoPacket::QueuedVideoPacket(
18 const VideoPacket* packet, const base::Closure& done)
19 : packet(packet), done(done) {
20 }
21
22 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() {
23 }
24
17 ChromotingClient::ChromotingClient(const ClientConfig& config, 25 ChromotingClient::ChromotingClient(const ClientConfig& config,
18 ClientContext* context, 26 ClientContext* context,
19 protocol::ConnectionToHost* connection, 27 protocol::ConnectionToHost* connection,
20 ChromotingView* view, 28 ChromotingView* view,
21 RectangleUpdateDecoder* rectangle_decoder, 29 RectangleUpdateDecoder* rectangle_decoder,
22 InputHandler* input_handler, 30 InputHandler* input_handler,
23 Task* client_done) 31 Task* client_done)
24 : config_(config), 32 : config_(config),
25 context_(context), 33 context_(context),
26 connection_(connection), 34 connection_(connection),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ChromotingStats* ChromotingClient::GetStats() { 83 ChromotingStats* ChromotingClient::GetStats() {
76 return &stats_; 84 return &stats_;
77 } 85 }
78 86
79 void ChromotingClient::Repaint() { 87 void ChromotingClient::Repaint() {
80 DCHECK(message_loop()->BelongsToCurrentThread()); 88 DCHECK(message_loop()->BelongsToCurrentThread());
81 view_->Paint(); 89 view_->Paint();
82 } 90 }
83 91
84 void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet, 92 void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet,
85 Task* done) { 93 const base::Closure& done) {
86 DCHECK(message_loop()->BelongsToCurrentThread()); 94 DCHECK(message_loop()->BelongsToCurrentThread());
87 95
88 // If the video packet is empty then drop it. Empty packets are used to 96 // If the video packet is empty then drop it. Empty packets are used to
89 // maintain activity on the network. 97 // maintain activity on the network.
90 if (!packet->has_data() || packet->data().size() == 0) { 98 if (!packet->has_data() || packet->data().size() == 0) {
91 done->Run(); 99 done.Run();
92 delete done;
93 return; 100 return;
94 } 101 }
95 102
96 // Record size of the packet for statistics. 103 // Record size of the packet for statistics.
97 stats_.video_bandwidth()->Record(packet->data().size()); 104 stats_.video_bandwidth()->Record(packet->data().size());
98 105
99 // Record statistics received from host. 106 // Record statistics received from host.
100 if (packet->has_capture_time_ms()) 107 if (packet->has_capture_time_ms())
101 stats_.video_capture_ms()->Record(packet->capture_time_ms()); 108 stats_.video_capture_ms()->Record(packet->capture_time_ms());
102 if (packet->has_encode_time_ms()) 109 if (packet->has_encode_time_ms())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return; 172 return;
166 } 173 }
167 174
168 // Record the latency between the final packet being received and 175 // Record the latency between the final packet being received and
169 // presented. 176 // presented.
170 if (last_packet) { 177 if (last_packet) {
171 stats_.video_decode_ms()->Record( 178 stats_.video_decode_ms()->Record(
172 (base::Time::Now() - decode_start).InMilliseconds()); 179 (base::Time::Now() - decode_start).InMilliseconds());
173 } 180 }
174 181
175 received_packets_.front().done->Run(); 182 received_packets_.front().done.Run();
176 delete received_packets_.front().done;
177 received_packets_.pop_front(); 183 received_packets_.pop_front();
178 184
179 packet_being_processed_ = false; 185 packet_being_processed_ = false;
180 186
181 // Process the next video packet. 187 // Process the next video packet.
182 DispatchPacket(); 188 DispatchPacket();
183 } 189 }
184 190
185 void ChromotingClient::Initialize() { 191 void ChromotingClient::Initialize() {
186 if (!message_loop()->BelongsToCurrentThread()) { 192 if (!message_loop()->BelongsToCurrentThread()) {
187 thread_proxy_.PostTask(FROM_HERE, base::Bind( 193 thread_proxy_.PostTask(FROM_HERE, base::Bind(
188 &ChromotingClient::Initialize, base::Unretained(this))); 194 &ChromotingClient::Initialize, base::Unretained(this)));
189 return; 195 return;
190 } 196 }
191 197
192 // Initialize the decoder. 198 // Initialize the decoder.
193 rectangle_decoder_->Initialize(connection_->config()); 199 rectangle_decoder_->Initialize(connection_->config());
194 200
195 // Schedule the input handler to process the event queue. 201 // Schedule the input handler to process the event queue.
196 input_handler_->Initialize(); 202 input_handler_->Initialize();
197 } 203 }
198 204
199 //////////////////////////////////////////////////////////////////////////// 205 ////////////////////////////////////////////////////////////////////////////
200 // ClientStub control channel interface. 206 // ClientStub control channel interface.
201 void ChromotingClient::BeginSessionResponse( 207 void ChromotingClient::BeginSessionResponse(
202 const protocol::LocalLoginStatus* msg, Task* done) { 208 const protocol::LocalLoginStatus* msg, const base::Closure& done) {
203 if (!message_loop()->BelongsToCurrentThread()) { 209 if (!message_loop()->BelongsToCurrentThread()) {
204 thread_proxy_.PostTask(FROM_HERE, base::Bind( 210 thread_proxy_.PostTask(FROM_HERE, base::Bind(
205 &ChromotingClient::BeginSessionResponse, base::Unretained(this), 211 &ChromotingClient::BeginSessionResponse, base::Unretained(this),
206 msg, done)); 212 msg, done));
207 return; 213 return;
208 } 214 }
209 215
210 VLOG(1) << "BeginSessionResponse received"; 216 VLOG(1) << "BeginSessionResponse received";
211 217
212 // Inform the connection that the client has been authenticated. This will 218 // Inform the connection that the client has been authenticated. This will
213 // enable the communication channels. 219 // enable the communication channels.
214 if (msg->success()) { 220 if (msg->success()) {
215 connection_->OnClientAuthenticated(); 221 connection_->OnClientAuthenticated();
216 } 222 }
217 223
218 view_->UpdateLoginStatus(msg->success(), msg->error_info()); 224 view_->UpdateLoginStatus(msg->success(), msg->error_info());
219 done->Run(); 225 done.Run();
220 delete done;
221 } 226 }
222 227
223 } // namespace remoting 228 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/chromoting_client.h ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698