diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 04:47:31 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 04:47:31 +0000 |
commit | f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352 (patch) | |
tree | 5107ccd0d038153d126a1d3e842dd042944f31f3 /media/base | |
parent | c2e45bf3a3207e2072c78804b012309de511275a (diff) | |
download | chromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.zip chromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.tar.gz chromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.tar.bz2 |
Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}.
Pass() was announced in
https://groups.google.com/a/chromium.org/d/topic/chromium-dev/RTd7rNxHjqk/discussion
This CL replaces comments about ownership transfer (in all files whose paths
contain media/) with the explicit passing of the appropriate scoper.
The exceptions that are not touched by this CL:
- scoped_refptr<> doesn't support Pass() and so is untouched.
- media/audio code defines its own callback machinery, mimicking the old-style
callbacks (pass by pointer, explicit deletes). I think that whole pile needs
to be replaced with new-style (Bind) callbacks, so left it alone for now.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/9015015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/async_filter_factory_base.h | 4 | ||||
-rw-r--r-- | media/base/composite_data_source_factory.cc | 22 | ||||
-rw-r--r-- | media/base/composite_data_source_factory.h | 8 | ||||
-rw-r--r-- | media/base/data_buffer.cc | 6 | ||||
-rw-r--r-- | media/base/data_buffer.h | 7 | ||||
-rw-r--r-- | media/base/filter_collection.cc | 8 | ||||
-rw-r--r-- | media/base/filter_collection.h | 5 | ||||
-rw-r--r-- | media/base/filter_factories.h | 6 | ||||
-rw-r--r-- | media/base/media_log.cc | 56 | ||||
-rw-r--r-- | media/base/media_log.h | 35 | ||||
-rw-r--r-- | media/base/mock_filters.cc | 24 | ||||
-rw-r--r-- | media/base/mock_filters.h | 15 | ||||
-rw-r--r-- | media/base/pipeline.h | 7 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 11 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 6 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 15 | ||||
-rw-r--r-- | media/base/test_data_util.cc | 4 |
17 files changed, 120 insertions, 119 deletions
diff --git a/media/base/async_filter_factory_base.h b/media/base/async_filter_factory_base.h index 303bad9..4a9200e 100644 --- a/media/base/async_filter_factory_base.h +++ b/media/base/async_filter_factory_base.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,7 +62,7 @@ class MEDIA_EXPORT AsyncDataSourceFactoryBase : public DataSourceFactory { // NOTE: Nothing in this base class needs to be cloned because this class // only keeps track of pending requests, which are not part of the cloning // process. - virtual DataSourceFactory* Clone() const = 0; + virtual scoped_ptr<DataSourceFactory> Clone() const = 0; protected: class MEDIA_EXPORT BuildRequest { diff --git a/media/base/composite_data_source_factory.cc b/media/base/composite_data_source_factory.cc index e751505..c0c28e1 100644 --- a/media/base/composite_data_source_factory.cc +++ b/media/base/composite_data_source_factory.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,7 @@ class CompositeDataSourceFactory::BuildRequest void CallNextFactory(); void OnBuildDone(PipelineStatus status, DataSource* data_source); - FactoryList factories_; + FactoryList factories_; // Not owned by this class. }; CompositeDataSourceFactory::CompositeDataSourceFactory() {} @@ -35,21 +35,25 @@ CompositeDataSourceFactory::~CompositeDataSourceFactory() { STLDeleteElements(&factories_); } -void CompositeDataSourceFactory::AddFactory(DataSourceFactory* factory) { - DCHECK(factory); - factories_.push_back(factory); +void CompositeDataSourceFactory::AddFactory( + scoped_ptr<DataSourceFactory> factory) { + DCHECK(factory.get()); + factories_.push_back(factory.release()); } -DataSourceFactory* CompositeDataSourceFactory::Clone() const { - CompositeDataSourceFactory* new_factory = new CompositeDataSourceFactory(); +scoped_ptr<DataSourceFactory> CompositeDataSourceFactory::Clone() const { + scoped_ptr<CompositeDataSourceFactory> new_factory( + new CompositeDataSourceFactory()); for (FactoryList::const_iterator itr = factories_.begin(); itr != factories_.end(); ++itr) { - new_factory->AddFactory((*itr)->Clone()); + new_factory->AddFactory((*itr)->Clone().Pass()); } - return new_factory; + // TODO(fischman): replace the extra scoped_ptr+release() with Pass() when + // http://crbug.com/109026 is fixed. + return scoped_ptr<DataSourceFactory>(new_factory.release()); } bool CompositeDataSourceFactory::AllowRequests() const { diff --git a/media/base/composite_data_source_factory.h b/media/base/composite_data_source_factory.h index 9f962d8..0118ce5 100644 --- a/media/base/composite_data_source_factory.h +++ b/media/base/composite_data_source_factory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,11 +19,11 @@ class MEDIA_EXPORT CompositeDataSourceFactory CompositeDataSourceFactory(); virtual ~CompositeDataSourceFactory(); - // Add factory to this composite. Ownership is transferred here. - void AddFactory(DataSourceFactory* factory); + // Add factory to this composite. + void AddFactory(scoped_ptr<DataSourceFactory> factory); // DataSourceFactory method. - virtual DataSourceFactory* Clone() const OVERRIDE; + virtual scoped_ptr<DataSourceFactory> Clone() const OVERRIDE; protected: // AsyncDataSourceFactoryBase methods. diff --git a/media/base/data_buffer.cc b/media/base/data_buffer.cc index 31b3c1c..b82de51 100644 --- a/media/base/data_buffer.cc +++ b/media/base/data_buffer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,8 +7,8 @@ namespace media { -DataBuffer::DataBuffer(uint8* buffer, size_t buffer_size) - : data_(buffer), +DataBuffer::DataBuffer(scoped_array<uint8> buffer, size_t buffer_size) + : data_(buffer.Pass()), buffer_size_(buffer_size), data_size_(buffer_size) { } diff --git a/media/base/data_buffer.h b/media/base/data_buffer.h index bb010f3..6c5c8a9 100644 --- a/media/base/data_buffer.h +++ b/media/base/data_buffer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,9 +17,8 @@ namespace media { class MEDIA_EXPORT DataBuffer : public Buffer { public: - // Takes ownership of the passed |buffer|, assumes valid data of size - // |buffer_size|. - DataBuffer(uint8* buffer, size_t buffer_size); + // Assumes valid data of size |buffer_size|. + DataBuffer(scoped_array<uint8> buffer, size_t buffer_size); // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is // set to a NULL ptr. diff --git a/media/base/filter_collection.cc b/media/base/filter_collection.cc index ed2339f..42f42d0 100644 --- a/media/base/filter_collection.cc +++ b/media/base/filter_collection.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,9 +12,9 @@ FilterCollection::FilterCollection() {} FilterCollection::~FilterCollection() {} -void FilterCollection::SetDemuxerFactory(DemuxerFactory* factory) { - DCHECK(factory); - demuxer_factory_.reset(factory); +void FilterCollection::SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory) { + DCHECK(factory.get()); + demuxer_factory_ = factory.Pass(); } DemuxerFactory* FilterCollection::GetDemuxerFactory() { diff --git a/media/base/filter_collection.h b/media/base/filter_collection.h index edf6b29..f129723 100644 --- a/media/base/filter_collection.h +++ b/media/base/filter_collection.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,8 +21,7 @@ class MEDIA_EXPORT FilterCollection { ~FilterCollection(); // DemuxerFactory accessor methods. - // FilterCollection takes ownership of the factory here. - void SetDemuxerFactory(DemuxerFactory* factory); + void SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory); DemuxerFactory* GetDemuxerFactory(); // Adds a filter to the collection. diff --git a/media/base/filter_factories.h b/media/base/filter_factories.h index 8b27c11..6158ff4 100644 --- a/media/base/filter_factories.h +++ b/media/base/filter_factories.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,7 +28,7 @@ class MEDIA_EXPORT DataSourceFactory { // Makes a copy of this factory. // NOTE: Pending requests are not cloned. - virtual DataSourceFactory* Clone() const = 0; + virtual scoped_ptr<DataSourceFactory> Clone() const = 0; }; class Demuxer; @@ -46,7 +46,7 @@ class MEDIA_EXPORT DemuxerFactory { // Makes a copy of this factory. // NOTE: Pending requests are not cloned. - virtual DemuxerFactory* Clone() const = 0; + virtual scoped_ptr<DemuxerFactory> Clone() const = 0; }; } // namespace media diff --git a/media/base/media_log.cc b/media/base/media_log.cc index ea61682..d9ac529 100644 --- a/media/base/media_log.cc +++ b/media/base/media_log.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -150,81 +150,81 @@ MediaLog::MediaLog() { MediaLog::~MediaLog() {} -void MediaLog::AddEvent(MediaLogEvent* event) { - scoped_ptr<MediaLogEvent> e(event); +void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { } -MediaLogEvent* MediaLog::CreateEvent(MediaLogEvent::Type type) { +scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { scoped_ptr<MediaLogEvent> event(new MediaLogEvent); event->id = id_; event->type = type; event->time = base::Time::Now(); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateBooleanEvent(MediaLogEvent::Type type, - const char* property, bool value) { +scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent( + MediaLogEvent::Type type, const char* property, bool value) { scoped_ptr<MediaLogEvent> event(CreateEvent(type)); event->params.SetBoolean(property, value); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateIntegerEvent(MediaLogEvent::Type type, - const char* property, int64 value) { +scoped_ptr<MediaLogEvent> MediaLog::CreateIntegerEvent( + MediaLogEvent::Type type, const char* property, int64 value) { scoped_ptr<MediaLogEvent> event(CreateEvent(type)); event->params.SetInteger(property, value); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateTimeEvent(MediaLogEvent::Type type, - const char* property, - base::TimeDelta value) { +scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent( + MediaLogEvent::Type type, const char* property, base::TimeDelta value) { scoped_ptr<MediaLogEvent> event(CreateEvent(type)); event->params.SetDouble(property, value.InSecondsF()); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateLoadEvent(const std::string& url) { +scoped_ptr<MediaLogEvent> MediaLog::CreateLoadEvent(const std::string& url) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD)); event->params.SetString("url", url); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateSeekEvent(float seconds) { +scoped_ptr<MediaLogEvent> MediaLog::CreateSeekEvent(float seconds) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK)); event->params.SetDouble("seek_target", seconds); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreatePipelineStateChangedEvent( +scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent( PipelineImpl::State state) { scoped_ptr<MediaLogEvent> event( CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED)); event->params.SetString("pipeline_state", PipelineStateToString(state)); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreatePipelineErrorEvent(PipelineStatus error) { +scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineErrorEvent( + PipelineStatus error) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR)); event->params.SetString("pipeline_error", PipelineStatusToString(error)); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateVideoSizeSetEvent(size_t width, size_t height) { +scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent( + size_t width, size_t height) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET)); event->params.SetInteger("width", width); event->params.SetInteger("height", height); - return event.release(); + return event.Pass(); } -MediaLogEvent* MediaLog::CreateBufferedExtentsChangedEvent( +scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent( size_t start, size_t current, size_t end) { scoped_ptr<MediaLogEvent> event( CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); event->params.SetInteger("buffer_start", start); event->params.SetInteger("buffer_current", current); event->params.SetInteger("buffer_end", end); - return event.release(); + return event.Pass(); } void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) { @@ -255,7 +255,7 @@ void MediaLog::AddStatisticsUpdatedEvent() { last_statistics_.video_frames_decoded); event->params.SetInteger("video_frames_dropped", last_statistics_.video_frames_dropped); - AddEvent(event.release()); + AddEvent(event.Pass()); stats_update_pending_ = false; } diff --git a/media/base/media_log.h b/media/base/media_log.h index 9f5e668..236c533 100644 --- a/media/base/media_log.h +++ b/media/base/media_log.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,24 +26,25 @@ class MEDIA_EXPORT MediaLog : public base::RefCountedThreadSafe<MediaLog> { // Add an event to this log. Overriden by inheritors to actually do something // with it. - // Takes ownership of |event|. - virtual void AddEvent(MediaLogEvent* event); + virtual void AddEvent(scoped_ptr<MediaLogEvent> event); // Helper methods to create events and their parameters. - MediaLogEvent* CreateEvent(MediaLogEvent::Type type); - MediaLogEvent* CreateBooleanEvent(MediaLogEvent::Type type, - const char* property, bool value); - MediaLogEvent* CreateIntegerEvent(MediaLogEvent::Type type, - const char* property, int64 value); - MediaLogEvent* CreateTimeEvent(MediaLogEvent::Type type, - const char* property, base::TimeDelta value); - MediaLogEvent* CreateLoadEvent(const std::string& url); - MediaLogEvent* CreateSeekEvent(float seconds); - MediaLogEvent* CreatePipelineStateChangedEvent(PipelineImpl::State state); - MediaLogEvent* CreatePipelineErrorEvent(PipelineStatus error); - MediaLogEvent* CreateVideoSizeSetEvent(size_t width, size_t height); - MediaLogEvent* CreateBufferedExtentsChangedEvent(size_t start, size_t current, - size_t end); + scoped_ptr<MediaLogEvent> CreateEvent(MediaLogEvent::Type type); + scoped_ptr<MediaLogEvent> CreateBooleanEvent( + MediaLogEvent::Type type, const char* property, bool value); + scoped_ptr<MediaLogEvent> CreateIntegerEvent( + MediaLogEvent::Type type, const char* property, int64 value); + scoped_ptr<MediaLogEvent> CreateTimeEvent( + MediaLogEvent::Type type, const char* property, base::TimeDelta value); + scoped_ptr<MediaLogEvent> CreateLoadEvent(const std::string& url); + scoped_ptr<MediaLogEvent> CreateSeekEvent(float seconds); + scoped_ptr<MediaLogEvent> CreatePipelineStateChangedEvent( + PipelineImpl::State state); + scoped_ptr<MediaLogEvent> CreatePipelineErrorEvent(PipelineStatus error); + scoped_ptr<MediaLogEvent> CreateVideoSizeSetEvent( + size_t width, size_t height); + scoped_ptr<MediaLogEvent> CreateBufferedExtentsChangedEvent( + size_t start, size_t current, size_t end); // Called when the pipeline statistics have been updated. // This gets called every frame, so we send the most recent stats after 500ms. diff --git a/media/base/mock_filters.cc b/media/base/mock_filters.cc index a406620..44c0062 100644 --- a/media/base/mock_filters.cc +++ b/media/base/mock_filters.cc @@ -1,10 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/mock_filters.h" #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "media/base/filter_host.h" using ::testing::_; @@ -65,8 +66,8 @@ void MockDemuxerFactory::RunBuildCallback(const std::string& url, callback.Run(status_, NULL); } -DemuxerFactory* MockDemuxerFactory::Clone() const { - return new MockDemuxerFactory(demuxer_.get()); +scoped_ptr<DemuxerFactory> MockDemuxerFactory::Clone() const { + return scoped_ptr<DemuxerFactory>(new MockDemuxerFactory(demuxer_.get())); } MockDemuxer::MockDemuxer() @@ -124,33 +125,36 @@ MockFilterCollection::MockFilterCollection() MockFilterCollection::~MockFilterCollection() {} -FilterCollection* MockFilterCollection::filter_collection( +scoped_ptr<FilterCollection> MockFilterCollection::filter_collection( bool include_demuxer, bool run_build_callback, bool run_build, PipelineStatus build_status) const { - FilterCollection* collection = new FilterCollection(); + scoped_ptr<FilterCollection> collection(new FilterCollection()); - MockDemuxerFactory* demuxer_factory = - new MockDemuxerFactory(include_demuxer ? demuxer_ : NULL); + scoped_ptr<MockDemuxerFactory> demuxer_factory( + new MockDemuxerFactory(include_demuxer ? demuxer_ : NULL)); if (build_status != PIPELINE_OK) demuxer_factory->SetError(build_status); if (run_build_callback) { ON_CALL(*demuxer_factory, Build(_, _)).WillByDefault(Invoke( - demuxer_factory, &MockDemuxerFactory::RunBuildCallback)); + demuxer_factory.get(), &MockDemuxerFactory::RunBuildCallback)); } // else ignore Build calls. if (run_build) EXPECT_CALL(*demuxer_factory, Build(_, _)); - collection->SetDemuxerFactory(demuxer_factory); + // TODO(fischman): replace the extra scoped_ptr+release() with Pass() when + // http://crbug.com/109026 is fixed. + collection->SetDemuxerFactory(scoped_ptr<DemuxerFactory>( + demuxer_factory.release())); collection->AddVideoDecoder(video_decoder_); collection->AddAudioDecoder(audio_decoder_); collection->AddVideoRenderer(video_renderer_); collection->AddAudioRenderer(audio_renderer_); - return collection; + return collection.Pass(); } void RunFilterCallback(::testing::Unused, const base::Closure& callback) { diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 5f8a5d7..22a0ce59 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -148,7 +148,7 @@ class MockDemuxerFactory : public DemuxerFactory { // DemuxerFactory methods. MOCK_METHOD2(Build, void(const std::string& url, const BuildCallback& callback)); - virtual DemuxerFactory* Clone() const; + virtual scoped_ptr<DemuxerFactory> Clone() const; private: scoped_refptr<MockDemuxer> demuxer_; @@ -294,14 +294,13 @@ class MockFilterCollection { MockVideoRenderer* video_renderer() const { return video_renderer_; } MockAudioRenderer* audio_renderer() const { return audio_renderer_; } - FilterCollection* filter_collection() const { - return filter_collection(true, true, true, PIPELINE_OK); + scoped_ptr<FilterCollection> filter_collection() const { + return filter_collection(true, true, true, PIPELINE_OK).Pass(); } - FilterCollection* filter_collection(bool include_demuxer, - bool run_build_callback, - bool run_build, - PipelineStatus build_status) const; + scoped_ptr<FilterCollection> filter_collection( + bool include_demuxer, bool run_build_callback, bool run_build, + PipelineStatus build_status) const; private: scoped_refptr<MockDemuxer> demuxer_; diff --git a/media/base/pipeline.h b/media/base/pipeline.h index cc38c4b..7d382d0 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -50,8 +50,7 @@ class MEDIA_EXPORT Pipeline : public base::RefCountedThreadSafe<Pipeline> { // The parameter specifies the type of event that is being signaled. typedef base::Callback<void(NetworkEvent)> NetworkEventCB; - // Initializes pipeline. Pipeline takes ownership of all callbacks passed - // into this method. + // Initializes pipeline. // |ended_callback| will be executed when the media reaches the end. // |error_callback_| will be executed upon an error in the pipeline. // |network_callback_| will be executed when there's a network event. @@ -70,7 +69,7 @@ class MEDIA_EXPORT Pipeline : public base::RefCountedThreadSafe<Pipeline> { // This method is asynchronous and can execute a callback when completed. // If the caller provides a |start_callback|, it will be called when the // pipeline initialization completes. - virtual bool Start(FilterCollection* filter_collection, + virtual bool Start(scoped_ptr<FilterCollection> filter_collection, const std::string& url, const PipelineStatusCB& start_callback) = 0; diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 5ea444c..7f709e4 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -98,11 +98,10 @@ void PipelineImpl::Init(const PipelineStatusCB& ended_callback, } // Creates the PipelineInternal and calls it's start method. -bool PipelineImpl::Start(FilterCollection* collection, +bool PipelineImpl::Start(scoped_ptr<FilterCollection> collection, const std::string& url, const PipelineStatusCB& start_callback) { base::AutoLock auto_lock(lock_); - scoped_ptr<FilterCollection> filter_collection(collection); if (running_) { VLOG(1) << "Media pipeline is already running"; @@ -118,7 +117,7 @@ bool PipelineImpl::Start(FilterCollection* collection, message_loop_->PostTask( FROM_HERE, base::Bind(&PipelineImpl::StartTask, this, - filter_collection.release(), + base::Passed(&collection), url, start_callback)); return true; @@ -626,12 +625,12 @@ void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { media_log_->QueueStatisticsUpdatedEvent(statistics_); } -void PipelineImpl::StartTask(FilterCollection* filter_collection, +void PipelineImpl::StartTask(scoped_ptr<FilterCollection> filter_collection, const std::string& url, const PipelineStatusCB& start_callback) { DCHECK_EQ(MessageLoop::current(), message_loop_); DCHECK_EQ(kCreated, state_); - filter_collection_.reset(filter_collection); + filter_collection_ = filter_collection.Pass(); url_ = url; seek_callback_ = start_callback; diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index be55291..c7a8e9f 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -107,7 +107,7 @@ class MEDIA_EXPORT PipelineImpl virtual void Init(const PipelineStatusCB& ended_callback, const PipelineStatusCB& error_callback, const NetworkEventCB& network_callback) OVERRIDE; - virtual bool Start(FilterCollection* filter_collection, + virtual bool Start(scoped_ptr<FilterCollection> filter_collection, const std::string& uri, const PipelineStatusCB& start_callback) OVERRIDE; virtual void Stop(const PipelineStatusCB& stop_callback) OVERRIDE; @@ -231,7 +231,7 @@ class MEDIA_EXPORT PipelineImpl // The following "task" methods correspond to the public methods, but these // methods are run as the result of posting a task to the PipelineInternal's // message loop. - void StartTask(FilterCollection* filter_collection, + void StartTask(scoped_ptr<FilterCollection> filter_collection, const std::string& url, const PipelineStatusCB& start_callback); diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index e27bdda..73b62b5 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -205,7 +205,7 @@ class PipelineImplTest : public ::testing::Test { pipeline_->Start(mocks_->filter_collection(true, true, true, - build_status), + build_status).Pass(), "", base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); @@ -328,7 +328,7 @@ TEST_F(PipelineImplTest, NeverInitializes) { pipeline_->Start(mocks_->filter_collection(false, false, true, - PIPELINE_OK), + PIPELINE_OK).Pass(), "", base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); @@ -352,12 +352,9 @@ TEST_F(PipelineImplTest, RequiredFilterMissing) { EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); // Create a filter collection with missing filter. - FilterCollection* collection = - mocks_->filter_collection(false, - true, - true, - PIPELINE_ERROR_REQUIRED_FILTER_MISSING); - pipeline_->Start(collection, "", + scoped_ptr<FilterCollection> collection(mocks_->filter_collection( + false, true, true, PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); + pipeline_->Start(collection.Pass(), "", base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); message_loop_.RunAllPending(); diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc index 45a3735..a7fb78e 100644 --- a/media/base/test_data_util.cc +++ b/media/base/test_data_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -42,7 +42,7 @@ void ReadTestDataFile(const std::string& name, scoped_refptr<Buffer>* buffer) { scoped_array<uint8> buf; int buf_size; ReadTestDataFile(name, &buf, &buf_size); - *buffer = new DataBuffer(buf.release(), buf_size); + *buffer = new DataBuffer(buf.Pass(), buf_size); } } // namespace media |