| Index: remoting/client/rectangle_update_decoder.cc
|
| diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc
|
| index b653e27d8fca7162966cda8c41ce7235df7a3565..4d3f4769d574511f46be6068d005e0f7d27cbc3d 100644
|
| --- a/remoting/client/rectangle_update_decoder.cc
|
| +++ b/remoting/client/rectangle_update_decoder.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "remoting/client/rectangle_update_decoder.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| #include "remoting/base/decoder.h"
|
| @@ -18,14 +19,17 @@ using remoting::protocol::SessionConfig;
|
|
|
| namespace remoting {
|
|
|
| -class PartialFrameCleanup : public Task {
|
| +class PartialFrameCleanup
|
| + : public base::RefCountedThreadSafe<PartialFrameCleanup> {
|
| public:
|
| PartialFrameCleanup(media::VideoFrame* frame, RectVector* rects,
|
| RectangleUpdateDecoder* decoder)
|
| : frame_(frame), rects_(rects), decoder_(decoder) {
|
| }
|
| + virtual ~PartialFrameCleanup() {
|
| + }
|
|
|
| - virtual void Run() {
|
| + void Run() {
|
| delete rects_;
|
| frame_ = NULL;
|
|
|
| @@ -69,31 +73,25 @@ void RectangleUpdateDecoder::Initialize(const SessionConfig& config) {
|
| }
|
|
|
| void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet,
|
| - Task* done) {
|
| + const base::Closure& done) {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this,
|
| - &RectangleUpdateDecoder::DecodePacket, packet,
|
| - done));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket,
|
| + this, packet, done));
|
| return;
|
| }
|
| - base::ScopedTaskRunner done_runner(done);
|
| -
|
| - AllocateFrame(packet, done_runner.Release());
|
| + AllocateFrame(packet, done);
|
| }
|
|
|
| void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet,
|
| - Task* done) {
|
| + const base::Closure& done) {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(
|
| - this,
|
| - &RectangleUpdateDecoder::AllocateFrame, packet, done));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::AllocateFrame,
|
| + this, packet, done));
|
| return;
|
| }
|
| - base::ScopedTaskRunner done_runner(done);
|
| + base::ScopedClosureRunner done_runner(done);
|
|
|
| // Find the required frame size.
|
| bool has_screen_size = packet->format().has_screen_width() &&
|
| @@ -120,13 +118,10 @@ void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet,
|
| frame_ = NULL;
|
| }
|
|
|
| - consumer_->AllocateFrame(media::VideoFrame::RGB32,
|
| - screen_size.width(), screen_size.height(),
|
| - base::TimeDelta(), base::TimeDelta(),
|
| - &frame_,
|
| - NewRunnableMethod(this,
|
| - &RectangleUpdateDecoder::ProcessPacketData,
|
| - packet, done_runner.Release()));
|
| + consumer_->AllocateFrame(
|
| + media::VideoFrame::RGB32, screen_size, &frame_,
|
| + base::Bind(&RectangleUpdateDecoder::ProcessPacketData,
|
| + this, packet, done_runner.Release()));
|
| frame_is_new_ = true;
|
| return;
|
| }
|
| @@ -134,16 +129,14 @@ void RectangleUpdateDecoder::AllocateFrame(const VideoPacket* packet,
|
| }
|
|
|
| void RectangleUpdateDecoder::ProcessPacketData(
|
| - const VideoPacket* packet, Task* done) {
|
| + const VideoPacket* packet, const base::Closure& done) {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this,
|
| - &RectangleUpdateDecoder::ProcessPacketData, packet,
|
| - done));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::ProcessPacketData,
|
| + this, packet, done));
|
| return;
|
| }
|
| - base::ScopedTaskRunner done_runner(done);
|
| + base::ScopedClosureRunner done_runner(done);
|
|
|
| if (frame_is_new_) {
|
| decoder_->Reset();
|
| @@ -165,11 +158,8 @@ void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio,
|
| double vertical_ratio) {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this,
|
| - &RectangleUpdateDecoder::SetScaleRatios,
|
| - horizontal_ratio,
|
| - vertical_ratio));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetScaleRatios,
|
| + this, horizontal_ratio, vertical_ratio));
|
| return;
|
| }
|
|
|
| @@ -182,10 +172,8 @@ void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio,
|
| void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(
|
| - this,
|
| - &RectangleUpdateDecoder::UpdateClipRect, new_clip_rect));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::UpdateClipRect,
|
| + this, new_clip_rect));
|
| return;
|
| }
|
|
|
| @@ -233,8 +221,7 @@ void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) {
|
| void RectangleUpdateDecoder::RefreshFullFrame() {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this, &RectangleUpdateDecoder::RefreshFullFrame));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::RefreshFullFrame, this));
|
| return;
|
| }
|
|
|
| @@ -261,7 +248,8 @@ void RectangleUpdateDecoder::SubmitToConsumer() {
|
| frame_is_consuming_ = true;
|
| consumer_->OnPartialFrameOutput(
|
| frame_, dirty_rects,
|
| - new PartialFrameCleanup(frame_, dirty_rects, this));
|
| + base::Bind(&PartialFrameCleanup::Run,
|
| + new PartialFrameCleanup(frame_, dirty_rects, this)));
|
| }
|
|
|
| void RectangleUpdateDecoder::DoRefresh() {
|
| @@ -278,8 +266,7 @@ void RectangleUpdateDecoder::DoRefresh() {
|
| void RectangleUpdateDecoder::OnFrameConsumed() {
|
| if (message_loop_ != MessageLoop::current()) {
|
| message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this, &RectangleUpdateDecoder::OnFrameConsumed));
|
| + FROM_HERE, base::Bind(&RectangleUpdateDecoder::OnFrameConsumed, this));
|
| return;
|
| }
|
|
|
|
|