diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 02:07:41 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 02:07:41 +0000 |
commit | 1e1cb3bc787a85e1791f737f831d00ee08db364d (patch) | |
tree | ab228ff464b8bd78aee795e58262bd6c11e5f3dc | |
parent | be4565bce9bb1a5b3f5477cc27e20da6ddcc1de7 (diff) | |
download | chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.zip chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.gz chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.bz2 |
Move code in src/remoting to the new callbacks.
BUG=None
TEST=Remoting still works.
Review URL: http://codereview.chromium.org/8493020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109367 0039d316-1c4b-4281-b951-d872f2087c98
58 files changed, 254 insertions, 357 deletions
diff --git a/remoting/base/base_mock_objects.h b/remoting/base/base_mock_objects.h index 92f17bf..e90530d 100644 --- a/remoting/base/base_mock_objects.h +++ b/remoting/base/base_mock_objects.h @@ -20,7 +20,7 @@ class MockEncoder : public Encoder { MOCK_METHOD3(Encode, void( scoped_refptr<CaptureData> capture_data, bool key_frame, - DataAvailableCallback* data_available_callback)); + const DataAvailableCallback& data_available_callback)); private: DISALLOW_COPY_AND_ASSIGN(MockEncoder); diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc index 6754a08..efe7055 100644 --- a/remoting/base/codec_test.cc +++ b/remoting/base/codec_test.cc @@ -5,6 +5,8 @@ #include <deque> #include <stdlib.h> +#include "base/bind.h" +#include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "media/base/video_frame.h" #include "remoting/base/base_mock_objects.h" @@ -269,8 +271,8 @@ static void TestEncodingRects(Encoder* encoder, } tester->AddRects(rects, count); - encoder->Encode(data, true, - NewCallback(tester, &EncoderTester::DataAvailable)); + encoder->Encode(data, true, base::Bind( + &EncoderTester::DataAvailable, base::Unretained(tester))); } void TestEncoder(Encoder* encoder, bool strict) { @@ -318,8 +320,8 @@ static void TestEncodingRects(Encoder* encoder, } } - encoder->Encode(data, true, - NewCallback(encoder_tester, &EncoderTester::DataAvailable)); + encoder->Encode(data, true, base::Bind(&EncoderTester::DataAvailable, + base::Unretained(encoder_tester))); decoder_tester->VerifyResults(); decoder_tester->Reset(); } @@ -351,5 +353,3 @@ void TestEncoderDecoder(Encoder* encoder, Decoder* decoder, bool strict) { } } // namespace remoting - -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester); diff --git a/remoting/base/compound_buffer_unittest.cc b/remoting/base/compound_buffer_unittest.cc index 60b9b78..5ad3dce 100644 --- a/remoting/base/compound_buffer_unittest.cc +++ b/remoting/base/compound_buffer_unittest.cc @@ -4,7 +4,8 @@ #include <string> -#include "base/callback_old.h" +#include "base/bind.h" +#include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "net/base/io_buffer.h" #include "remoting/base/compound_buffer.h" @@ -82,7 +83,7 @@ class CompoundBufferTest : public testing::Test { // Iterate over chunks of data with sizes specified in |sizes| in the // interval [0..kDataSize]. |function| is called for each chunk. void IterateOverPieces(const int sizes[], - Callback2<int, int>::Type* function) { + const base::Callback<void(int, int)>& function) { DCHECK_GT(sizes[0], 0); int pos = 0; @@ -93,11 +94,10 @@ class CompoundBufferTest : public testing::Test { if (sizes[index] <= 0) index = 0; - function->Run(pos, size); + function.Run(pos, size); pos += size; } - delete function; } bool CompareData(const CompoundBuffer& buffer, char* data, int size) { @@ -179,89 +179,81 @@ class CompoundBufferTest : public testing::Test { TEST_F(CompoundBufferTest, Append) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, AppendCopyOf) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::AppendCopyOf)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::AppendCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::AppendCopyOf)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::AppendCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, Prepend) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Prepend)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::Prepend, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Prepend)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Prepend, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, PrependCopyOf) { target_.Clear(); - IterateOverPieces(kChunkSizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::PrependCopyOf)); + IterateOverPieces(kChunkSizes0, base::Bind( + &CompoundBufferTest::PrependCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::PrependCopyOf)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::PrependCopyOf, base::Unretained(this))); EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } TEST_F(CompoundBufferTest, CropFront) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); - IterateOverPieces(kCropSizes, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCropFront)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); + IterateOverPieces(kCropSizes, base::Bind( + &CompoundBufferTest::TestCropFront, base::Unretained(this))); } TEST_F(CompoundBufferTest, CropBack) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); - IterateOverPieces(kCropSizes, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCropBack)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); + IterateOverPieces(kCropSizes, base::Bind( + &CompoundBufferTest::TestCropBack, base::Unretained(this))); } TEST_F(CompoundBufferTest, CopyFrom) { target_.Clear(); - IterateOverPieces(kChunkSizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kChunkSizes1, base::Bind( + &CompoundBufferTest::Append, base::Unretained(this))); { SCOPED_TRACE("CopyFrom.kCopySizes0"); - IterateOverPieces(kCopySizes0, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCopyFrom)); + IterateOverPieces(kCopySizes0, base::Bind( + &CompoundBufferTest::TestCopyFrom, base::Unretained(this))); } { SCOPED_TRACE("CopyFrom.kCopySizes1"); - IterateOverPieces(kCopySizes1, NewCallback( - static_cast<CompoundBufferTest*>(this), - &CompoundBufferTest::TestCopyFrom)); + IterateOverPieces(kCopySizes1, base::Bind( + &CompoundBufferTest::TestCopyFrom, base::Unretained(this))); } } diff --git a/remoting/base/decoder.h b/remoting/base/decoder.h index dded484..d932ff1 100644 --- a/remoting/base/decoder.h +++ b/remoting/base/decoder.h @@ -8,7 +8,6 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/task.h" #include "media/base/video_frame.h" #include "remoting/proto/video.pb.h" #include "third_party/skia/include/core/SkRect.h" diff --git a/remoting/base/decoder_row_based.cc b/remoting/base/decoder_row_based.cc index e6fcf95..cf89677 100644 --- a/remoting/base/decoder_row_based.cc +++ b/remoting/base/decoder_row_based.cc @@ -4,6 +4,7 @@ #include "remoting/base/decoder_row_based.h" +#include "base/logging.h" #include "remoting/base/decompressor.h" #include "remoting/base/decompressor_zlib.h" #include "remoting/base/decompressor_verbatim.h" diff --git a/remoting/base/decoder_vp8.cc b/remoting/base/decoder_vp8.cc index 4befd69..ff1bd77 100644 --- a/remoting/base/decoder_vp8.cc +++ b/remoting/base/decoder_vp8.cc @@ -4,6 +4,7 @@ #include "remoting/base/decoder_vp8.h" +#include "base/logging.h" #include "media/base/media.h" #include "media/base/yuv_convert.h" #include "remoting/base/util.h" diff --git a/remoting/base/encoder.h b/remoting/base/encoder.h index 65b74a4..d1f226a 100644 --- a/remoting/base/encoder.h +++ b/remoting/base/encoder.h @@ -6,7 +6,7 @@ #define REMOTING_BASE_ENCODER_H_ #include "base/basictypes.h" -#include "base/callback_old.h" +#include "base/callback.h" #include "media/base/data_buffer.h" namespace media { @@ -29,7 +29,7 @@ class Encoder { // of HostMessage to reduce the amount of memory copies. // The callback takes ownership of the HostMessage and is responsible for // deleting it. - typedef Callback1<VideoPacket*>::Type DataAvailableCallback; + typedef base::Callback<void(VideoPacket*)> DataAvailableCallback; virtual ~Encoder() {} @@ -42,7 +42,7 @@ class Encoder { // is called. virtual void Encode(scoped_refptr<CaptureData> capture_data, bool key_frame, - DataAvailableCallback* data_available_callback) = 0; + const DataAvailableCallback& data_available_callback) = 0; }; } // namespace remoting diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc index c8a801f..332cde3 100644 --- a/remoting/base/encoder_row_based.cc +++ b/remoting/base/encoder_row_based.cc @@ -56,14 +56,15 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor, EncoderRowBased::~EncoderRowBased() {} -void EncoderRowBased::Encode(scoped_refptr<CaptureData> capture_data, - bool key_frame, - DataAvailableCallback* data_available_callback) { +void EncoderRowBased::Encode( + scoped_refptr<CaptureData> capture_data, + bool key_frame, + const DataAvailableCallback& data_available_callback) { CHECK(capture_data->pixel_format() == media::VideoFrame::RGB32) << "RowBased Encoder only works with RGB32. Got " << capture_data->pixel_format(); capture_data_ = capture_data; - callback_.reset(data_available_callback); + callback_ = data_available_callback; const SkRegion& region = capture_data->dirty_region(); SkRegion::Iterator iter(region); @@ -74,7 +75,7 @@ void EncoderRowBased::Encode(scoped_refptr<CaptureData> capture_data, } capture_data_ = NULL; - callback_.reset(); + callback_.Reset(); } void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) { @@ -131,7 +132,7 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) { // If we have filled the message or we have reached the end of stream. if (filled == packet_size_ || !compress_again) { packet->mutable_data()->resize(filled); - callback_->Run(packet); + callback_.Run(packet); packet = NULL; } diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h index c510a41..a34a2b6 100644 --- a/remoting/base/encoder_row_based.h +++ b/remoting/base/encoder_row_based.h @@ -30,9 +30,10 @@ class EncoderRowBased : public Encoder { virtual ~EncoderRowBased(); - virtual void Encode(scoped_refptr<CaptureData> capture_data, - bool key_frame, - DataAvailableCallback* data_available_callback); + virtual void Encode( + scoped_refptr<CaptureData> capture_data, + bool key_frame, + const DataAvailableCallback& data_available_callback) OVERRIDE; private: EncoderRowBased(Compressor* compressor, VideoPacketFormat::Encoding encoding); @@ -58,7 +59,7 @@ class EncoderRowBased : public Encoder { scoped_ptr<Compressor> compressor_; scoped_refptr<CaptureData> capture_data_; - scoped_ptr<DataAvailableCallback> callback_; + DataAvailableCallback callback_; // The most recent screen size. SkISize screen_size_; diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc index 42369e8..6317821 100644 --- a/remoting/base/encoder_vp8.cc +++ b/remoting/base/encoder_vp8.cc @@ -216,7 +216,7 @@ void EncoderVp8::PrepareActiveMap(const RectVector& updated_rects) { void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, bool key_frame, - DataAvailableCallback* data_available_callback) { + const DataAvailableCallback& data_available_callback) { if (!initialized_ || (capture_data->size() != size_)) { bool ret = Init(capture_data->size()); // TODO(hclam): Handle error better. @@ -293,8 +293,7 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, rect->set_height(updated_rects[i].height()); } - data_available_callback->Run(message); - delete data_available_callback; + data_available_callback.Run(message); } } // namespace remoting diff --git a/remoting/base/encoder_vp8.h b/remoting/base/encoder_vp8.h index 1d145e8..81cfff0 100644 --- a/remoting/base/encoder_vp8.h +++ b/remoting/base/encoder_vp8.h @@ -22,9 +22,10 @@ class EncoderVp8 : public Encoder { EncoderVp8(); virtual ~EncoderVp8(); - virtual void Encode(scoped_refptr<CaptureData> capture_data, - bool key_frame, - DataAvailableCallback* data_available_callback); + virtual void Encode( + scoped_refptr<CaptureData> capture_data, + bool key_frame, + const DataAvailableCallback& data_available_callback) OVERRIDE; private: typedef std::vector<SkIRect> RectVector; diff --git a/remoting/base/encoder_vp8_unittest.cc b/remoting/base/encoder_vp8_unittest.cc index 73fb157..94be428 100644 --- a/remoting/base/encoder_vp8_unittest.cc +++ b/remoting/base/encoder_vp8_unittest.cc @@ -5,6 +5,7 @@ #include <limits> #include <vector> +#include "base/bind.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "remoting/base/capture_data.h" @@ -51,13 +52,15 @@ TEST(EncoderVp8Test, TestSizeChangeNoLeak) { scoped_refptr<CaptureData> capture_data(new CaptureData( planes, SkISize::Make(width, height), media::VideoFrame::RGB32)); encoder.Encode(capture_data, false, - NewCallback(&callback, &EncoderCallback::DataAvailable)); + base::Bind(&EncoderCallback::DataAvailable, + base::Unretained(&callback))); height /= 2; capture_data = new CaptureData(planes, SkISize::Make(width, height), media::VideoFrame::RGB32); encoder.Encode(capture_data, false, - NewCallback(&callback, &EncoderCallback::DataAvailable)); + base::Bind(&EncoderCallback::DataAvailable, + base::Unretained(&callback))); } TEST(EncoderVp8Test, AlignAndClipRect) { diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index e50d95d3..f07b5e8 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -28,7 +28,7 @@ ChromotingClient::ChromotingClient(const ClientConfig& config, ChromotingView* view, RectangleUpdateDecoder* rectangle_decoder, InputHandler* input_handler, - Task* client_done) + const base::Closure& client_done) : config_(config), context_(context), connection_(connection), @@ -81,8 +81,9 @@ void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { } void ChromotingClient::ClientDone() { - if (client_done_ != NULL) { + if (!client_done_.is_null()) { message_loop()->PostTask(FROM_HERE, client_done_); + client_done_.Reset(); } } @@ -152,8 +153,8 @@ void ChromotingClient::DispatchPacket() { decode_start = base::Time::Now(); rectangle_decoder_->DecodePacket( - packet, NewRunnableMethod(this, &ChromotingClient::OnPacketDone, - last_packet, decode_start)); + packet, base::Bind(&ChromotingClient::OnPacketDone, + base::Unretained(this), last_packet, decode_start)); } void ChromotingClient::OnConnectionState( diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index 124e425..fe48057 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -9,7 +9,7 @@ #include <list> -#include "base/task.h" +#include "base/callback.h" #include "base/time.h" #include "remoting/base/scoped_thread_proxy.h" #include "remoting/client/client_config.h" @@ -46,7 +46,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, ChromotingView* view, RectangleUpdateDecoder* rectangle_decoder, InputHandler* input_handler, - Task* client_done); + const base::Closure& client_done); virtual ~ChromotingClient(); void Start(scoped_refptr<XmppProxy> xmpp_proxy); @@ -102,7 +102,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, InputHandler* input_handler_; // If non-NULL, this is called when the client is done. - Task* client_done_; + base::Closure client_done_; // Contains all video packets that have been received, but have not yet been // processed. @@ -127,6 +127,4 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); - #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h index 339b3a4..187b3d5 100644 --- a/remoting/client/frame_consumer.h +++ b/remoting/client/frame_consumer.h @@ -18,12 +18,12 @@ class FrameConsumer { // Request a frame be allocated from the FrameConsumer. // - // If a frame cannot be allocated to fit the format, and height/width + // If a frame cannot be allocated to fit the format, and |size| // requirements, |frame_out| will be set to NULL. // - // An allocated frame will have at least the width and height requested, but - // may be bigger. Query the retrun frame for the actual frame size, stride, - // etc. + // An allocated frame will have at least the |size| requested, but + // may be bigger. Query the retrun frame for the actual frame size, + // stride, etc. // // The AllocateFrame call is asynchronous. From invocation, until when the // |done| callback is invoked, |frame_out| should be considered to be locked @@ -35,12 +35,9 @@ class FrameConsumer { // All frames retrieved via the AllocateFrame call must be released by a // corresponding call ReleaseFrame(scoped_refptr<VideoFrame>* frame_out. virtual void AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, + const SkISize& size, scoped_refptr<media::VideoFrame>* frame_out, - Task* done) = 0; + const base::Closure& done) = 0; virtual void ReleaseFrame(media::VideoFrame* frame) = 0; @@ -52,7 +49,7 @@ class FrameConsumer { // callback is invoked. virtual void OnPartialFrameOutput(media::VideoFrame* frame, RectVector* rects, - Task* done) = 0; + const base::Closure& done) = 0; private: DISALLOW_COPY_AND_ASSIGN(FrameConsumer); diff --git a/remoting/client/input_handler.h b/remoting/client/input_handler.h index c1c783b..34265f6 100644 --- a/remoting/client/input_handler.h +++ b/remoting/client/input_handler.h @@ -50,6 +50,4 @@ class InputHandler { } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::InputHandler); - #endif // REMOTING_CLIENT_INPUT_HANDLER_H_ diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 5657839..822fa33 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -136,7 +136,7 @@ void ChromotingInstance::Connect(const ClientConfig& config) { client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), view_proxy_, rectangle_decoder_.get(), - input_handler_.get(), NULL)); + input_handler_.get(), base::Closure())); LOG(INFO) << "Connecting to " << config.host_jid << ". Local jid: " << config.local_jid << "."; diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h index de87a48..22ec759 100644 --- a/remoting/client/plugin/pepper_input_handler.h +++ b/remoting/client/plugin/pepper_input_handler.h @@ -45,6 +45,4 @@ class PepperInputHandler : public InputHandler { } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperInputHandler); - #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index fa20c06..3d6a71d 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -6,6 +6,7 @@ #include "base/message_loop.h" #include "base/string_util.h" +#include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/graphics_2d.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/point.h" @@ -309,21 +310,16 @@ double PepperView::GetVerticalScaleRatio() const { } void PepperView::AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, + const SkISize& size, scoped_refptr<media::VideoFrame>* frame_out, - Task* done) { + const base::Closure& done) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); - *frame_out = media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, - width, height, - base::TimeDelta(), - base::TimeDelta()); + *frame_out = media::VideoFrame::CreateFrame( + media::VideoFrame::RGB32, size.width(), size.height(), + base::TimeDelta(), base::TimeDelta()); (*frame_out)->AddRef(); - done->Run(); - delete done; + done.Run(); } void PepperView::ReleaseFrame(media::VideoFrame* frame) { @@ -335,14 +331,13 @@ void PepperView::ReleaseFrame(media::VideoFrame* frame) { void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, RectVector* rects, - Task* done) { + const base::Closure& done) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); // TODO(ajwong): Clean up this API to be async so we don't need to use a // member variable as a hack. PaintFrame(frame, rects); - done->Run(); - delete done; + done.Run(); } void PepperView::OnPaintDone(base::Time paint_start) { diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h index 4053d66..9036650 100644 --- a/remoting/client/plugin/pepper_view.h +++ b/remoting/client/plugin/pepper_view.h @@ -47,16 +47,13 @@ class PepperView : public ChromotingView, // FrameConsumer implementation. virtual void AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, + const SkISize& size, scoped_refptr<media::VideoFrame>* frame_out, - Task* done); - virtual void ReleaseFrame(media::VideoFrame* frame); + const base::Closure& done) OVERRIDE; + virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; virtual void OnPartialFrameOutput(media::VideoFrame* frame, RectVector* rects, - Task* done); + const base::Closure& done) OVERRIDE; // This is called when the dimension of the plugin element has changed. // Return true if plugin size has changed, false otherwise. diff --git a/remoting/client/plugin/pepper_view_proxy.cc b/remoting/client/plugin/pepper_view_proxy.cc index 66ec46c..189602f 100644 --- a/remoting/client/plugin/pepper_view_proxy.cc +++ b/remoting/client/plugin/pepper_view_proxy.cc @@ -30,7 +30,7 @@ bool PepperViewProxy::Initialize() { void PepperViewProxy::TearDown() { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { plugin_message_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &PepperViewProxy::TearDown)); + FROM_HERE, base::Bind(&PepperViewProxy::TearDown, this)); return; } @@ -41,7 +41,7 @@ void PepperViewProxy::TearDown() { void PepperViewProxy::Paint() { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { plugin_message_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &PepperViewProxy::Paint)); + FROM_HERE, base::Bind(&PepperViewProxy::Paint, this)); return; } @@ -51,8 +51,8 @@ void PepperViewProxy::Paint() { void PepperViewProxy::SetSolidFill(uint32 color) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &PepperViewProxy::SetSolidFill, color)); + plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + &PepperViewProxy::SetSolidFill, this, color)); return; } @@ -63,7 +63,7 @@ void PepperViewProxy::SetSolidFill(uint32 color) { void PepperViewProxy::UnsetSolidFill() { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { plugin_message_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &PepperViewProxy::UnsetSolidFill)); + FROM_HERE, base::Bind(&PepperViewProxy::UnsetSolidFill, this)); return; } @@ -75,8 +75,8 @@ void PepperViewProxy::SetConnectionState( protocol::ConnectionToHost::State state, protocol::ConnectionToHost::Error error) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &PepperViewProxy::SetConnectionState, state, error)); + plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + &PepperViewProxy::SetConnectionState, this, state, error)); return; } @@ -106,29 +106,24 @@ double PepperViewProxy::GetVerticalScaleRatio() const { void PepperViewProxy::AllocateFrame( media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, + const SkISize& size, scoped_refptr<media::VideoFrame>* frame_out, - Task* done) { + const base::Closure& done) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &PepperViewProxy::AllocateFrame, format, width, - height, timestamp, duration, frame_out, done)); + plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + &PepperViewProxy::AllocateFrame, this, format, size, frame_out, done)); return; } if (view_) { - view_->AllocateFrame(format, width, height, timestamp, duration, frame_out, - done); + view_->AllocateFrame(format, size, frame_out, done); } } void PepperViewProxy::ReleaseFrame(media::VideoFrame* frame) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &PepperViewProxy::ReleaseFrame, make_scoped_refptr(frame))); + plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + &PepperViewProxy::ReleaseFrame, this, make_scoped_refptr(frame))); return; } @@ -138,10 +133,10 @@ void PepperViewProxy::ReleaseFrame(media::VideoFrame* frame) { void PepperViewProxy::OnPartialFrameOutput(media::VideoFrame* frame, RectVector* rects, - Task* done) { + const base::Closure& done) { if (instance_ && !plugin_message_loop_->BelongsToCurrentThread()) { - plugin_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &PepperViewProxy::OnPartialFrameOutput, + plugin_message_loop_->PostTask(FROM_HERE, base::Bind( + &PepperViewProxy::OnPartialFrameOutput, this, make_scoped_refptr(frame), rects, done)); return; } diff --git a/remoting/client/plugin/pepper_view_proxy.h b/remoting/client/plugin/pepper_view_proxy.h index b52623f..be55233 100644 --- a/remoting/client/plugin/pepper_view_proxy.h +++ b/remoting/client/plugin/pepper_view_proxy.h @@ -53,16 +53,13 @@ class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>, // FrameConsumer implementation. virtual void AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, + const SkISize& size, scoped_refptr<media::VideoFrame>* frame_out, - Task* done); - virtual void ReleaseFrame(media::VideoFrame* frame); + const base::Closure& done) OVERRIDE; + virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; virtual void OnPartialFrameOutput(media::VideoFrame* frame, RectVector* rects, - Task* done); + const base::Closure& done) OVERRIDE; // Remove the reference to |instance_| and |view_| by setting the value to // NULL. diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index b653e27..9e09d7f 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,28 +19,6 @@ using remoting::protocol::SessionConfig; namespace remoting { -class PartialFrameCleanup : public Task { - public: - PartialFrameCleanup(media::VideoFrame* frame, RectVector* rects, - RectangleUpdateDecoder* decoder) - : frame_(frame), rects_(rects), decoder_(decoder) { - } - - virtual void Run() { - delete rects_; - frame_ = NULL; - - // There maybe pending request to refresh rectangles. - decoder_->OnFrameConsumed(); - decoder_ = NULL; - } - - private: - scoped_refptr<media::VideoFrame> frame_; - RectVector* rects_; - scoped_refptr<RectangleUpdateDecoder> decoder_; -}; - RectangleUpdateDecoder::RectangleUpdateDecoder(MessageLoop* message_loop, FrameConsumer* consumer) : message_loop_(message_loop), @@ -69,31 +48,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 +93,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 +104,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 +133,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 +147,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 +196,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; } @@ -259,9 +221,8 @@ void RectangleUpdateDecoder::SubmitToConsumer() { decoder_->GetUpdatedRects(dirty_rects); frame_is_consuming_ = true; - consumer_->OnPartialFrameOutput( - frame_, dirty_rects, - new PartialFrameCleanup(frame_, dirty_rects, this)); + consumer_->OnPartialFrameOutput(frame_, dirty_rects, base::Bind( + &RectangleUpdateDecoder::OnFrameConsumed, this, dirty_rects)); } void RectangleUpdateDecoder::DoRefresh() { @@ -275,14 +236,16 @@ void RectangleUpdateDecoder::DoRefresh() { SubmitToConsumer(); } -void RectangleUpdateDecoder::OnFrameConsumed() { +void RectangleUpdateDecoder::OnFrameConsumed(RectVector* rects) { if (message_loop_ != MessageLoop::current()) { message_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &RectangleUpdateDecoder::OnFrameConsumed)); + FROM_HERE, base::Bind(&RectangleUpdateDecoder::OnFrameConsumed, + this, rects)); return; } + delete rects; + frame_is_consuming_ = false; DoRefresh(); } diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index d44bb6f..1a61856 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -38,10 +38,7 @@ class RectangleUpdateDecoder : // regsitered as data is avaialable. DecodePacket may keep a reference to // |packet| so the |packet| must remain alive and valid until |done| is // executed. - // - // TODO(ajwong): Should packet be a const pointer to make the lifetime - // more clear? - void DecodePacket(const VideoPacket* packet, Task* done); + void DecodePacket(const VideoPacket* packet, const base::Closure& done); // Set the scale ratio for the decoded video frame. Scale ratio greater // than 1.0 is not supported. @@ -64,8 +61,8 @@ class RectangleUpdateDecoder : ~RectangleUpdateDecoder(); - void AllocateFrame(const VideoPacket* packet, Task* done); - void ProcessPacketData(const VideoPacket* packet, Task* done); + void AllocateFrame(const VideoPacket* packet, const base::Closure& done); + void ProcessPacketData(const VideoPacket* packet, const base::Closure& done); void RefreshRects(const RectVector& rects); // Obtain updated rectangles from decoder and submit it to the consumer. @@ -75,9 +72,8 @@ class RectangleUpdateDecoder : // When done the affected rectangles are submitted to the consumer. void DoRefresh(); - // Called by PartialFrameCleanup when consumer has finished using our - // internal frame. - void OnFrameConsumed(); + // Callback for FrameConsumer::OnPartialFrameOutput() + void OnFrameConsumed(RectVector* rects); // Pointers to infrastructure objects. Not owned. MessageLoop* message_loop_; @@ -99,6 +95,4 @@ class RectangleUpdateDecoder : } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::RectangleUpdateDecoder); - #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H diff --git a/remoting/host/capturer.h b/remoting/host/capturer.h index e29b7f5..9039e04 100644 --- a/remoting/host/capturer.h +++ b/remoting/host/capturer.h @@ -6,7 +6,7 @@ #define REMOTING_HOST_CAPTURER_H_ #include "base/basictypes.h" -#include "base/callback_old.h" +#include "base/callback.h" #include "remoting/base/capture_data.h" #include "third_party/skia/include/core/SkRegion.h" @@ -38,7 +38,8 @@ namespace remoting { class Capturer { public: // CaptureCompletedCallback is called when the capturer has completed. - typedef Callback1<scoped_refptr<CaptureData> >::Type CaptureCompletedCallback; + typedef base::Callback<void(scoped_refptr<CaptureData>)> + CaptureCompletedCallback; virtual ~Capturer() {}; @@ -73,7 +74,8 @@ class Capturer { // data of the previous capture. // There can be at most one concurrent read going on when this // method is called. - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) = 0; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) = 0; // Get the size of the most recently captured screen. virtual const SkISize& size_most_recent() const = 0; diff --git a/remoting/host/capturer_fake.cc b/remoting/host/capturer_fake.cc index 88bac10..647a148 100644 --- a/remoting/host/capturer_fake.cc +++ b/remoting/host/capturer_fake.cc @@ -68,9 +68,8 @@ void CapturerFake::InvalidateFullScreen() { helper.InvalidateFullScreen(); } -void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) { - scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); - +void CapturerFake::CaptureInvalidRegion( + const CaptureCompletedCallback& callback) { GenerateImage(); InvalidateScreen(size_); @@ -89,7 +88,7 @@ void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) { helper.set_size_most_recent(capture_data->size()); - callback->Run(capture_data); + callback.Run(capture_data); } const SkISize& CapturerFake::size_most_recent() const { diff --git a/remoting/host/capturer_fake.h b/remoting/host/capturer_fake.h index 252fd40..ba74a98 100644 --- a/remoting/host/capturer_fake.h +++ b/remoting/host/capturer_fake.h @@ -27,8 +27,8 @@ class CapturerFake : public Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) - OVERRIDE; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) OVERRIDE; virtual const SkISize& size_most_recent() const OVERRIDE; private: diff --git a/remoting/host/capturer_fake_ascii.cc b/remoting/host/capturer_fake_ascii.cc index f2bb5d2..e0f5845 100644 --- a/remoting/host/capturer_fake_ascii.cc +++ b/remoting/host/capturer_fake_ascii.cc @@ -52,9 +52,7 @@ void CapturerFakeAscii::InvalidateFullScreen() { } void CapturerFakeAscii::CaptureInvalidRegion( - CaptureCompletedCallback* callback) { - scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); - + const CaptureCompletedCallback& callback) { GenerateImage(); DataPlanes planes; planes.data[0] = buffers_[current_buffer_].get(); @@ -65,7 +63,7 @@ void CapturerFakeAscii::CaptureInvalidRegion( helper_.set_size_most_recent(capture_data->size()); - callback->Run(capture_data); + callback.Run(capture_data); } const SkISize& CapturerFakeAscii::size_most_recent() const { diff --git a/remoting/host/capturer_fake_ascii.h b/remoting/host/capturer_fake_ascii.h index 8902cee..07261e3 100644 --- a/remoting/host/capturer_fake_ascii.h +++ b/remoting/host/capturer_fake_ascii.h @@ -28,8 +28,8 @@ class CapturerFakeAscii : public Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) - OVERRIDE; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) OVERRIDE; virtual const SkISize& size_most_recent() const; private: diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc index 062f259..239aa16 100644 --- a/remoting/host/capturer_linux.cc +++ b/remoting/host/capturer_linux.cc @@ -79,8 +79,8 @@ class CapturerLinux : public Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) - OVERRIDE; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) OVERRIDE; virtual const SkISize& size_most_recent() const OVERRIDE; private: @@ -264,9 +264,7 @@ void CapturerLinux::InvalidateFullScreen() { } void CapturerLinux::CaptureInvalidRegion( - CaptureCompletedCallback* callback) { - scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); - + const CaptureCompletedCallback& callback) { // TODO(lambroslambrou): In the non-DAMAGE case, there should be no need // for any X event processing in this class. ProcessPendingXEvents(); @@ -286,7 +284,7 @@ void CapturerLinux::CaptureInvalidRegion( current_buffer_ = (current_buffer_ + 1) % kNumBuffers; helper_.set_size_most_recent(capture_data->size()); - callback->Run(capture_data); + callback.Run(capture_data); } void CapturerLinux::ProcessPendingXEvents() { diff --git a/remoting/host/capturer_mac.cc b/remoting/host/capturer_mac.cc index a4ee518..394c8b1 100644 --- a/remoting/host/capturer_mac.cc +++ b/remoting/host/capturer_mac.cc @@ -153,8 +153,8 @@ class CapturerMac : public Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) - OVERRIDE; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) OVERRIDE; virtual const SkISize& size_most_recent() const OVERRIDE; private: @@ -163,12 +163,12 @@ class CapturerMac : public Capturer { void CgBlitPreLion(const VideoFrameBuffer& buffer, const SkRegion& region); void CgBlitPostLion(const VideoFrameBuffer& buffer, const SkRegion& region); void CaptureRegion(const SkRegion& region, - CaptureCompletedCallback* callback); + const CaptureCompletedCallback& callback); void ScreenRefresh(CGRectCount count, const CGRect *rect_array); void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, - size_t count, - const CGRect *rect_array); + size_t count, + const CGRect *rect_array); void DisplaysReconfigured(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags); static void ScreenRefreshCallback(CGRectCount count, @@ -346,7 +346,8 @@ void CapturerMac::InvalidateFullScreen() { helper_.InvalidateFullScreen(); } -void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) { +void CapturerMac::CaptureInvalidRegion( + const CaptureCompletedCallback& callback) { // Only allow captures when the display configuration is not occurring. scoped_refptr<CaptureData> data; @@ -391,8 +392,7 @@ void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) { helper_.set_size_most_recent(data->size()); display_configuration_capture_event_.Signal(); - callback->Run(data); - delete callback; + callback.Run(data); } void CapturerMac::GlBlitFast(const VideoFrameBuffer& buffer, diff --git a/remoting/host/capturer_mac_unittest.cc b/remoting/host/capturer_mac_unittest.cc index 80deedb..e6224ba 100644 --- a/remoting/host/capturer_mac_unittest.cc +++ b/remoting/host/capturer_mac_unittest.cc @@ -8,6 +8,7 @@ #include <ostream> +#include "base/bind.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" @@ -88,14 +89,14 @@ TEST_F(CapturerMacTest, Capture) { SCOPED_TRACE(""); // Check that we get an initial full-screen updated. CapturerCallback1 callback1; - capturer_->CaptureInvalidRegion( - NewCallback(&callback1, &CapturerCallback1::CaptureDoneCallback)); + capturer_->CaptureInvalidRegion(base::Bind( + &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); // Check that subsequent dirty rects are propagated correctly. AddDirtyRect(); CapturerCallback2 callback2(region_); capturer_->InvalidateRegion(region_); - capturer_->CaptureInvalidRegion( - NewCallback(&callback2, &CapturerCallback2::CaptureDoneCallback)); + capturer_->CaptureInvalidRegion(base::Bind( + &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); } } // namespace remoting diff --git a/remoting/host/capturer_win.cc b/remoting/host/capturer_win.cc index cdb84cb..9d8b860 100644 --- a/remoting/host/capturer_win.cc +++ b/remoting/host/capturer_win.cc @@ -30,8 +30,8 @@ class CapturerGdi : public Capturer { virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; virtual void InvalidateScreen(const SkISize& size) OVERRIDE; virtual void InvalidateFullScreen() OVERRIDE; - virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) - OVERRIDE; + virtual void CaptureInvalidRegion( + const CaptureCompletedCallback& callback) OVERRIDE; virtual const SkISize& size_most_recent() const OVERRIDE; private: @@ -62,7 +62,7 @@ class CapturerGdi : public Capturer { void CalculateInvalidRegion(); void CaptureRegion(const SkRegion& region, - CaptureCompletedCallback* callback); + const CaptureCompletedCallback& callback); void ReleaseBuffers(); // Generates an image in the current buffer. @@ -144,7 +144,8 @@ void CapturerGdi::InvalidateFullScreen() { helper_.InvalidateFullScreen(); } -void CapturerGdi::CaptureInvalidRegion(CaptureCompletedCallback* callback) { +void CapturerGdi::CaptureInvalidRegion( + const CaptureCompletedCallback& callback) { CalculateInvalidRegion(); SkRegion invalid_region; helper_.SwapInvalidRegion(&invalid_region); @@ -277,9 +278,7 @@ void CapturerGdi::CalculateInvalidRegion() { } void CapturerGdi::CaptureRegion(const SkRegion& region, - CaptureCompletedCallback* callback) { - scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); - + const CaptureCompletedCallback& callback) { const VideoFrameBuffer& buffer = buffers_[current_buffer_]; current_buffer_ = (current_buffer_ + 1) % kNumBuffers; @@ -294,7 +293,7 @@ void CapturerGdi::CaptureRegion(const SkRegion& region, helper_.set_size_most_recent(data->size()); - callback->Run(data); + callback.Run(data); } void CapturerGdi::CaptureImage() { diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index fe54f78..434552f 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -104,7 +104,7 @@ void ChromotingHost::Start() { } // This method is called when we need to destroy the host process. -void ChromotingHost::Shutdown(Task* shutdown_task) { +void ChromotingHost::Shutdown(const base::Closure& shutdown_task) { if (MessageLoop::current() != context_->main_message_loop()) { context_->main_message_loop()->PostTask( FROM_HERE, @@ -121,7 +121,7 @@ void ChromotingHost::Shutdown(Task* shutdown_task) { context_->main_message_loop()->PostTask(FROM_HERE, shutdown_task); return; } - if (shutdown_task) + if (!shutdown_task.is_null()) shutdown_tasks_.push_back(shutdown_task); if (state_ == kStopping) return; @@ -263,7 +263,7 @@ void ChromotingHost::OnIncomingSession( *response = protocol::SessionManager::DECLINE; // Close existing sessions and shutdown the host. - Shutdown(NULL); + Shutdown(base::Closure()); return; } @@ -331,10 +331,7 @@ void ChromotingHost::LocalMouseMoved(const SkIPoint& new_pos) { void ChromotingHost::PauseSession(bool pause) { if (context_->main_message_loop() != MessageLoop::current()) { context_->main_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, - &ChromotingHost::PauseSession, - pause)); + FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause)); return; } ClientList::iterator client; @@ -610,10 +607,9 @@ void ChromotingHost::ShutdownFinish() { (*it)->OnShutdown(); } - for (std::vector<Task*>::iterator it = shutdown_tasks_.begin(); + for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); it != shutdown_tasks_.end(); ++it) { - (*it)->Run(); - delete *it; + it->Run(); } shutdown_tasks_.clear(); } diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 76c204c..2596afb 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -90,7 +90,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, // Asynchronously shutdown the host process. |shutdown_task| is // called after shutdown is completed. - void Shutdown(Task* shutdown_task); + void Shutdown(const base::Closure& shutdown_task); // Adds |observer| to the list of status observers. Doesn't take // ownership of |observer|, so |observer| must outlive this @@ -245,9 +245,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, std::string access_code_; - // Stores list of tasks that should be executed when we finish + // Stores list of closures that should be executed when we finish // shutdown. Used only while |state_| is set to kStopping. - std::vector<Task*> shutdown_tasks_; + std::vector<base::Closure> shutdown_tasks_; UiStrings ui_strings_; diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index 9a636c0..d5e4df6 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -171,24 +171,20 @@ class ChromotingHostTest : public testing::Test { connection->set_host_stub(client.get()); context_.network_message_loop()->PostTask( - FROM_HERE, - NewRunnableFunction(&ChromotingHostTest::AddClientToHost, - host_, client)); + FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, + host_, client)); if (authenticate) { context_.network_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(client.get(), - &ClientSession::OnAuthenticationComplete)); + FROM_HERE, base::Bind(&ClientSession::OnAuthenticationComplete, + client.get())); } } // Helper method to remove a client connection from ChromotingHost. void RemoveClientConnection() { context_.network_message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(host_.get(), - &ChromotingHost::OnClientDisconnected, - connection_)); + FROM_HERE, base::Bind(&ChromotingHost::OnClientDisconnected, + host_.get(), connection_)); } static void AddClientToHost(scoped_refptr<ChromotingHost> host, @@ -197,8 +193,7 @@ class ChromotingHostTest : public testing::Test { } void ShutdownHost() { - host_->Shutdown( - NewRunnableFunction(&PostQuitTask, &message_loop_)); + host_->Shutdown(base::Bind(&PostQuitTask, &message_loop_)); } protected: @@ -237,9 +232,9 @@ TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { host_->Start(); message_loop_.PostTask( - FROM_HERE,NewRunnableMethod( - host_.get(), &ChromotingHost::Shutdown, - NewRunnableFunction(&PostQuitTask, &message_loop_))); + FROM_HERE, base::Bind( + &ChromotingHost::Shutdown, host_.get(), + base::Bind(&PostQuitTask, &message_loop_))); message_loop_.Run(); } diff --git a/remoting/host/continue_window_linux.cc b/remoting/host/continue_window_linux.cc index 431144d..ddd959c 100644 --- a/remoting/host/continue_window_linux.cc +++ b/remoting/host/continue_window_linux.cc @@ -97,7 +97,7 @@ void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { if (response_id == GTK_RESPONSE_OK) { host_->PauseSession(false); } else { - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); } Hide(); } diff --git a/remoting/host/continue_window_mac.mm b/remoting/host/continue_window_mac.mm index c53c11f..2dac22c 100644 --- a/remoting/host/continue_window_mac.mm +++ b/remoting/host/continue_window_mac.mm @@ -143,7 +143,7 @@ ContinueWindow* ContinueWindow::Create() { - (void)onCancel:(id)sender { [self hide]; - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); host_ = nil; } diff --git a/remoting/host/continue_window_win.cc b/remoting/host/continue_window_win.cc index ed5eea2..73a214a 100644 --- a/remoting/host/continue_window_win.cc +++ b/remoting/host/continue_window_win.cc @@ -95,7 +95,7 @@ BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg, return TRUE; case IDC_CONTINUE_CANCEL: CHECK(host_); - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); ::EndDialog(hwnd, LOWORD(wParam)); hwnd_ = NULL; return TRUE; diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc index d891fe6..c838a0f 100644 --- a/remoting/host/desktop_environment.cc +++ b/remoting/host/desktop_environment.cc @@ -202,7 +202,7 @@ void DesktopEnvironment::OnShutdownHostTimer() { DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); ShowContinueWindow(false); - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); } } // namespace remoting diff --git a/remoting/host/disconnect_window_linux.cc b/remoting/host/disconnect_window_linux.cc index b2dd6f5..b7292d6 100644 --- a/remoting/host/disconnect_window_linux.cc +++ b/remoting/host/disconnect_window_linux.cc @@ -120,7 +120,7 @@ void DisconnectWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { // button were visible). CHECK(host_); - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); Hide(); } diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm index 7c1ab44..94ba855 100644 --- a/remoting/host/disconnect_window_mac.mm +++ b/remoting/host/disconnect_window_mac.mm @@ -90,7 +90,7 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() { - (IBAction)stopSharing:(id)sender { if (self.host) { - self.host->Shutdown(NULL); + self.host->Shutdown(base::Closure()); self.host = NULL; } } diff --git a/remoting/host/disconnect_window_win.cc b/remoting/host/disconnect_window_win.cc index 9f33d2b..a9f7742 100644 --- a/remoting/host/disconnect_window_win.cc +++ b/remoting/host/disconnect_window_win.cc @@ -204,7 +204,7 @@ void DisconnectWindowWin::Show(ChromotingHost* host, void DisconnectWindowWin::ShutdownHost() { CHECK(host_); - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); } static int GetControlTextWidth(HWND control) { diff --git a/remoting/host/host_key_pair.h b/remoting/host/host_key_pair.h index 32a15d0..2ea00a0 100644 --- a/remoting/host/host_key_pair.h +++ b/remoting/host/host_key_pair.h @@ -43,6 +43,4 @@ class HostKeyPair { } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostKeyPair); - #endif // REMOTING_HOST_HOST_KEY_PAIR_H_ diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index 7696dbd..5dbdd7b 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -30,7 +30,8 @@ class MockCapturer : public Capturer { MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region)); MOCK_METHOD1(InvalidateScreen, void(const SkISize&)); MOCK_METHOD0(InvalidateFullScreen, void()); - MOCK_METHOD1(CaptureInvalidRegion, void(CaptureCompletedCallback* callback)); + MOCK_METHOD1(CaptureInvalidRegion, + void(const CaptureCompletedCallback& callback)); MOCK_CONST_METHOD0(size_most_recent, const SkISize&()); private: diff --git a/remoting/host/json_host_config.cc b/remoting/host/json_host_config.cc index 2d2c884..66ac912 100644 --- a/remoting/host/json_host_config.cc +++ b/remoting/host/json_host_config.cc @@ -4,6 +4,7 @@ #include "remoting/host/json_host_config.h" +#include "base/bind.h" #include "base/file_util.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -44,7 +45,7 @@ bool JsonHostConfig::Read() { void JsonHostConfig::Save() { message_loop_proxy_->PostTask( - FROM_HERE, NewRunnableMethod(this, &JsonHostConfig::DoWrite)); + FROM_HERE, base::Bind(&JsonHostConfig::DoWrite, this)); } void JsonHostConfig::DoWrite() { diff --git a/remoting/host/local_input_monitor_mac.mm b/remoting/host/local_input_monitor_mac.mm index c6d9484..6b8f0e0 100644 --- a/remoting/host/local_input_monitor_mac.mm +++ b/remoting/host/local_input_monitor_mac.mm @@ -7,6 +7,7 @@ #import <AppKit/AppKit.h> #include <set> +#include "base/bind.h" #include "base/compiler_specific.h" #include "base/lazy_instance.h" #include "base/logging.h" @@ -99,7 +100,7 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, - (void)hotKeyHit:(GTMCarbonHotKey*)hotKey { base::AutoLock lock(hostsLock_); for (Hosts::const_iterator i = hosts_.begin(); i != hosts_.end(); ++i) { - (*i)->Shutdown(NULL); + (*i)->Shutdown(base::Closure()); } } diff --git a/remoting/host/local_input_monitor_thread_linux.cc b/remoting/host/local_input_monitor_thread_linux.cc index 2f429d6..cae44f1 100644 --- a/remoting/host/local_input_monitor_thread_linux.cc +++ b/remoting/host/local_input_monitor_thread_linux.cc @@ -173,7 +173,7 @@ void LocalInputMonitorThread::LocalKeyPressed(int key_code, bool down) { } else if (key_sym == XK_Alt_L || key_sym == XK_Alt_R) { alt_pressed_ = down; } else if (alt_pressed_ && ctrl_pressed_ && key_sym == XK_Escape && down) { - host_->Shutdown(NULL); + host_->Shutdown(base::Closure()); } } diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index 1838cf0..6fb0171 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -578,7 +578,8 @@ void HostNPScriptObject::DisconnectInternal() { DCHECK(host_); SetState(kDisconnecting); host_->Shutdown( - NewRunnableMethod(this, &HostNPScriptObject::OnShutdownFinished)); + base::Bind(&HostNPScriptObject::OnShutdownFinished, + base::Unretained(this))); } } diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc index 9c23874..d779eca 100644 --- a/remoting/host/screen_recorder.cc +++ b/remoting/host/screen_recorder.cc @@ -60,7 +60,7 @@ ScreenRecorder::~ScreenRecorder() { void ScreenRecorder::Start() { capture_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &ScreenRecorder::DoStart)); + FROM_HERE, base::Bind(&ScreenRecorder::DoStart, this)); } void ScreenRecorder::Stop(const base::Closure& done_task) { @@ -82,35 +82,31 @@ void ScreenRecorder::Stop(const base::Closure& done_task) { void ScreenRecorder::AddConnection( scoped_refptr<ConnectionToClient> connection) { capture_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoInvalidateFullScreen)); + FROM_HERE, base::Bind(&ScreenRecorder::DoInvalidateFullScreen, this)); // Add the client to the list so it can receive update stream. network_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoAddConnection, connection)); + FROM_HERE, base::Bind(&ScreenRecorder::DoAddConnection, + this, connection)); } void ScreenRecorder::RemoveConnection( scoped_refptr<ConnectionToClient> connection) { network_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoRemoveClient, connection)); + FROM_HERE, base::Bind(&ScreenRecorder::DoRemoveClient, this, connection)); } void ScreenRecorder::RemoveAllConnections() { network_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoRemoveAllClients)); + FROM_HERE, base::Bind(&ScreenRecorder::DoRemoveAllClients, this)); } void ScreenRecorder::UpdateSequenceNumber(int64 sequence_number) { // Sequence number is used and written only on the capture thread. if (MessageLoop::current() != capture_loop_) { capture_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::UpdateSequenceNumber, - sequence_number)); + FROM_HERE, base::Bind(&ScreenRecorder::UpdateSequenceNumber, + this, sequence_number)); return; } @@ -183,7 +179,7 @@ void ScreenRecorder::DoCapture() { // And finally perform one capture. capture_start_time_ = base::Time::Now(); capturer()->CaptureInvalidRegion( - NewCallback(this, &ScreenRecorder::CaptureDoneCallback)); + base::Bind(&ScreenRecorder::CaptureDoneCallback, this)); } void ScreenRecorder::CaptureDoneCallback( @@ -209,8 +205,7 @@ void ScreenRecorder::CaptureDoneCallback( } encode_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoEncode, capture_data)); + FROM_HERE, base::Bind(&ScreenRecorder::DoEncode, this, capture_data)); } void ScreenRecorder::DoFinishOneRecording() { @@ -273,8 +268,7 @@ void ScreenRecorder::FrameSentCallback(VideoPacket* packet) { return; capture_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, - &ScreenRecorder::DoFinishOneRecording)); + FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this)); } void ScreenRecorder::DoAddConnection( @@ -314,9 +308,8 @@ void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) { network_stopped_ = true; encode_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoStopOnEncodeThread, - done_task)); + FROM_HERE, base::Bind(&ScreenRecorder::DoStopOnEncodeThread, + this, done_task)); } // Encoder thread -------------------------------------------------------------- @@ -331,17 +324,15 @@ void ScreenRecorder::DoEncode( VideoPacket* packet = new VideoPacket(); packet->set_flags(VideoPacket::LAST_PARTITION); network_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, - &ScreenRecorder::DoSendVideoPacket, - packet)); + FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, + this, packet)); return; } encode_start_time_ = base::Time::Now(); encoder()->Encode( capture_data, false, - NewCallback(this, &ScreenRecorder::EncodedDataAvailableCallback)); + base::Bind(&ScreenRecorder::EncodedDataAvailableCallback, this)); } void ScreenRecorder::DoStopOnEncodeThread(const base::Closure& done_task) { @@ -371,8 +362,7 @@ void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) { } network_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); + FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, packet)); } } // namespace remoting diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc index 3a20283..51996dce 100644 --- a/remoting/host/screen_recorder_unittest.cc +++ b/remoting/host/screen_recorder_unittest.cc @@ -25,7 +25,6 @@ using ::testing::DeleteArg; using ::testing::DoAll; using ::testing::InSequence; using ::testing::InvokeWithoutArgs; -using ::testing::NotNull; using ::testing::Return; using ::testing::SaveArg; @@ -36,15 +35,13 @@ namespace { ACTION_P2(RunCallback, region, data) { SkRegion& dirty_region = data->mutable_dirty_region(); dirty_region.op(region, SkRegion::kUnion_Op); - arg0->Run(data); - delete arg0; + arg0.Run(data); } ACTION(FinishEncode) { scoped_ptr<VideoPacket> packet(new VideoPacket()); packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION); - arg2->Run(packet.release()); - delete arg2; + arg2.Run(packet.release()); } ACTION(FinishSend) { @@ -119,11 +116,11 @@ TEST_F(ScreenRecorderTest, StartAndStop) { EXPECT_CALL(capturer_, InvalidateFullScreen()); // First the capturer is called. - EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) + EXPECT_CALL(capturer_, CaptureInvalidRegion(_)) .WillRepeatedly(RunCallback(update_region, data)); // Expect the encoder be called. - EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) + EXPECT_CALL(*encoder_, Encode(data, false, _)) .WillRepeatedly(FinishEncode()); MockVideoStub video_stub; diff --git a/remoting/protocol/buffered_socket_writer.cc b/remoting/protocol/buffered_socket_writer.cc index ce8dd87..2edba0b 100644 --- a/remoting/protocol/buffered_socket_writer.cc +++ b/remoting/protocol/buffered_socket_writer.cc @@ -129,7 +129,7 @@ void BufferedSocketWriterBase::OnWritten(int result) { // Schedule next write. message_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &BufferedSocketWriterBase::DoWrite)); + FROM_HERE, base::Bind(&BufferedSocketWriterBase::DoWrite, this)); } void BufferedSocketWriterBase::HandleError(int result) { diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index 4f8a46b..9c92856 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -58,8 +58,7 @@ void ConnectionToClient::Disconnect() { // This method can be called from main thread so perform threading switching. if (!message_loop_->BelongsToCurrentThread()) { message_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ConnectionToClient::Disconnect)); + FROM_HERE, base::Bind(&ConnectionToClient::Disconnect, this)); return; } diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index 7dcfc4e..c7cc0d0 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -178,6 +178,4 @@ class ConnectionToHost : public SignalStrategy::StatusObserver, } // namespace protocol } // namespace remoting -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::ConnectionToHost); - #endif // REMOTING_PROTOCOL_CONNECTION_TO_HOST_H_ diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc index ef5eb78..f96f038 100644 --- a/remoting/protocol/jingle_session_unittest.cc +++ b/remoting/protocol/jingle_session_unittest.cc @@ -317,7 +317,7 @@ class ChannelTesterBase : public base::RefCountedThreadSafe<ChannelTesterBase> { void Start() { MessageLoop::current()->PostTask( - FROM_HERE, NewRunnableMethod(this, &ChannelTesterBase::DoStart)); + FROM_HERE, base::Bind(&ChannelTesterBase::DoStart, this)); } bool WaitFinished() { @@ -607,7 +607,7 @@ class UDPChannelTester : public ChannelTesterBase { EXPECT_EQ(kMessageSize, result); packets_sent_++; MessageLoop::current()->PostDelayedTask( - FROM_HERE, NewRunnableMethod(this, &UDPChannelTester::DoWrite), + FROM_HERE, base::Bind(&UDPChannelTester::DoWrite, this), kUdpWriteDelayMs); } } diff --git a/remoting/protocol/protocol_test_client.cc b/remoting/protocol/protocol_test_client.cc index 49fd2bc..aa35ba5 100644 --- a/remoting/protocol/protocol_test_client.cc +++ b/remoting/protocol/protocol_test_client.cc @@ -129,8 +129,8 @@ void ProtocolTestConnection::Write(const std::string& str) { scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(str.length())); memcpy(buf->data(), str.c_str(), str.length()); message_loop_->PostTask( - FROM_HERE, NewRunnableMethod( - this, &ProtocolTestConnection::DoWrite, buf, str.length())); + FROM_HERE, base::Bind(&ProtocolTestConnection::DoWrite, + this, buf, str.length())); } void ProtocolTestConnection::DoWrite( @@ -156,8 +156,7 @@ void ProtocolTestConnection::DoWrite( void ProtocolTestConnection::Read() { message_loop_->PostTask( - FROM_HERE, NewRunnableMethod( - this, &ProtocolTestConnection::DoRead)); + FROM_HERE, base::Bind(&ProtocolTestConnection::DoRead, this)); } void ProtocolTestConnection::DoRead() { diff --git a/remoting/protocol/util.cc b/remoting/protocol/util.cc index 9dfa016..080fcc3 100644 --- a/remoting/protocol/util.cc +++ b/remoting/protocol/util.cc @@ -35,9 +35,5 @@ scoped_refptr<net::IOBufferWithSize> SerializeAndFrameMessage( return buffer; } -Task* NewDeleteMessageTask(google::protobuf::MessageLite* message) { - return NewRunnableFunction(&DeleteMessage, message); -} - } // namespace protocol } // namespace remoting diff --git a/remoting/protocol/util.h b/remoting/protocol/util.h index 53e1f67..802e65c 100644 --- a/remoting/protocol/util.h +++ b/remoting/protocol/util.h @@ -23,9 +23,6 @@ namespace protocol { scoped_refptr<net::IOBufferWithSize> SerializeAndFrameMessage( const google::protobuf::MessageLite& msg); -// Create a runnable task that deletes a message. -Task* NewDeleteMessageTask(google::protobuf::MessageLite* message); - } // namespace protocol } // namespace remoting |