summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 20:34:21 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 20:34:21 +0000
commit5249afba3c44b941606b573feaca363282c1809b (patch)
tree7140ea38c09d2d3dab4d9a928121a23e4974e508 /webkit
parent35fa1543cfcaa0a3d2ca423cf028f3797914d389 (diff)
downloadchromium_src-5249afba3c44b941606b573feaca363282c1809b.zip
chromium_src-5249afba3c44b941606b573feaca363282c1809b.tar.gz
chromium_src-5249afba3c44b941606b573feaca363282c1809b.tar.bz2
Finish the base::Bind migration for webkit/media.
BUG=none TEST={content,media}_unittests,test_shell_tests,trybots Review URL: http://codereview.chromium.org/8764002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/media/buffered_data_source.cc10
-rw-r--r--webkit/media/buffered_resource_loader.cc58
-rw-r--r--webkit/media/buffered_resource_loader.h10
-rw-r--r--webkit/media/buffered_resource_loader_unittest.cc6
-rw-r--r--webkit/media/webmediaplayer_proxy.cc32
5 files changed, 59 insertions, 57 deletions
diff --git a/webkit/media/buffered_data_source.cc b/webkit/media/buffered_data_source.cc
index 2d7b8c9..0c005ab 100644
--- a/webkit/media/buffered_data_source.cc
+++ b/webkit/media/buffered_data_source.cc
@@ -225,7 +225,7 @@ void BufferedDataSource::InitializeTask() {
// responds with 200 instead of 206 we'll fall back into a streaming mode.
loader_ = CreateResourceLoader(0, kPositionNotSpecified);
loader_->Start(
- NewCallback(this, &BufferedDataSource::HttpInitialStartCallback),
+ base::Bind(&BufferedDataSource::HttpInitialStartCallback, this),
base::Bind(&BufferedDataSource::NetworkEventCallback, this),
frame_);
} else {
@@ -235,7 +235,7 @@ void BufferedDataSource::InitializeTask() {
loader_ = CreateResourceLoader(kPositionNotSpecified,
kPositionNotSpecified);
loader_->Start(
- NewCallback(this, &BufferedDataSource::NonHttpInitialStartCallback),
+ base::Bind(&BufferedDataSource::NonHttpInitialStartCallback, this),
base::Bind(&BufferedDataSource::NetworkEventCallback, this),
frame_);
}
@@ -306,7 +306,7 @@ void BufferedDataSource::RestartLoadingTask() {
loader_ = CreateResourceLoader(read_position_, kPositionNotSpecified);
loader_->Start(
- NewCallback(this, &BufferedDataSource::PartialReadStartCallback),
+ base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
base::Bind(&BufferedDataSource::NetworkEventCallback, this),
frame_);
}
@@ -374,7 +374,7 @@ void BufferedDataSource::ReadInternal() {
// Perform the actual read with BufferedResourceLoader.
loader_->Read(read_position_, read_size_, intermediate_read_buffer_.get(),
- NewCallback(this, &BufferedDataSource::ReadCallback));
+ base::Bind(&BufferedDataSource::ReadCallback, this));
}
// Method to report the results of the current read request. Also reset all
@@ -446,7 +446,7 @@ void BufferedDataSource::HttpInitialStartCallback(int error) {
loader_ = CreateResourceLoader(kPositionNotSpecified,
kPositionNotSpecified);
loader_->Start(
- NewCallback(this, &BufferedDataSource::HttpInitialStartCallback),
+ base::Bind(&BufferedDataSource::HttpInitialStartCallback, this),
base::Bind(&BufferedDataSource::NetworkEventCallback, this),
frame_);
return;
diff --git a/webkit/media/buffered_resource_loader.cc b/webkit/media/buffered_resource_loader.cc
index b571dbc..3d856f9 100644
--- a/webkit/media/buffered_resource_loader.cc
+++ b/webkit/media/buffered_resource_loader.cc
@@ -112,11 +112,9 @@ BufferedResourceLoader::BufferedResourceLoader(
first_byte_position_(first_byte_position),
last_byte_position_(last_byte_position),
single_origin_(true),
- start_callback_(NULL),
offset_(0),
content_length_(kPositionNotSpecified),
instance_size_(kPositionNotSpecified),
- read_callback_(NULL),
read_position_(0),
read_size_(0),
read_buffer_(NULL),
@@ -139,17 +137,18 @@ BufferedResourceLoader::~BufferedResourceLoader() {
url_loader_->cancel();
}
-void BufferedResourceLoader::Start(net::OldCompletionCallback* start_callback,
- const base::Closure& event_callback,
- WebFrame* frame) {
+void BufferedResourceLoader::Start(
+ const net::CompletionCallback& start_callback,
+ const base::Closure& event_callback,
+ WebFrame* frame) {
// Make sure we have not started.
- DCHECK(!start_callback_.get());
+ DCHECK(start_callback_.is_null());
DCHECK(event_callback_.is_null());
- DCHECK(start_callback);
+ DCHECK(!start_callback.is_null());
DCHECK(!event_callback.is_null());
CHECK(frame);
- start_callback_.reset(start_callback);
+ start_callback_ = start_callback;
event_callback_ = event_callback;
if (first_byte_position_ != kPositionNotSpecified) {
@@ -195,9 +194,9 @@ void BufferedResourceLoader::Start(net::OldCompletionCallback* start_callback,
void BufferedResourceLoader::Stop() {
// Reset callbacks.
- start_callback_.reset();
+ start_callback_.Reset();
event_callback_.Reset();
- read_callback_.reset();
+ read_callback_.Reset();
// Use the internal buffer to signal that we have been stopped.
// TODO(hclam): Not so pretty to do this.
@@ -219,18 +218,19 @@ void BufferedResourceLoader::Stop() {
}
}
-void BufferedResourceLoader::Read(int64 position,
- int read_size,
- uint8* buffer,
- net::OldCompletionCallback* read_callback) {
- DCHECK(!read_callback_.get());
+void BufferedResourceLoader::Read(
+ int64 position,
+ int read_size,
+ uint8* buffer,
+ const net::CompletionCallback& read_callback) {
+ DCHECK(read_callback_.is_null());
DCHECK(buffer_.get());
- DCHECK(read_callback);
+ DCHECK(!read_callback.is_null());
DCHECK(buffer);
DCHECK_GT(read_size, 0);
// Save the parameter of reading.
- read_callback_.reset(read_callback);
+ read_callback_ = read_callback;
read_position_ = position;
read_size_ = read_size;
read_buffer_ = buffer;
@@ -347,7 +347,7 @@ void BufferedResourceLoader::willSendRequest(
// The load may have been stopped and |start_callback| is destroyed.
// In this case we shouldn't do anything.
- if (!start_callback_.get()) {
+ if (start_callback_.is_null()) {
// Set the url in the request to an invalid value (empty url).
newRequest.setURL(WebKit::WebURL());
return;
@@ -374,7 +374,7 @@ void BufferedResourceLoader::didReceiveResponse(
// The loader may have been stopped and |start_callback| is destroyed.
// In this case we shouldn't do anything.
- if (!start_callback_.get())
+ if (start_callback_.is_null())
return;
bool partial_response = false;
@@ -494,8 +494,8 @@ void BufferedResourceLoader::didFinishLoading(
instance_size_ = offset_ + buffer_->forward_bytes();
}
- // If there is a start callback, calls it.
- if (start_callback_.get()) {
+ // If there is a start callback, run it.
+ if (!start_callback_.is_null()) {
DoneStart(net::OK);
}
@@ -530,8 +530,8 @@ void BufferedResourceLoader::didFail(
DCHECK(!completed_);
completed_ = true;
- // If there is a start callback, calls it.
- if (start_callback_.get()) {
+ // If there is a start callback, run it.
+ if (!start_callback_.is_null()) {
DoneStart(error.reason);
}
@@ -623,7 +623,7 @@ bool BufferedResourceLoader::ShouldEnableDefer() {
// Defer if nothing is being requested.
case kReadThenDefer:
- return !read_callback_.get();
+ return read_callback_.is_null();
// Defer if we've reached the max capacity of the threshold.
case kThresholdDefer:
@@ -646,7 +646,7 @@ bool BufferedResourceLoader::ShouldDisableDefer() {
// We have an outstanding read request, and we have not buffered enough
// yet to fulfill the request; disable defer to get more data.
case kReadThenDefer:
- return read_callback_.get() &&
+ return !read_callback_.is_null() &&
last_offset_ > static_cast<int>(buffer_->forward_bytes());
// We have less than half the capacity of our threshold, so
@@ -764,8 +764,8 @@ std::string BufferedResourceLoader::GenerateHeaders(
}
void BufferedResourceLoader::DoneRead(int error) {
- read_callback_->RunWithParams(Tuple1<int>(error));
- read_callback_.reset();
+ read_callback_.Run(error);
+ read_callback_.Reset();
if (buffer_.get() && saved_forward_capacity_) {
buffer_->set_forward_capacity(saved_forward_capacity_);
saved_forward_capacity_ = 0;
@@ -779,8 +779,8 @@ void BufferedResourceLoader::DoneRead(int error) {
}
void BufferedResourceLoader::DoneStart(int error) {
- start_callback_->RunWithParams(Tuple1<int>(error));
- start_callback_.reset();
+ start_callback_.Run(error);
+ start_callback_.Reset();
}
void BufferedResourceLoader::NotifyNetworkEvent() {
diff --git a/webkit/media/buffered_resource_loader.h b/webkit/media/buffered_resource_loader.h
index 4399d00..4141c79 100644
--- a/webkit/media/buffered_resource_loader.h
+++ b/webkit/media/buffered_resource_loader.h
@@ -79,7 +79,7 @@ class BufferedResourceLoader
// An error code that indicates the request has failed.
// |event_callback| is called when the response is completed, data is
// received, the request is suspended or resumed.
- virtual void Start(net::OldCompletionCallback* callback,
+ virtual void Start(const net::CompletionCallback& callback,
const base::Closure& event_callback,
WebKit::WebFrame* frame);
@@ -98,7 +98,7 @@ class BufferedResourceLoader
// - net::ERR_CACHE_MISS
// The read was made too far away from the current buffered position.
virtual void Read(int64 position, int read_size,
- uint8* buffer, net::OldCompletionCallback* callback);
+ uint8* buffer, const net::CompletionCallback& callback);
// Returns the position of the last byte buffered. Returns
// |kPositionNotSpecified| if such value is not available.
@@ -227,7 +227,7 @@ class BufferedResourceLoader
// Calls |event_callback_| in terms of a network event.
void NotifyNetworkEvent();
- bool HasPendingRead() { return read_callback_.get() != NULL; }
+ bool HasPendingRead() { return !read_callback_.is_null(); }
// Helper function that returns true if a range request was specified.
bool IsRangeRequest() const;
@@ -268,14 +268,14 @@ class BufferedResourceLoader
base::Closure event_callback_;
// Members used during request start.
- scoped_ptr<net::OldCompletionCallback> start_callback_;
+ net::CompletionCallback start_callback_;
int64 offset_;
int64 content_length_;
int64 instance_size_;
// Members used during a read operation. They should be reset after each
// read has completed or failed.
- scoped_ptr<net::OldCompletionCallback> read_callback_;
+ net::CompletionCallback read_callback_;
int64 read_position_;
size_t read_size_;
uint8* read_buffer_;
diff --git a/webkit/media/buffered_resource_loader_unittest.cc b/webkit/media/buffered_resource_loader_unittest.cc
index e434dff..b68b3da 100644
--- a/webkit/media/buffered_resource_loader_unittest.cc
+++ b/webkit/media/buffered_resource_loader_unittest.cc
@@ -108,7 +108,8 @@ class BufferedResourceLoaderTest : public testing::Test {
EXPECT_CALL(*url_loader_, loadAsynchronously(Truly(CorrectAcceptEncoding),
loader_.get()));
loader_->Start(
- NewCallback(this, &BufferedResourceLoaderTest::StartCallback),
+ base::Bind(&BufferedResourceLoaderTest::StartCallback,
+ base::Unretained(this)),
base::Bind(&BufferedResourceLoaderTest::NetworkCallback,
base::Unretained(this)),
view_->mainFrame());
@@ -238,7 +239,8 @@ class BufferedResourceLoaderTest : public testing::Test {
// Helper method to read from |loader_|.
void ReadLoader(int64 position, int size, uint8* buffer) {
loader_->Read(position, size, buffer,
- NewCallback(this, &BufferedResourceLoaderTest::ReadCallback));
+ base::Bind(&BufferedResourceLoaderTest::ReadCallback,
+ base::Unretained(this)));
}
// Verifies that data in buffer[0...size] is equal to data_[pos...pos+size].
diff --git a/webkit/media/webmediaplayer_proxy.cc b/webkit/media/webmediaplayer_proxy.cc
index 6d4222c..4c09b32 100644
--- a/webkit/media/webmediaplayer_proxy.cc
+++ b/webkit/media/webmediaplayer_proxy.cc
@@ -40,8 +40,8 @@ void WebMediaPlayerProxy::Repaint() {
if (outstanding_repaints_ < kMaxOutstandingRepaints) {
++outstanding_repaints_;
- render_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &WebMediaPlayerProxy::RepaintTask));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::RepaintTask, this));
}
}
@@ -99,29 +99,29 @@ void WebMediaPlayerProxy::Detach() {
void WebMediaPlayerProxy::PipelineInitializationCallback(
PipelineStatus status) {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::PipelineInitializationTask, status));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::PipelineInitializationTask, this, status));
}
void WebMediaPlayerProxy::PipelineSeekCallback(PipelineStatus status) {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::PipelineSeekTask, status));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::PipelineSeekTask, this, status));
}
void WebMediaPlayerProxy::PipelineEndedCallback(PipelineStatus status) {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::PipelineEndedTask, status));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::PipelineEndedTask, this, status));
}
void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) {
DCHECK_NE(error, media::PIPELINE_OK);
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::PipelineErrorTask, error));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::PipelineErrorTask, this, error));
}
void WebMediaPlayerProxy::NetworkEventCallback(NetworkEvent type) {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::NetworkEventTask, type));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::NetworkEventTask, this, type));
}
void WebMediaPlayerProxy::AddDataSource(WebDataSource* data_source) {
@@ -184,14 +184,14 @@ void WebMediaPlayerProxy::PutCurrentFrame(
}
void WebMediaPlayerProxy::DemuxerOpened(media::ChunkDemuxer* demuxer) {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::DemuxerOpenedTask,
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::DemuxerOpenedTask, this,
scoped_refptr<media::ChunkDemuxer>(demuxer)));
}
void WebMediaPlayerProxy::DemuxerClosed() {
- render_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &WebMediaPlayerProxy::DemuxerClosedTask));
+ render_loop_->PostTask(FROM_HERE, base::Bind(
+ &WebMediaPlayerProxy::DemuxerClosedTask, this));
}
void WebMediaPlayerProxy::DemuxerFlush() {