summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 02:07:41 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 02:07:41 +0000
commit1e1cb3bc787a85e1791f737f831d00ee08db364d (patch)
treeab228ff464b8bd78aee795e58262bd6c11e5f3dc /remoting/base
parentbe4565bce9bb1a5b3f5477cc27e20da6ddcc1de7 (diff)
downloadchromium_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
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/base_mock_objects.h2
-rw-r--r--remoting/base/codec_test.cc12
-rw-r--r--remoting/base/compound_buffer_unittest.cc76
-rw-r--r--remoting/base/decoder.h1
-rw-r--r--remoting/base/decoder_row_based.cc1
-rw-r--r--remoting/base/decoder_vp8.cc1
-rw-r--r--remoting/base/encoder.h6
-rw-r--r--remoting/base/encoder_row_based.cc13
-rw-r--r--remoting/base/encoder_row_based.h9
-rw-r--r--remoting/base/encoder_vp8.cc5
-rw-r--r--remoting/base/encoder_vp8.h7
-rw-r--r--remoting/base/encoder_vp8_unittest.cc7
12 files changed, 69 insertions, 71 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) {