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

Unified Diff: remoting/client/chromoting_client.cc

Issue 9827006: Refactor VideoStub interface to accept ownership of video packets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/chromoting_client.h ('k') | remoting/client/rectangle_update_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/chromoting_client.cc
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 521a875a3874aaf6dda250580f5832a5883c20e3..74f631389582436ddb37bc8d74ea79a83e80e71e 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -19,8 +19,8 @@ namespace remoting {
using protocol::AuthenticationMethod;
ChromotingClient::QueuedVideoPacket::QueuedVideoPacket(
- const VideoPacket* packet, const base::Closure& done)
- : packet(packet), done(done) {
+ scoped_ptr<VideoPacket> packet, const base::Closure& done)
+ : packet(packet.release()), done(done) {
}
ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() {
@@ -78,6 +78,7 @@ void ChromotingClient::Stop(const base::Closure& shutdown_task) {
// Drop all pending packets.
while(!received_packets_.empty()) {
+ delete received_packets_.front().packet;
received_packets_.front().done.Run();
received_packets_.pop_front();
}
@@ -103,7 +104,7 @@ ChromotingStats* ChromotingClient::GetStats() {
return &stats_;
}
-void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet,
+void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
const base::Closure& done) {
DCHECK(message_loop()->BelongsToCurrentThread());
@@ -132,7 +133,7 @@ void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet,
stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
}
- received_packets_.push_back(QueuedVideoPacket(packet, done));
+ received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done));
if (!packet_being_processed_)
DispatchPacket();
}
@@ -150,7 +151,8 @@ void ChromotingClient::DispatchPacket() {
return;
}
- const VideoPacket* packet = received_packets_.front().packet;
+ scoped_ptr<VideoPacket> packet(received_packets_.front().packet);
+ received_packets_.front().packet = NULL;
packet_being_processed_ = true;
// Measure the latency between the last packet being received and presented.
@@ -160,8 +162,9 @@ void ChromotingClient::DispatchPacket() {
decode_start = base::Time::Now();
rectangle_decoder_->DecodePacket(
- packet, base::Bind(&ChromotingClient::OnPacketDone,
- base::Unretained(this), last_packet, decode_start));
+ packet.Pass(),
+ base::Bind(&ChromotingClient::OnPacketDone, base::Unretained(this),
+ last_packet, decode_start));
}
void ChromotingClient::OnConnectionState(
« no previous file with comments | « remoting/client/chromoting_client.h ('k') | remoting/client/rectangle_update_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698