diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 16:57:02 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 16:57:02 +0000 |
commit | a9590c25660d4be4caad2add5e16e08003e5ed39 (patch) | |
tree | 10b2dd0b18e9122aa0eb86d80e14c8e3efafd73e /webkit/glue/media | |
parent | bac2d4979f97026ed1344cd2dc9b208f58886537 (diff) | |
download | chromium_src-a9590c25660d4be4caad2add5e16e08003e5ed39.zip chromium_src-a9590c25660d4be4caad2add5e16e08003e5ed39.tar.gz chromium_src-a9590c25660d4be4caad2add5e16e08003e5ed39.tar.bz2 |
PipelineError is dead. Long live PipelineStatus!
PipelineError was a poor naming choice because most of the time variables of
that type held the value PIPELINE_OK meaning there was in fact no error.
Replaced the idiom of [0-ary callback + GetError()] with
[1-ary callback taking PipelineStatus argument] which makes the Pipeline API
cleaner and less error-prone. Before, consumers of the API had to make sure to
call GetError() at the top of each callback, or risk missing state transitions
in the pipeline. Now each callback gets an explicit parameter holding the
pipeline status at the moment the callback was invoked so failing to handle
error conditions should be more apparent in the code.
BUG=none
TEST=media_unittests + trybots: {mac,linux,win}{_layout,}, linux_rel, linux_clang (all pass or fail with unrelated errors)
Review URL: http://codereview.chromium.org/6686061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r-- | webkit/glue/media/buffered_data_source.cc | 5 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source.h | 2 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source_unittest.cc | 6 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source.cc | 6 | ||||
-rw-r--r-- | webkit/glue/media/web_data_source_factory.cc | 9 |
5 files changed, 15 insertions, 13 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 135c49e..2622255 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -412,14 +412,15 @@ void BufferedDataSource::DoneRead_Locked(int error) { read_buffer_ = 0; } -void BufferedDataSource::DoneInitialization_Locked(media::PipelineError error) { +void BufferedDataSource::DoneInitialization_Locked( + media::PipelineStatus status) { DCHECK(MessageLoop::current() == render_loop_); DCHECK(initialize_callback_.get()); lock_.AssertAcquired(); scoped_ptr<media::PipelineStatusCallback> initialize_callback( initialize_callback_.release()); - initialize_callback->Run(error); + initialize_callback->Run(status); } ///////////////////////////////////////////////////////////////////////////// diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index 9e043b0..5ab3035 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -98,7 +98,7 @@ class BufferedDataSource : public WebDataSource { void DoneRead_Locked(int error); // Calls |initialize_callback_| and reset it. - void DoneInitialization_Locked(media::PipelineError error); + void DoneInitialization_Locked(media::PipelineStatus status); // Callback method for |loader_| if URL for the resource requested is using // HTTP protocol. This method is called when response for initial request is diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc index 9763678..dd5c891 100644 --- a/webkit/glue/media/buffered_data_source_unittest.cc +++ b/webkit/glue/media/buffered_data_source_unittest.cc @@ -168,7 +168,7 @@ class BufferedDataSourceTest : public testing::Test { .WillByDefault(Return(partial_response)); ON_CALL(*loader_, url()) .WillByDefault(ReturnRef(gurl_)); - media::PipelineError expected_init_error = media::PIPELINE_OK; + media::PipelineStatus expected_init_status = media::PIPELINE_OK; if (initialized_ok) { // Expected loaded or not. EXPECT_CALL(host_, SetLoaded(loaded)); @@ -184,13 +184,13 @@ class BufferedDataSourceTest : public testing::Test { EXPECT_CALL(host_, SetStreaming(true)); } } else { - expected_init_error = media::PIPELINE_ERROR_NETWORK; + expected_init_status = media::PIPELINE_ERROR_NETWORK; EXPECT_CALL(*loader_, Stop()); } // Actual initialization of the data source. data_source_->Initialize(url, - media::NewExpectedStatusCallback(expected_init_error)); + media::NewExpectedStatusCallback(expected_init_status)); message_loop_->RunAllPending(); if (initialized_ok) { diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index ca258d4..186f6d7 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -321,12 +321,12 @@ void SimpleDataSource::CancelTask() { void SimpleDataSource::DoneInitialization_Locked(bool success) { lock_.AssertAcquired(); - media::PipelineError error = media::PIPELINE_ERROR_NETWORK; + media::PipelineStatus status = media::PIPELINE_ERROR_NETWORK; if (success) { state_ = INITIALIZED; UpdateHostState(); - error = media::PIPELINE_OK; + status = media::PIPELINE_OK; } else { state_ = UNINITIALIZED; url_loader_.reset(); @@ -334,7 +334,7 @@ void SimpleDataSource::DoneInitialization_Locked(bool success) { scoped_ptr<media::PipelineStatusCallback> initialize_callback( initialize_callback_.release()); - initialize_callback->Run(error); + initialize_callback->Run(status); } void SimpleDataSource::UpdateHostState() { diff --git a/webkit/glue/media/web_data_source_factory.cc b/webkit/glue/media/web_data_source_factory.cc index f9036c7..d98e2da 100644 --- a/webkit/glue/media/web_data_source_factory.cc +++ b/webkit/glue/media/web_data_source_factory.cc @@ -21,7 +21,7 @@ class WebDataSourceFactory::BuildRequest virtual void DoStart(); private: - void InitDone(media::PipelineError error); + void InitDone(media::PipelineStatus status); scoped_refptr<WebDataSource> data_source_; WebDataSourceBuildObserverHack* build_observer_; @@ -84,17 +84,18 @@ void WebDataSourceFactory::BuildRequest::DoStart() { data_source_->Initialize(url(), NewCallback(this, &BuildRequest::InitDone)); } -void WebDataSourceFactory::BuildRequest::InitDone(media::PipelineError error) { +void WebDataSourceFactory::BuildRequest::InitDone( + media::PipelineStatus status) { scoped_refptr<WebDataSource> data_source; - data_source = (error == media::PIPELINE_OK) ? data_source_ : NULL; + data_source = (status == media::PIPELINE_OK) ? data_source_ : NULL; data_source_ = NULL; if (build_observer_ && data_source.get()) { build_observer_->Run(data_source.get()); } - RequestComplete(error, data_source); + RequestComplete(status, data_source); // Don't do anything after this line. This object is deleted by // RequestComplete(). } |