summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 01:24:26 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 01:24:26 +0000
commit76897a743f6c27643e71acadb918eab041dccc34 (patch)
tree9cd1d35abb9aae317d1c1563898ecf83b67d9212 /webkit
parent464c6802874128cf75a6f3af266a4301f049510a (diff)
downloadchromium_src-76897a743f6c27643e71acadb918eab041dccc34.zip
chromium_src-76897a743f6c27643e71acadb918eab041dccc34.tar.gz
chromium_src-76897a743f6c27643e71acadb918eab041dccc34.tar.bz2
Clean up callback variable names and comments inside BufferedDataSource/BufferedResourceLoader.
Review URL: http://codereview.chromium.org/9383020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/media/buffered_data_source.cc47
-rw-r--r--webkit/media/buffered_data_source.h12
-rw-r--r--webkit/media/buffered_resource_loader.cc68
-rw-r--r--webkit/media/buffered_resource_loader.h32
4 files changed, 80 insertions, 79 deletions
diff --git a/webkit/media/buffered_data_source.cc b/webkit/media/buffered_data_source.cc
index 8537073..e20b941 100644
--- a/webkit/media/buffered_data_source.cc
+++ b/webkit/media/buffered_data_source.cc
@@ -76,20 +76,21 @@ void BufferedDataSource::set_host(media::DataSourceHost* host) {
}
}
-void BufferedDataSource::Initialize(const GURL& url,
- const media::PipelineStatusCB& callback) {
+void BufferedDataSource::Initialize(
+ const GURL& url,
+ const media::PipelineStatusCB& initialize_cb) {
DCHECK(MessageLoop::current() == render_loop_);
- DCHECK(!callback.is_null());
+ DCHECK(!initialize_cb.is_null());
DCHECK(!loader_.get());
url_ = url;
// This data source doesn't support data:// protocol so reject it.
if (url_.SchemeIs(kDataScheme)) {
- callback.Run(media::DATASOURCE_ERROR_URL_NOT_SUPPORTED);
+ initialize_cb.Run(media::DATASOURCE_ERROR_URL_NOT_SUPPORTED);
return;
}
- initialize_cb_ = callback;
+ initialize_cb_ = initialize_cb;
if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) {
// Do an unbounded range request starting at the beginning. If the server
@@ -115,13 +116,13 @@ void BufferedDataSource::Initialize(const GURL& url,
/////////////////////////////////////////////////////////////////////////////
// media::Filter implementation.
-void BufferedDataSource::Stop(const base::Closure& callback) {
+void BufferedDataSource::Stop(const base::Closure& closure) {
{
base::AutoLock auto_lock(lock_);
stop_signal_received_ = true;
}
- if (!callback.is_null())
- callback.Run();
+ if (!closure.is_null())
+ closure.Run();
render_loop_->PostTask(FROM_HERE,
base::Bind(&BufferedDataSource::CleanupTask, this));
@@ -146,20 +147,20 @@ void BufferedDataSource::SetBitrate(int bitrate) {
// media::DataSource implementation.
void BufferedDataSource::Read(
int64 position, size_t size, uint8* data,
- const media::DataSource::ReadCallback& read_callback) {
- VLOG(1) << "Read: " << position << " offset, " << size << " bytes";
- DCHECK(!read_callback.is_null());
+ const media::DataSource::ReadCallback& read_cb) {
+ DVLOG(1) << "Read: " << position << " offset, " << size << " bytes";
+ DCHECK(!read_cb.is_null());
{
base::AutoLock auto_lock(lock_);
- DCHECK(read_callback_.is_null());
+ DCHECK(read_cb_.is_null());
if (stop_signal_received_ || stopped_on_render_loop_) {
- read_callback.Run(kReadError);
+ read_cb.Run(kReadError);
return;
}
- read_callback_ = read_callback;
+ read_cb_ = read_cb;
}
render_loop_->PostTask(FROM_HERE, base::Bind(
@@ -204,7 +205,7 @@ void BufferedDataSource::ReadTask(
if (stopped_on_render_loop_)
return;
- DCHECK(!read_callback_.is_null());
+ DCHECK(!read_cb_.is_null());
}
// Saves the read parameters.
@@ -228,10 +229,10 @@ void BufferedDataSource::CleanupTask() {
// Signal that stop task has finished execution.
// NOTE: it's vital that this be set under lock, as that's how Read() tests
- // before registering a new |read_callback_| (which is cleared below).
+ // before registering a new |read_cb_| (which is cleared below).
stopped_on_render_loop_ = true;
- if (!read_callback_.is_null())
+ if (!read_cb_.is_null())
DoneRead_Locked(net::ERR_FAILED);
}
@@ -253,7 +254,7 @@ void BufferedDataSource::RestartLoadingTask() {
{
// If there's no outstanding read then return early.
base::AutoLock auto_lock(lock_);
- if (read_callback_.is_null())
+ if (read_cb_.is_null())
return;
}
@@ -333,19 +334,19 @@ void BufferedDataSource::ReadInternal() {
// Method to report the results of the current read request. Also reset all
// the read parameters.
void BufferedDataSource::DoneRead_Locked(int error) {
- VLOG(1) << "DoneRead: " << error << " bytes";
+ DVLOG(1) << "DoneRead: " << error << " bytes";
DCHECK(MessageLoop::current() == render_loop_);
- DCHECK(!read_callback_.is_null());
+ DCHECK(!read_cb_.is_null());
lock_.AssertAcquired();
if (error >= 0) {
- read_callback_.Run(static_cast<size_t>(error));
+ read_cb_.Run(static_cast<size_t>(error));
} else {
- read_callback_.Run(kReadError);
+ read_cb_.Run(kReadError);
}
- read_callback_.Reset();
+ read_cb_.Reset();
read_position_ = 0;
read_size_ = 0;
read_buffer_ = 0;
diff --git a/webkit/media/buffered_data_source.h b/webkit/media/buffered_data_source.h
index 079edd0..58e1ea6 100644
--- a/webkit/media/buffered_data_source.h
+++ b/webkit/media/buffered_data_source.h
@@ -33,22 +33,22 @@ class BufferedDataSource : public WebDataSource {
// media::DataSource implementation.
// Called from demuxer thread.
virtual void set_host(media::DataSourceHost* host) OVERRIDE;
- virtual void Stop(const base::Closure& callback) OVERRIDE;
+ virtual void Stop(const base::Closure& closure) OVERRIDE;
virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
virtual void Read(
int64 position,
size_t size,
uint8* data,
- const media::DataSource::ReadCallback& read_callback) OVERRIDE;
+ const media::DataSource::ReadCallback& read_cb) OVERRIDE;
virtual bool GetSize(int64* size_out) OVERRIDE;
virtual bool IsStreaming() OVERRIDE;
virtual void SetPreload(media::Preload preload) OVERRIDE;
virtual void SetBitrate(int bitrate) OVERRIDE;
// webkit_glue::WebDataSource implementation.
- virtual void Initialize(const GURL& url,
- const media::PipelineStatusCB& callback) OVERRIDE;
+ virtual void Initialize(
+ const GURL& url, const media::PipelineStatusCB& initialize_cb) OVERRIDE;
virtual bool HasSingleOrigin() OVERRIDE;
virtual void Abort() OVERRIDE;
@@ -92,7 +92,7 @@ class BufferedDataSource : public WebDataSource {
// the render thread.
void ReadInternal();
- // Calls |read_callback_| and reset all read parameters.
+ // Calls |read_cb_| and reset all read parameters.
void DoneRead_Locked(int error);
// Calls |initialize_cb_| and reset it.
@@ -151,7 +151,7 @@ class BufferedDataSource : public WebDataSource {
media::PipelineStatusCB initialize_cb_;
// Read parameters received from the Read() method call.
- media::DataSource::ReadCallback read_callback_;
+ media::DataSource::ReadCallback read_cb_;
int64 read_position_;
int read_size_;
uint8* read_buffer_;
diff --git a/webkit/media/buffered_resource_loader.cc b/webkit/media/buffered_resource_loader.cc
index f672127..53a236e 100644
--- a/webkit/media/buffered_resource_loader.cc
+++ b/webkit/media/buffered_resource_loader.cc
@@ -131,18 +131,18 @@ BufferedResourceLoader::BufferedResourceLoader(
BufferedResourceLoader::~BufferedResourceLoader() {}
void BufferedResourceLoader::Start(
- const net::CompletionCallback& start_callback,
- const base::Closure& event_callback,
+ const net::CompletionCallback& start_cb,
+ const base::Closure& event_cb,
WebFrame* frame) {
// Make sure we have not started.
- DCHECK(start_callback_.is_null());
- DCHECK(event_callback_.is_null());
- DCHECK(!start_callback.is_null());
- DCHECK(!event_callback.is_null());
+ DCHECK(start_cb_.is_null());
+ DCHECK(event_cb_.is_null());
+ DCHECK(!start_cb.is_null());
+ DCHECK(!event_cb.is_null());
CHECK(frame);
- start_callback_ = start_callback;
- event_callback_ = event_callback;
+ start_cb_ = start_cb;
+ event_cb_ = event_cb;
if (first_byte_position_ != kPositionNotSpecified) {
// TODO(hclam): server may not support range request so |offset_| may not
@@ -187,9 +187,9 @@ void BufferedResourceLoader::Start(
void BufferedResourceLoader::Stop() {
// Reset callbacks.
- start_callback_.Reset();
- event_callback_.Reset();
- read_callback_.Reset();
+ start_cb_.Reset();
+ event_cb_.Reset();
+ read_cb_.Reset();
// Use the internal buffer to signal that we have been stopped.
// TODO(hclam): Not so pretty to do this.
@@ -207,16 +207,16 @@ void BufferedResourceLoader::Read(
int64 position,
int read_size,
uint8* buffer,
- const net::CompletionCallback& read_callback) {
- DCHECK(start_callback_.is_null());
- DCHECK(read_callback_.is_null());
- DCHECK(!read_callback.is_null());
+ const net::CompletionCallback& read_cb) {
+ DCHECK(start_cb_.is_null());
+ DCHECK(read_cb_.is_null());
+ DCHECK(!read_cb.is_null());
DCHECK(buffer_.get());
DCHECK(buffer);
DCHECK_GT(read_size, 0);
// Save the parameter of reading.
- read_callback_ = read_callback;
+ read_cb_ = read_cb;
read_position_ = position;
read_size_ = read_size;
read_buffer_ = buffer;
@@ -334,9 +334,9 @@ void BufferedResourceLoader::willSendRequest(
WebURLRequest& newRequest,
const WebURLResponse& redirectResponse) {
- // The load may have been stopped and |start_callback| is destroyed.
+ // The load may have been stopped and |start_cb| is destroyed.
// In this case we shouldn't do anything.
- if (start_callback_.is_null()) {
+ if (start_cb_.is_null()) {
// Set the url in the request to an invalid value (empty url).
newRequest.setURL(WebKit::WebURL());
return;
@@ -362,9 +362,9 @@ void BufferedResourceLoader::didReceiveResponse(
DVLOG(1) << "didReceiveResponse: " << response.httpStatusCode();
DCHECK(active_loader_.get());
- // The loader may have been stopped and |start_callback| is destroyed.
+ // The loader may have been stopped and |start_cb| is destroyed.
// In this case we shouldn't do anything.
- if (start_callback_.is_null())
+ if (start_cb_.is_null())
return;
bool partial_response = false;
@@ -485,8 +485,8 @@ void BufferedResourceLoader::didFinishLoading(
}
// If there is a start callback, run it.
- if (!start_callback_.is_null()) {
- DCHECK(read_callback_.is_null())
+ if (!start_cb_.is_null()) {
+ DCHECK(read_cb_.is_null())
<< "Shouldn't have a read callback during start";
DoneStart(net::OK);
return;
@@ -523,8 +523,8 @@ void BufferedResourceLoader::didFail(
NotifyNetworkEvent();
// Don't leave start callbacks hanging around.
- if (!start_callback_.is_null()) {
- DCHECK(read_callback_.is_null())
+ if (!start_cb_.is_null()) {
+ DCHECK(read_cb_.is_null())
<< "Shouldn't have a read callback during start";
DoneStart(net::ERR_FAILED);
return;
@@ -608,7 +608,7 @@ bool BufferedResourceLoader::ShouldEnableDefer() const {
// Defer if nothing is being requested.
case kReadThenDefer:
- return read_callback_.is_null();
+ return read_cb_.is_null();
// Defer if we've reached the max capacity of the threshold.
case kThresholdDefer:
@@ -631,7 +631,7 @@ bool BufferedResourceLoader::ShouldDisableDefer() const {
// 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_.is_null() &&
+ return !read_cb_.is_null() &&
last_offset_ > static_cast<int>(buffer_->forward_bytes());
// We have less than half the capacity of our threshold, so
@@ -760,20 +760,20 @@ void BufferedResourceLoader::DoneRead(int error) {
last_offset_ = 0;
Log();
- net::CompletionCallback read_callback;
- std::swap(read_callback, read_callback_);
- read_callback.Run(error);
+ net::CompletionCallback read_cb;
+ std::swap(read_cb, read_cb_);
+ read_cb.Run(error);
}
void BufferedResourceLoader::DoneStart(int error) {
- net::CompletionCallback start_callback;
- std::swap(start_callback, start_callback_);
- start_callback.Run(error);
+ net::CompletionCallback start_cb;
+ std::swap(start_cb, start_cb_);
+ start_cb.Run(error);
}
void BufferedResourceLoader::NotifyNetworkEvent() {
- if (!event_callback_.is_null())
- event_callback_.Run();
+ if (!event_cb_.is_null())
+ event_cb_.Run();
}
bool BufferedResourceLoader::IsRangeRequest() const {
diff --git a/webkit/media/buffered_resource_loader.h b/webkit/media/buffered_resource_loader.h
index 64db97d..bde91ad 100644
--- a/webkit/media/buffered_resource_loader.h
+++ b/webkit/media/buffered_resource_loader.h
@@ -77,10 +77,10 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient {
// An invalid response is received from the server.
// - (Anything else)
// 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(const net::CompletionCallback& callback,
- const base::Closure& event_callback,
+ // |event_cb| is called when the response is completed, data is received, the
+ // request is suspended or resumed.
+ virtual void Start(const net::CompletionCallback& start_cb,
+ const base::Closure& event_cb,
WebKit::WebFrame* frame);
// Stops everything associated with this loader, including active URL loads
@@ -179,12 +179,12 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient {
// Updates the |buffer_|'s forward and backward capacities.
void UpdateBufferWindow();
- // Returns true if we should defer resource loading, based
- // on current buffering scheme.
+ // Returns true if we should defer resource loading based on the current
+ // buffering scheme.
bool ShouldEnableDefer() const;
- // Returns true if we should enable resource loading, based
- // on current buffering scheme.
+ // Returns true if we should enable resource loading based on the current
+ // buffering scheme.
bool ShouldDisableDefer() const;
// Updates deferring behavior based on current buffering scheme.
@@ -201,8 +201,8 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient {
// Returns true if the current read request will be fulfilled in the future.
bool WillFulfillRead() const;
- // Method that does the actual read and calls the |read_callback_|, assuming
- // the request range is in |buffer_|.
+ // Method that does the actual read and calls the |read_cb_|, assuming the
+ // request range is in |buffer_|.
void ReadInternal();
// If we have made a range request, verify the response from the server.
@@ -224,10 +224,10 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient {
// Done with start. Invokes the start callback and reset it.
void DoneStart(int error);
- // Calls |event_callback_| in terms of a network event.
+ // Calls |event_cb_| in terms of a network event.
void NotifyNetworkEvent();
- bool HasPendingRead() { return !read_callback_.is_null(); }
+ bool HasPendingRead() { return !read_cb_.is_null(); }
// Helper function that returns true if a range request was specified.
bool IsRangeRequest() const;
@@ -258,18 +258,18 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient {
int64 last_byte_position_;
bool single_origin_;
- // Callback method that listens to network events.
- base::Closure event_callback_;
+ // Closure that listens to network events.
+ base::Closure event_cb_;
// Members used during request start.
- net::CompletionCallback start_callback_;
+ net::CompletionCallback start_cb_;
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.
- net::CompletionCallback read_callback_;
+ net::CompletionCallback read_cb_;
int64 read_position_;
size_t read_size_;
uint8* read_buffer_;