diff options
author | dcheng <dcheng@chromium.org> | 2015-12-27 00:54:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-27 08:54:53 +0000 |
commit | 652f5ff5aa1c3592d61a310edc680bf92cf9f57b (patch) | |
tree | b9d734a460575b5de93ad0bee4204b1cf628a714 | |
parent | a3fa7abe73f7bd52b3333f8da4ba5c2333b4f78f (diff) | |
download | chromium_src-652f5ff5aa1c3592d61a310edc680bf92cf9f57b.zip chromium_src-652f5ff5aa1c3592d61a310edc680bf92cf9f57b.tar.gz chromium_src-652f5ff5aa1c3592d61a310edc680bf92cf9f57b.tar.bz2 |
Convert Pass()→std::move() in //media
☃
BUG=557422
R=avi@chromium.org
TBR=jrummell@chromium.org
Review URL: https://codereview.chromium.org/1544313002
Cr-Commit-Position: refs/heads/master@{#366924}
135 files changed, 865 insertions, 808 deletions
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc index dc207b0..8ab709d 100644 --- a/media/audio/audio_input_controller.cc +++ b/media/audio/audio_input_controller.cc @@ -4,6 +4,8 @@ #include "media/audio/audio_input_controller.h" +#include <utility> + #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "base/single_thread_task_runner.h" @@ -730,7 +732,7 @@ void AudioInputController::WriteInputDataForDebugging( scoped_ptr<AudioBus> data) { DCHECK(task_runner_->BelongsToCurrentThread()); if (input_writer_) - input_writer_->Write(data.Pass()); + input_writer_->Write(std::move(data)); } } // namespace media diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc index ae64f34..52017f2 100644 --- a/media/audio/audio_input_device.cc +++ b/media/audio/audio_input_device.cc @@ -5,6 +5,7 @@ #include "media/audio/audio_input_device.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/macros.h" @@ -56,7 +57,7 @@ AudioInputDevice::AudioInputDevice( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) : ScopedTaskRunnerObserver(io_task_runner), callback_(NULL), - ipc_(ipc.Pass()), + ipc_(std::move(ipc)), state_(IDLE), session_id_(0), agc_is_enabled_(false), @@ -296,7 +297,7 @@ void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { reinterpret_cast<media::AudioInputBuffer*>(ptr); scoped_ptr<media::AudioBus> audio_bus = media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); - audio_buses_.push_back(audio_bus.Pass()); + audio_buses_.push_back(std::move(audio_bus)); ptr += segment_length_; } } diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc index 6c5d59e..3af32b7 100644 --- a/media/audio/audio_output_device.cc +++ b/media/audio/audio_output_device.cc @@ -6,6 +6,7 @@ #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/callback_helpers.h" #include "base/macros.h" @@ -51,7 +52,7 @@ AudioOutputDevice::AudioOutputDevice( const url::Origin& security_origin) : ScopedTaskRunnerObserver(io_task_runner), callback_(NULL), - ipc_(ipc.Pass()), + ipc_(std::move(ipc)), state_(IDLE), start_on_authorized_(false), play_on_start_(true), diff --git a/media/audio/sounds/audio_stream_handler.cc b/media/audio/sounds/audio_stream_handler.cc index 373a3ed..62235c9 100644 --- a/media/audio/sounds/audio_stream_handler.cc +++ b/media/audio/sounds/audio_stream_handler.cc @@ -5,8 +5,8 @@ #include "media/audio/sounds/audio_stream_handler.h" #include <stdint.h> - #include <string> +#include <utility> #include "base/cancelable_callback.h" #include "base/logging.h" @@ -45,7 +45,7 @@ class AudioStreamHandler::AudioStreamContainer stream_(NULL), cursor_(0), delayed_stop_posted_(false), - wav_audio_(wav_audio.Pass()) { + wav_audio_(std::move(wav_audio)) { DCHECK(wav_audio_); } @@ -188,7 +188,7 @@ AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data) { // Store the duration of the WAV data then pass the handler to |stream_|. duration_ = wav_audio->GetDuration(); - stream_.reset(new AudioStreamContainer(wav_audio.Pass())); + stream_.reset(new AudioStreamContainer(std::move(wav_audio))); } AudioStreamHandler::~AudioStreamHandler() { diff --git a/media/base/audio_shifter.cc b/media/base/audio_shifter.cc index 11b7b6f..f5aee2c 100644 --- a/media/base/audio_shifter.cc +++ b/media/base/audio_shifter.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/base/audio_shifter.h" + #include <algorithm> #include <cmath> +#include <utility> #include "base/bind.h" #include "media/base/audio_bus.h" -#include "media/base/audio_shifter.h" namespace media { @@ -111,7 +113,7 @@ void AudioShifter::Push(scoped_ptr<AudioBus> input, playout_time, base::TimeDelta::FromSeconds(queue_.back().audio->frames()) / rate_); } - queue_.push_back(AudioQueueEntry(playout_time, input.Pass())); + queue_.push_back(AudioQueueEntry(playout_time, std::move(input))); while (!queue_.empty() && queue_.back().target_playout_time - queue_.front().target_playout_time > max_buffer_size_) { diff --git a/media/base/audio_shifter_unittest.cc b/media/base/audio_shifter_unittest.cc index f424033e..1544704 100644 --- a/media/base/audio_shifter_unittest.cc +++ b/media/base/audio_shifter_unittest.cc @@ -52,7 +52,7 @@ class AudioShifterTest : tag_input_ = false; expect_smooth_output_ = false; } - return input.Pass(); + return input; } void SetupOutput(int size, base::TimeDelta rate) { @@ -165,7 +165,7 @@ TEST_P(AudioShifterTest, TestSync) { TEST_P(AudioShifterTest, TestSyncWithPush) { // Push some extra audio. - shifter_.Push(CreateTestInput().Pass(), now_ - base::TimeDelta(input_rate_)); + shifter_.Push(CreateTestInput(), now_ - base::TimeDelta(input_rate_)); RunAndCheckSync(1000); EXPECT_LE(skip_outputs_.size(), 2UL); } diff --git a/media/base/audio_splicer.cc b/media/base/audio_splicer.cc index cc0c72b..8e84fd7 100644 --- a/media/base/audio_splicer.cc +++ b/media/base/audio_splicer.cc @@ -5,9 +5,9 @@ #include "media/base/audio_splicer.h" #include <stdint.h> - #include <cstdlib> #include <deque> +#include <utility> #include "base/logging.h" #include "base/macros.h" @@ -56,7 +56,7 @@ scoped_ptr<AudioBus> CreateAudioBufferWrapper( wrapper->SetChannelData( ch, reinterpret_cast<float*>(buffer->channel_data()[ch])); } - return wrapper.Pass(); + return wrapper; } } // namespace @@ -380,7 +380,7 @@ bool AudioSplicer::AddInput(const scoped_refptr<AudioBuffer>& input) { // Crossfade the pre splice and post splice sections and transfer all relevant // buffers into |output_sanitizer_|. - CrossfadePostSplice(pre_splice.Pass(), crossfade_buffer); + CrossfadePostSplice(std::move(pre_splice), crossfade_buffer); // Clear the splice timestamp so new splices can be accepted. reset_splice_timestamps(); @@ -497,7 +497,7 @@ scoped_ptr<AudioBus> AudioSplicer::ExtractCrossfadeFromPreSplice( pre_splice_sanitizer_->Reset(); DCHECK_EQ(output_bus->frames(), frames_read); DCHECK_EQ(output_ts_helper.GetFramesToTarget(splice_timestamp_), 0); - return output_bus.Pass(); + return output_bus; } void AudioSplicer::CrossfadePostSplice( diff --git a/media/base/audio_video_metadata_extractor_unittest.cc b/media/base/audio_video_metadata_extractor_unittest.cc index d0927d5..d67808f 100644 --- a/media/base/audio_video_metadata_extractor_unittest.cc +++ b/media/base/audio_video_metadata_extractor_unittest.cc @@ -29,14 +29,14 @@ scoped_ptr<AudioVideoMetadataExtractor> GetExtractor( EXPECT_EQ(expected_result, extracted); if (!extracted) - return extractor.Pass(); + return extractor; EXPECT_EQ(expected_duration, extractor->duration()); EXPECT_EQ(expected_width, extractor->width()); EXPECT_EQ(expected_height, extractor->height()); - return extractor.Pass(); + return extractor; } TEST(AudioVideoMetadataExtractorTest, InvalidFile) { diff --git a/media/base/bind_to_current_loop_unittest.cc b/media/base/bind_to_current_loop_unittest.cc index 2303085..7fb56d4 100644 --- a/media/base/bind_to_current_loop_unittest.cc +++ b/media/base/bind_to_current_loop_unittest.cc @@ -4,6 +4,8 @@ #include "media/base/bind_to_current_loop.h" +#include <utility> + #include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" #include "testing/gtest/include/gtest/gtest.h" @@ -81,7 +83,7 @@ TEST_F(BindToCurrentLoopTest, PassedScopedPtrBool) { scoped_ptr<bool> scoped_ptr_bool(new bool(true)); base::Callback<void(scoped_ptr<bool>)> cb = BindToCurrentLoop(base::Bind( &BoundBoolSetFromScopedPtr, &bool_val)); - cb.Run(scoped_ptr_bool.Pass()); + cb.Run(std::move(scoped_ptr_bool)); EXPECT_FALSE(bool_val); loop_.RunUntilIdle(); EXPECT_TRUE(bool_val); @@ -106,7 +108,7 @@ TEST_F(BindToCurrentLoopTest, PassedScopedArrayBool) { scoped_array_bool[0] = true; base::Callback<void(scoped_ptr<bool[]>)> cb = BindToCurrentLoop(base::Bind( &BoundBoolSetFromScopedArray, &bool_val)); - cb.Run(scoped_array_bool.Pass()); + cb.Run(std::move(scoped_array_bool)); EXPECT_FALSE(bool_val); loop_.RunUntilIdle(); EXPECT_TRUE(bool_val); @@ -134,7 +136,7 @@ TEST_F(BindToCurrentLoopTest, PassedScopedPtrFreeDeleterBool) { base::Callback<void(scoped_ptr<bool, base::FreeDeleter>)> cb = BindToCurrentLoop(base::Bind(&BoundBoolSetFromScopedPtrFreeDeleter, &bool_val)); - cb.Run(scoped_ptr_free_deleter_bool.Pass()); + cb.Run(std::move(scoped_ptr_free_deleter_bool)); EXPECT_FALSE(bool_val); loop_.RunUntilIdle(); EXPECT_TRUE(bool_val); diff --git a/media/base/cdm_promise_adapter.cc b/media/base/cdm_promise_adapter.cc index 3fd2498..5df17d8 100644 --- a/media/base/cdm_promise_adapter.cc +++ b/media/base/cdm_promise_adapter.cc @@ -4,6 +4,8 @@ #include "media/base/cdm_promise_adapter.h" +#include <utility> + #include "media/base/media_keys.h" namespace media { @@ -20,7 +22,7 @@ CdmPromiseAdapter::~CdmPromiseAdapter() { uint32_t CdmPromiseAdapter::SavePromise(scoped_ptr<CdmPromise> promise) { DCHECK(thread_checker_.CalledOnValidThread()); uint32_t promise_id = next_promise_id_++; - promises_.add(promise_id, promise.Pass()); + promises_.add(promise_id, std::move(promise)); return promise_id; } diff --git a/media/base/data_buffer.cc b/media/base/data_buffer.cc index 3879969..0c103f2 100644 --- a/media/base/data_buffer.cc +++ b/media/base/data_buffer.cc @@ -4,6 +4,8 @@ #include "media/base/data_buffer.h" +#include <utility> + namespace media { DataBuffer::DataBuffer(int buffer_size) @@ -14,7 +16,9 @@ DataBuffer::DataBuffer(int buffer_size) } DataBuffer::DataBuffer(scoped_ptr<uint8_t[]> buffer, int buffer_size) - : data_(buffer.Pass()), buffer_size_(buffer_size), data_size_(buffer_size) { + : data_(std::move(buffer)), + buffer_size_(buffer_size), + data_size_(buffer_size) { CHECK(data_.get()); CHECK_GE(buffer_size, 0); } diff --git a/media/base/data_buffer_unittest.cc b/media/base/data_buffer_unittest.cc index c06e087..2b18bf0 100644 --- a/media/base/data_buffer_unittest.cc +++ b/media/base/data_buffer_unittest.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/base/data_buffer.h" + #include <stdint.h> +#include <utility> #include "base/macros.h" #include "base/strings/string_util.h" -#include "media/base/data_buffer.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { @@ -36,7 +38,7 @@ TEST(DataBufferTest, Constructor_ScopedArray) { scoped_ptr<uint8_t[]> data(new uint8_t[kSize]); const uint8_t* kData = data.get(); - scoped_refptr<DataBuffer> buffer = new DataBuffer(data.Pass(), kSize); + scoped_refptr<DataBuffer> buffer = new DataBuffer(std::move(data), kSize); EXPECT_TRUE(buffer->data()); EXPECT_TRUE(buffer->writable_data()); EXPECT_EQ(kData, buffer->data()); diff --git a/media/base/decoder_buffer.h b/media/base/decoder_buffer.h index ae1a993..3460e05 100644 --- a/media/base/decoder_buffer.h +++ b/media/base/decoder_buffer.h @@ -141,7 +141,7 @@ class MEDIA_EXPORT DecoderBuffer void set_decrypt_config(scoped_ptr<DecryptConfig> decrypt_config) { DCHECK(!end_of_stream()); - decrypt_config_ = decrypt_config.Pass(); + decrypt_config_ = std::move(decrypt_config); } // If there's no data in this buffer, it represents end of stream. diff --git a/media/base/media_file_checker.cc b/media/base/media_file_checker.cc index 0482bc54..a04775b 100644 --- a/media/base/media_file_checker.cc +++ b/media/base/media_file_checker.cc @@ -6,8 +6,8 @@ #include <stddef.h> #include <stdint.h> - #include <map> +#include <utility> #include "base/bind.h" #include "base/time/time.h" @@ -24,14 +24,13 @@ static void OnError(bool* called) { *called = false; } -MediaFileChecker::MediaFileChecker(base::File file) : file_(file.Pass()) { -} +MediaFileChecker::MediaFileChecker(base::File file) : file_(std::move(file)) {} MediaFileChecker::~MediaFileChecker() { } bool MediaFileChecker::Start(base::TimeDelta check_time) { - media::FileDataSource source(file_.Pass()); + media::FileDataSource source(std::move(file_)); bool read_ok = true; media::BlockingUrlProtocol protocol(&source, base::Bind(&OnError, &read_ok)); media::FFmpegGlue glue(&protocol); diff --git a/media/base/media_file_checker_unittest.cc b/media/base/media_file_checker_unittest.cc index 001fe04..63aad60 100644 --- a/media/base/media_file_checker_unittest.cc +++ b/media/base/media_file_checker_unittest.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/base/media_file_checker.h" + +#include <utility> + #include "base/files/file.h" #include "base/logging.h" #include "build/build_config.h" -#include "media/base/media_file_checker.h" #include "media/base/test_data_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -16,7 +19,7 @@ static void RunMediaFileChecker(const std::string& filename, bool expectation) { base::File::FLAG_OPEN | base::File::FLAG_READ); ASSERT_TRUE(file.IsValid()); - MediaFileChecker checker(file.Pass()); + MediaFileChecker checker(std::move(file)); const base::TimeDelta check_time = base::TimeDelta::FromMilliseconds(100); bool result = checker.Start(check_time); EXPECT_EQ(expectation, result); diff --git a/media/base/media_log.cc b/media/base/media_log.cc index d0890c2..916021a 100644 --- a/media/base/media_log.cc +++ b/media/base/media_log.cc @@ -4,6 +4,8 @@ #include "media/base/media_log.h" +#include <utility> + #include "base/atomic_sequence_num.h" #include "base/json/json_writer.h" #include "base/values.h" @@ -147,7 +149,7 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { event->id = id_; event->type = type; event->time = base::TimeTicks::Now(); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent( @@ -156,7 +158,7 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent( bool value) { scoped_ptr<MediaLogEvent> event(CreateEvent(type)); event->params.SetBoolean(property, value); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateStringEvent( @@ -165,7 +167,7 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateStringEvent( const std::string& value) { scoped_ptr<MediaLogEvent> event(CreateEvent(type)); event->params.SetString(property, value); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent( @@ -177,19 +179,19 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent( event->params.SetString(property, "unknown"); else event->params.SetDouble(property, value.InSecondsF()); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateLoadEvent(const std::string& url) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD)); event->params.SetString("url", url); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateSeekEvent(float seconds) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK)); event->params.SetDouble("seek_target", seconds); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent( @@ -197,14 +199,14 @@ scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent( scoped_ptr<MediaLogEvent> event( CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED)); event->params.SetString("pipeline_state", Pipeline::GetStateString(state)); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineErrorEvent( PipelineStatus error) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR)); event->params.SetInteger("pipeline_error", error); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent( @@ -212,7 +214,7 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent( scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET)); event->params.SetInteger("width", width); event->params.SetInteger("height", height); - return event.Pass(); + return event; } scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent( @@ -226,41 +228,41 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent( event->params.SetDouble("buffer_start", start); event->params.SetDouble("buffer_current", current); event->params.SetDouble("buffer_end", end); - return event.Pass(); + return event; } void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level))); event->params.SetString(MediaLogLevelToString(level), message); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } void MediaLog::SetStringProperty( const std::string& key, const std::string& value) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); event->params.SetString(key, value); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } void MediaLog::SetIntegerProperty( const std::string& key, int value) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); event->params.SetInteger(key, value); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } void MediaLog::SetDoubleProperty( const std::string& key, double value) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); event->params.SetDouble(key, value); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } void MediaLog::SetBooleanProperty( const std::string& key, bool value) { scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); event->params.SetBoolean(key, value); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } void MediaLog::SetTimeProperty( @@ -270,7 +272,7 @@ void MediaLog::SetTimeProperty( event->params.SetString(key, "unknown"); else event->params.SetDouble(key, value.InSecondsF()); - AddEvent(event.Pass()); + AddEvent(std::move(event)); } LogHelper::LogHelper(MediaLog::MediaLogLevel level, diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc index 9427261..ce49c5d 100644 --- a/media/base/pipeline.cc +++ b/media/base/pipeline.cc @@ -5,6 +5,7 @@ #include "media/base/pipeline.h" #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -80,7 +81,7 @@ void Pipeline::Start(Demuxer* demuxer, running_ = true; demuxer_ = demuxer; - renderer_ = renderer.Pass(); + renderer_ = std::move(renderer); ended_cb_ = ended_cb; error_cb_ = error_cb; seek_cb_ = seek_cb; @@ -148,8 +149,9 @@ void Pipeline::Resume(scoped_ptr<Renderer> renderer, base::TimeDelta timestamp, const PipelineStatusCB& seek_cb) { task_runner_->PostTask( - FROM_HERE, base::Bind(&Pipeline::ResumeTask, weak_factory_.GetWeakPtr(), - base::Passed(renderer.Pass()), timestamp, seek_cb)); + FROM_HERE, + base::Bind(&Pipeline::ResumeTask, weak_factory_.GetWeakPtr(), + base::Passed(std::move(renderer)), timestamp, seek_cb)); } float Pipeline::GetVolume() const { @@ -707,7 +709,7 @@ void Pipeline::ResumeTask(scoped_ptr<Renderer> renderer, DCHECK(!pending_callbacks_.get()); SetState(kResuming); - renderer_ = renderer.Pass(); + renderer_ = std::move(renderer); // Set up for a seek. (Matches setup in SeekTask().) // TODO(sandersd): Share implementation with SeekTask(). diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc index a597aed..5406278 100644 --- a/media/base/pipeline_unittest.cc +++ b/media/base/pipeline_unittest.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <stddef.h> +#include "media/base/pipeline.h" +#include <stddef.h> +#include <utility> #include <vector> #include "base/bind.h" @@ -17,7 +19,6 @@ #include "media/base/gmock_callback_support.h" #include "media/base/media_log.h" #include "media/base/mock_filters.h" -#include "media/base/pipeline.h" #include "media/base/test_helpers.h" #include "media/base/text_renderer.h" #include "media/base/text_track_config.h" @@ -169,7 +170,7 @@ class PipelineTest : public ::testing::Test { DemuxerStream::Type type) { scoped_ptr<StrictMock<MockDemuxerStream> > stream( new StrictMock<MockDemuxerStream>(type)); - return stream.Pass(); + return stream; } // Sets up expectations to allow the video renderer to initialize. @@ -193,7 +194,7 @@ class PipelineTest : public ::testing::Test { void StartPipeline() { EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); pipeline_->Start( - demuxer_.get(), scoped_renderer_.Pass(), + demuxer_.get(), std::move(scoped_renderer_), base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)), @@ -238,7 +239,7 @@ class PipelineTest : public ::testing::Test { void CreateTextStream() { scoped_ptr<FakeTextTrackStream> text_stream(new FakeTextTrackStream()); EXPECT_CALL(*text_stream, OnRead()).Times(AnyNumber()); - text_stream_ = text_stream.Pass(); + text_stream_ = std::move(text_stream); } MockDemuxerStream* audio_stream() { @@ -315,7 +316,7 @@ class PipelineTest : public ::testing::Test { void DoResume(const base::TimeDelta& seek_time) { pipeline_->Resume( - scoped_renderer_.Pass(), seek_time, + std::move(scoped_renderer_), seek_time, base::Bind(&CallbackHelper::OnResume, base::Unretained(&callbacks_))); message_loop_.RunUntilIdle(); } @@ -346,7 +347,7 @@ class PipelineTest : public ::testing::Test { void DoOnAddTextTrack(const TextTrackConfig& config, const AddTextTrackDoneCB& done_cb) { scoped_ptr<TextTrack> text_track(new MockTextTrack); - done_cb.Run(text_track.Pass()); + done_cb.Run(std::move(text_track)); } // Fixture members. diff --git a/media/base/serial_runner.cc b/media/base/serial_runner.cc index 9e599307..2e085e3 100644 --- a/media/base/serial_runner.cc +++ b/media/base/serial_runner.cc @@ -91,7 +91,7 @@ scoped_ptr<SerialRunner> SerialRunner::Run( const Queue& bound_fns, const PipelineStatusCB& done_cb) { scoped_ptr<SerialRunner> callback_series( new SerialRunner(bound_fns, done_cb)); - return callback_series.Pass(); + return callback_series; } void SerialRunner::RunNextInSeries(PipelineStatus last_status) { diff --git a/media/base/text_renderer.cc b/media/base/text_renderer.cc index da0e6f3..2add40c 100644 --- a/media/base/text_renderer.cc +++ b/media/base/text_renderer.cc @@ -5,6 +5,7 @@ #include "media/base/text_renderer.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -296,7 +297,7 @@ void TextRenderer::OnAddTextTrackDone(DemuxerStream* text_stream, DCHECK(text_stream); DCHECK(text_track); - scoped_ptr<TextTrackState> state(new TextTrackState(text_track.Pass())); + scoped_ptr<TextTrackState> state(new TextTrackState(std::move(text_track))); text_track_state_map_[text_stream] = state.release(); pending_eos_set_.insert(text_stream); @@ -317,9 +318,7 @@ void TextRenderer::Read( } TextRenderer::TextTrackState::TextTrackState(scoped_ptr<TextTrack> tt) - : read_state(kReadIdle), - text_track(tt.Pass()) { -} + : read_state(kReadIdle), text_track(std::move(tt)) {} TextRenderer::TextTrackState::~TextTrackState() { } diff --git a/media/base/text_renderer_unittest.cc b/media/base/text_renderer_unittest.cc index 9d669ae..bbf8330 100644 --- a/media/base/text_renderer_unittest.cc +++ b/media/base/text_renderer_unittest.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <stddef.h> +#include "media/base/text_renderer.h" +#include <stddef.h> +#include <utility> #include <vector> #include "base/bind.h" @@ -15,7 +17,6 @@ #include "media/base/decoder_buffer.h" #include "media/base/demuxer_stream.h" #include "media/base/fake_text_track_stream.h" -#include "media/base/text_renderer.h" #include "media/base/text_track_config.h" #include "media/base/video_decoder_config.h" #include "media/filters/webvtt_util.h" @@ -100,7 +101,7 @@ class TextRendererTest : public testing::Test { // text renderer deallocates them. text_tracks_.push_back(new FakeTextTrack(destroy_cb, config)); scoped_ptr<TextTrack> text_track(text_tracks_.back()); - done_cb.Run(text_track.Pass()); + done_cb.Run(std::move(text_track)); } void RemoveTextTrack(unsigned idx) { diff --git a/media/base/video_frame_metadata.cc b/media/base/video_frame_metadata.cc index 31b1918..2ecf002 100644 --- a/media/base/video_frame_metadata.cc +++ b/media/base/video_frame_metadata.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/base/video_frame_metadata.h" + #include <stdint.h> +#include <utility> #include "base/logging.h" #include "base/strings/string_number_conversions.h" -#include "media/base/video_frame_metadata.h" namespace media { @@ -72,7 +74,7 @@ void VideoFrameMetadata::SetTimeTicks(Key key, const base::TimeTicks& value) { } void VideoFrameMetadata::SetValue(Key key, scoped_ptr<base::Value> value) { - dictionary_.SetWithoutPathExpansion(ToInternalKey(key), value.Pass()); + dictionary_.SetWithoutPathExpansion(ToInternalKey(key), std::move(value)); } bool VideoFrameMetadata::GetBoolean(Key key, bool* value) const { diff --git a/media/blink/active_loader.cc b/media/blink/active_loader.cc index 2f1e084..0f38b0a 100644 --- a/media/blink/active_loader.cc +++ b/media/blink/active_loader.cc @@ -4,15 +4,15 @@ #include "media/blink/active_loader.h" +#include <utility> + #include "media/blink/buffered_resource_loader.h" #include "third_party/WebKit/public/platform/WebURLLoader.h" namespace media { ActiveLoader::ActiveLoader(scoped_ptr<blink::WebURLLoader> loader) - : loader_(loader.Pass()), - deferred_(false) { -} + : loader_(std::move(loader)), deferred_(false) {} ActiveLoader::~ActiveLoader() { loader_->cancel(); diff --git a/media/blink/buffered_data_source.cc b/media/blink/buffered_data_source.cc index 4dd9fb5..c6e11a6 100644 --- a/media/blink/buffered_data_source.cc +++ b/media/blink/buffered_data_source.cc @@ -4,6 +4,8 @@ #include "media/blink/buffered_data_source.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" @@ -315,7 +317,7 @@ void BufferedDataSource::StopInternal_Locked() { init_cb_.Reset(); if (read_op_) - ReadOperation::Run(read_op_.Pass(), kReadError); + ReadOperation::Run(std::move(read_op_), kReadError); } void BufferedDataSource::StopLoader() { @@ -444,7 +446,7 @@ void BufferedDataSource::PartialReadStartCallback( base::AutoLock auto_lock(lock_); if (stop_signal_received_) return; - ReadOperation::Run(read_op_.Pass(), kReadError); + ReadOperation::Run(std::move(read_op_), kReadError); } bool BufferedDataSource::CheckPartialResponseURL( @@ -510,7 +512,7 @@ void BufferedDataSource::ReadCallback( return; } - ReadOperation::Run(read_op_.Pass(), kReadError); + ReadOperation::Run(std::move(read_op_), kReadError); return; } @@ -529,7 +531,7 @@ void BufferedDataSource::ReadCallback( total_bytes_); } } - ReadOperation::Run(read_op_.Pass(), bytes_read); + ReadOperation::Run(std::move(read_op_), bytes_read); } void BufferedDataSource::LoadingStateChangedCallback( diff --git a/media/blink/buffered_resource_loader.cc b/media/blink/buffered_resource_loader.cc index dedd3bf..01427a1 100644 --- a/media/blink/buffered_resource_loader.cc +++ b/media/blink/buffered_resource_loader.cc @@ -6,8 +6,8 @@ #include <stddef.h> #include <stdint.h> - #include <limits> +#include <utility> #include "base/bits.h" #include "base/callback_helpers.h" @@ -183,7 +183,7 @@ void BufferedResourceLoader::Start( // Check for our test WebURLLoader. scoped_ptr<WebURLLoader> loader; if (test_loader_) { - loader = test_loader_.Pass(); + loader = std::move(test_loader_); } else { WebURLLoaderOptions options; if (cors_mode_ == kUnspecified) { @@ -204,7 +204,7 @@ void BufferedResourceLoader::Start( // Start the resource loading. loader->loadAsynchronously(request, this); - active_loader_.reset(new ActiveLoader(loader.Pass())); + active_loader_.reset(new ActiveLoader(std::move(loader))); loading_cb_.Run(kLoading); } @@ -555,7 +555,7 @@ void BufferedResourceLoader::didFail( // We don't need to continue loading after failure. // // Keep it alive until we exit this method so that |error| remains valid. - scoped_ptr<ActiveLoader> active_loader = active_loader_.Pass(); + scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); loader_failed_ = true; loading_cb_.Run(kLoadingFailed); diff --git a/media/blink/cdm_session_adapter.cc b/media/blink/cdm_session_adapter.cc index e260340..f264287 100644 --- a/media/blink/cdm_session_adapter.cc +++ b/media/blink/cdm_session_adapter.cc @@ -4,6 +4,8 @@ #include "media/blink/cdm_session_adapter.h" +#include <utility> + #include "base/bind.h" #include "base/logging.h" #include "base/metrics/histogram.h" @@ -45,7 +47,7 @@ void CdmSessionAdapter::CreateCdm( base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); DCHECK(!cdm_created_result_); - cdm_created_result_ = result.Pass(); + cdm_created_result_ = std::move(result); cdm_factory->Create( key_system, security_origin, cdm_config, @@ -61,7 +63,7 @@ void CdmSessionAdapter::CreateCdm( void CdmSessionAdapter::SetServerCertificate( const std::vector<uint8_t>& certificate, scoped_ptr<SimpleCdmPromise> promise) { - cdm_->SetServerCertificate(certificate, promise.Pass()); + cdm_->SetServerCertificate(certificate, std::move(promise)); } WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() { @@ -90,29 +92,29 @@ void CdmSessionAdapter::InitializeNewSession( MediaKeys::SessionType session_type, scoped_ptr<NewSessionCdmPromise> promise) { cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, - promise.Pass()); + std::move(promise)); } void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type, const std::string& session_id, scoped_ptr<NewSessionCdmPromise> promise) { - cdm_->LoadSession(session_type, session_id, promise.Pass()); + cdm_->LoadSession(session_type, session_id, std::move(promise)); } void CdmSessionAdapter::UpdateSession(const std::string& session_id, const std::vector<uint8_t>& response, scoped_ptr<SimpleCdmPromise> promise) { - cdm_->UpdateSession(session_id, response, promise.Pass()); + cdm_->UpdateSession(session_id, response, std::move(promise)); } void CdmSessionAdapter::CloseSession(const std::string& session_id, scoped_ptr<SimpleCdmPromise> promise) { - cdm_->CloseSession(session_id, promise.Pass()); + cdm_->CloseSession(session_id, std::move(promise)); } void CdmSessionAdapter::RemoveSession(const std::string& session_id, scoped_ptr<SimpleCdmPromise> promise) { - cdm_->RemoveSession(session_id, promise.Pass()); + cdm_->RemoveSession(session_id, std::move(promise)); } CdmContext* CdmSessionAdapter::GetCdmContext() { @@ -181,7 +183,8 @@ void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id, DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " << session_id; if (session) - session->OnSessionKeysChange(has_additional_usable_key, keys_info.Pass()); + session->OnSessionKeysChange(has_additional_usable_key, + std::move(keys_info)); } void CdmSessionAdapter::OnSessionExpirationUpdate( diff --git a/media/blink/key_system_config_selector.cc b/media/blink/key_system_config_selector.cc index 2d1577e..2b8316a 100644 --- a/media/blink/key_system_config_selector.cc +++ b/media/blink/key_system_config_selector.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "key_system_config_selector.h" +#include "media/blink/key_system_config_selector.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -705,7 +706,7 @@ void KeySystemConfigSelector::SelectConfig( request->are_secure_codecs_supported = are_secure_codecs_supported; request->succeeded_cb = succeeded_cb; request->not_supported_cb = not_supported_cb; - SelectConfigInternal(request.Pass()); + SelectConfigInternal(std::move(request)); } void KeySystemConfigSelector::SelectConfigInternal( @@ -778,7 +779,7 @@ void KeySystemConfigSelector::OnPermissionResult( bool is_permission_granted) { request->was_permission_requested = true; request->is_permission_granted = is_permission_granted; - SelectConfigInternal(request.Pass()); + SelectConfigInternal(std::move(request)); } } // namespace media diff --git a/media/blink/multibuffer_data_source.cc b/media/blink/multibuffer_data_source.cc index 103b1a0..1ecebcc 100644 --- a/media/blink/multibuffer_data_source.cc +++ b/media/blink/multibuffer_data_source.cc @@ -4,6 +4,8 @@ #include "media/blink/multibuffer_data_source.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" @@ -383,14 +385,14 @@ void MultibufferDataSource::ReadTask() { int64_t available = reader_->Available(); if (available < 0) { // A failure has occured. - ReadOperation::Run(read_op_.Pass(), kReadError); + ReadOperation::Run(std::move(read_op_), kReadError); return; } if (available) { bytes_read = static_cast<int>(std::min<int64_t>(available, read_op_->size())); bytes_read = reader_->TryRead(read_op_->data(), bytes_read); - ReadOperation::Run(read_op_.Pass(), bytes_read); + ReadOperation::Run(std::move(read_op_), bytes_read); } else { reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask, weak_factory_.GetWeakPtr())); @@ -410,7 +412,7 @@ void MultibufferDataSource::StopInternal_Locked() { init_cb_.Reset(); if (read_op_) - ReadOperation::Run(read_op_.Pass(), kReadError); + ReadOperation::Run(std::move(read_op_), kReadError); } void MultibufferDataSource::StopLoader() { diff --git a/media/blink/resource_multibuffer_data_provider.cc b/media/blink/resource_multibuffer_data_provider.cc index b3357c5..0c5c718 100644 --- a/media/blink/resource_multibuffer_data_provider.cc +++ b/media/blink/resource_multibuffer_data_provider.cc @@ -5,6 +5,7 @@ #include "media/blink/resource_multibuffer_data_provider.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/bits.h" @@ -82,7 +83,7 @@ void ResourceMultiBufferDataProvider::Start() { // Check for our test WebURLLoader. scoped_ptr<WebURLLoader> loader; if (test_loader_) { - loader = test_loader_.Pass(); + loader = std::move(test_loader_); } else { WebURLLoaderOptions options; if (url_data_->cors_mode() == UrlData::CORS_UNSPECIFIED) { @@ -103,7 +104,7 @@ void ResourceMultiBufferDataProvider::Start() { // Start the resource loading. loader->loadAsynchronously(request, this); - active_loader_.reset(new ActiveLoader(loader.Pass())); + active_loader_.reset(new ActiveLoader(std::move(loader))); } ResourceMultiBufferDataProvider::~ResourceMultiBufferDataProvider() {} @@ -298,7 +299,7 @@ void ResourceMultiBufferDataProvider::didReceiveResponse( url_data_->multibuffer()->RemoveProvider(this)); url_data_ = destination_url_data.get(); // Give the ownership to our new owner. - url_data_->multibuffer()->AddProvider(self.Pass()); + url_data_->multibuffer()->AddProvider(std::move(self)); // Call callback to let upstream users know about the transfer. // This will merge the data from the two multibuffers and @@ -381,7 +382,7 @@ void ResourceMultiBufferDataProvider::didFinishLoading( base::TimeDelta::FromMilliseconds(kLoaderPartialRetryDelayMs)); return; } else { - scoped_ptr<ActiveLoader> active_loader = active_loader_.Pass(); + scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); url_data_->Fail(); return; } @@ -415,7 +416,7 @@ void ResourceMultiBufferDataProvider::didFail(WebURLLoader* loader, // We don't need to continue loading after failure. // // Keep it alive until we exit this method so that |error| remains valid. - scoped_ptr<ActiveLoader> active_loader = active_loader_.Pass(); + scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); url_data_->Fail(); } } diff --git a/media/blink/texttrack_impl.cc b/media/blink/texttrack_impl.cc index 1d58af9..dbe9762 100644 --- a/media/blink/texttrack_impl.cc +++ b/media/blink/texttrack_impl.cc @@ -4,6 +4,8 @@ #include "media/blink/texttrack_impl.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/single_thread_task_runner.h" @@ -20,7 +22,7 @@ TextTrackImpl::TextTrackImpl( scoped_ptr<WebInbandTextTrackImpl> text_track) : task_runner_(task_runner), client_(client), - text_track_(text_track.Pass()) { + text_track_(std::move(text_track)) { client_->addTextTrack(text_track_.get()); } diff --git a/media/blink/video_frame_compositor.h b/media/blink/video_frame_compositor.h index f7c495d..893fa7c 100644 --- a/media/blink/video_frame_compositor.h +++ b/media/blink/video_frame_compositor.h @@ -5,6 +5,8 @@ #ifndef MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ #define MEDIA_BLINK_VIDEO_FRAME_COMPOSITOR_H_ +#include <utility> + #include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -110,7 +112,7 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor base::TimeDelta GetCurrentFrameTimestamp() const; void set_tick_clock_for_testing(scoped_ptr<base::TickClock> tick_clock) { - tick_clock_ = tick_clock.Pass(); + tick_clock_ = std::move(tick_clock); } void clear_current_frame_for_testing() { current_frame_ = nullptr; } diff --git a/media/blink/webcontentdecryptionmodule_impl.cc b/media/blink/webcontentdecryptionmodule_impl.cc index 81a0ee8..8619107 100644 --- a/media/blink/webcontentdecryptionmodule_impl.cc +++ b/media/blink/webcontentdecryptionmodule_impl.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webcontentdecryptionmodule_impl.h" +#include "media/blink/webcontentdecryptionmodule_impl.h" + +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -68,7 +70,7 @@ void WebContentDecryptionModuleImpl::Create( // be destructed. scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); adapter->CreateCdm(cdm_factory, key_system_ascii, security_origin_as_gurl, - cdm_config, result.Pass()); + cdm_config, std::move(result)); } WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( diff --git a/media/blink/webcontentdecryptionmoduleaccess_impl.cc b/media/blink/webcontentdecryptionmoduleaccess_impl.cc index 8d3b64e..17bb1fb 100644 --- a/media/blink/webcontentdecryptionmoduleaccess_impl.cc +++ b/media/blink/webcontentdecryptionmoduleaccess_impl.cc @@ -4,6 +4,8 @@ #include "media/blink/webcontentdecryptionmoduleaccess_impl.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/memory/scoped_ptr.h" @@ -29,7 +31,7 @@ static void CreateCdm( return; } - client->CreateCdm(key_system, security_origin, cdm_config, result.Pass()); + client->CreateCdm(key_system, security_origin, cdm_config, std::move(result)); } WebContentDecryptionModuleAccessImpl* diff --git a/media/blink/webencryptedmediaclient_impl.cc b/media/blink/webencryptedmediaclient_impl.cc index 940805b..ab226bf 100644 --- a/media/blink/webencryptedmediaclient_impl.cc +++ b/media/blink/webencryptedmediaclient_impl.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webencryptedmediaclient_impl.h" +#include "media/blink/webencryptedmediaclient_impl.h" + +#include <utility> #include "base/bind.h" #include "base/metrics/histogram.h" @@ -124,7 +126,7 @@ void WebEncryptedMediaClientImpl::CreateCdm( const CdmConfig& cdm_config, scoped_ptr<blink::WebContentDecryptionModuleResult> result) { WebContentDecryptionModuleImpl::Create( - cdm_factory_, key_system, security_origin, cdm_config, result.Pass()); + cdm_factory_, key_system, security_origin, cdm_config, std::move(result)); } void WebEncryptedMediaClientImpl::OnRequestSucceeded( diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index 0994d9e..5dd65d0 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc @@ -8,6 +8,7 @@ #include <cmath> #include <limits> #include <string> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -180,7 +181,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( base::Bind(&WebMediaPlayerImpl::SetCdm, AsWeakPtr(), base::Bind(&IgnoreCdmAttached))), - renderer_factory_(renderer_factory.Pass()) { + renderer_factory_(std::move(renderer_factory)) { DCHECK(!adjust_allocated_memory_cb_.is_null()); if (delegate) @@ -1023,9 +1024,9 @@ void WebMediaPlayerImpl::OnAddTextTrack( new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id)); scoped_ptr<TextTrack> text_track(new TextTrackImpl( - main_task_runner_, client_, web_inband_text_track.Pass())); + main_task_runner_, client_, std::move(web_inband_text_track))); - done_cb.Run(text_track.Pass()); + done_cb.Run(std::move(text_track)); } void WebMediaPlayerImpl::OnHidden() { diff --git a/media/blink/webmediaplayer_util.cc b/media/blink/webmediaplayer_util.cc index e1dc363..7581bc3 100644 --- a/media/blink/webmediaplayer_util.cc +++ b/media/blink/webmediaplayer_util.cc @@ -7,6 +7,7 @@ #include <math.h> #include <stddef.h> #include <string> +#include <utility> #include "base/metrics/histogram.h" #include "media/base/bind_to_current_loop.h" @@ -197,7 +198,7 @@ class SetSinkIdCallback { explicit SetSinkIdCallback(blink::WebSetSinkIdCallbacks* web_callback) : web_callback_(web_callback) {} SetSinkIdCallback(const SetSinkIdCallback& other) - : web_callback_(other.web_callback_.Pass()) {} + : web_callback_(std::move(other.web_callback_)) {} ~SetSinkIdCallback() {} friend void RunSetSinkIdCallback(const SetSinkIdCallback& callback, OutputDeviceStatus result); diff --git a/media/capture/content/screen_capture_device_core.cc b/media/capture/content/screen_capture_device_core.cc index d87b0a5..2b3f3cf 100644 --- a/media/capture/content/screen_capture_device_core.cc +++ b/media/capture/content/screen_capture_device_core.cc @@ -4,6 +4,8 @@ #include "media/capture/content/screen_capture_device_core.h" +#include <utility> + #include "base/bind.h" #include "base/logging.h" #include "base/macros.h" @@ -54,7 +56,7 @@ void ScreenCaptureDeviceCore::AllocateAndStart( } oracle_proxy_ = new ThreadSafeCaptureOracle( - client.Pass(), params, capture_machine_->IsAutoThrottlingEnabled()); + std::move(client), params, capture_machine_->IsAutoThrottlingEnabled()); capture_machine_->Start( oracle_proxy_, params, @@ -85,7 +87,7 @@ void ScreenCaptureDeviceCore::CaptureStarted(bool success) { ScreenCaptureDeviceCore::ScreenCaptureDeviceCore( scoped_ptr<VideoCaptureMachine> capture_machine) - : state_(kIdle), capture_machine_(capture_machine.Pass()) { + : state_(kIdle), capture_machine_(std::move(capture_machine)) { DCHECK(capture_machine_.get()); } diff --git a/media/capture/content/thread_safe_capture_oracle.cc b/media/capture/content/thread_safe_capture_oracle.cc index a721a94..a99a99a 100644 --- a/media/capture/content/thread_safe_capture_oracle.cc +++ b/media/capture/content/thread_safe_capture_oracle.cc @@ -5,6 +5,7 @@ #include "media/capture/content/thread_safe_capture_oracle.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bits.h" @@ -35,7 +36,7 @@ ThreadSafeCaptureOracle::ThreadSafeCaptureOracle( scoped_ptr<VideoCaptureDevice::Client> client, const VideoCaptureParams& params, bool enable_auto_throttling) - : client_(client.Pass()), + : client_(std::move(client)), oracle_(base::TimeDelta::FromMicroseconds(static_cast<int64_t>( 1000000.0 / params.requested_format.frame_rate + 0.5 /* to round to nearest int */)), @@ -185,7 +186,7 @@ void ThreadSafeCaptureOracle::DidCaptureFrame( base::Bind(&ThreadSafeCaptureOracle::DidConsumeFrame, this, frame_number, frame->metadata())); - client_->OnIncomingCapturedVideoFrame(buffer.Pass(), frame, timestamp); + client_->OnIncomingCapturedVideoFrame(std::move(buffer), frame, timestamp); } } diff --git a/media/capture/video/fake_video_capture_device.cc b/media/capture/video/fake_video_capture_device.cc index a30b398..f4ef6ad 100644 --- a/media/capture/video/fake_video_capture_device.cc +++ b/media/capture/video/fake_video_capture_device.cc @@ -5,8 +5,8 @@ #include "media/capture/video/fake_video_capture_device.h" #include <stddef.h> - #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/strings/stringprintf.h" @@ -89,7 +89,7 @@ void FakeVideoCaptureDevice::AllocateAndStart( scoped_ptr<VideoCaptureDevice::Client> client) { DCHECK(thread_checker_.CalledOnValidThread()); - client_ = client.Pass(); + client_ = std::move(client); // Incoming |params| can be none of the supported formats, so we get the // closest thing rounded up. TODO(mcasas): Use the |params|, if they belong to @@ -214,7 +214,7 @@ void FakeVideoCaptureDevice::CaptureUsingClientBuffers( } // Give the captured frame to the client. - client_->OnIncomingCapturedBuffer(capture_buffer.Pass(), capture_format_, + client_->OnIncomingCapturedBuffer(std::move(capture_buffer), capture_format_, base::TimeTicks::Now()); BeepAndScheduleNextCapture( diff --git a/media/capture/video/fake_video_capture_device_unittest.cc b/media/capture/video/fake_video_capture_device_unittest.cc index 64dd94c..f61b085 100644 --- a/media/capture/video/fake_video_capture_device_unittest.cc +++ b/media/capture/video/fake_video_capture_device_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/capture/video/fake_video_capture_device.h" + #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/command_line.h" @@ -14,7 +17,6 @@ #include "build/build_config.h" #include "media/base/media_switches.h" #include "media/base/video_capture_types.h" -#include "media/capture/video/fake_video_capture_device.h" #include "media/capture/video/fake_video_capture_device_factory.h" #include "media/capture/video/video_capture_device.h" #include "testing/gmock/include/gmock/gmock.h" @@ -212,7 +214,7 @@ TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) { VideoCaptureParams capture_params; capture_params.requested_format.frame_size.SetSize(640, 480); capture_params.requested_format.frame_rate = testing::get<2>(GetParam()); - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); WaitForCapturedFrame(); EXPECT_EQ(last_format().frame_size.width(), 640); @@ -272,7 +274,7 @@ TEST_P(FakeVideoCaptureDeviceCommandLineTest, FrameRate) { VideoCaptureParams capture_params; capture_params.requested_format.frame_size.SetSize(1280, 720); capture_params.requested_format.frame_rate = GetParam().fps; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); WaitForCapturedFrame(); EXPECT_EQ(last_format().frame_size.width(), 1280); diff --git a/media/capture/video/file_video_capture_device.cc b/media/capture/video/file_video_capture_device.cc index 5c509f2..0227891 100644 --- a/media/capture/video/file_video_capture_device.cc +++ b/media/capture/video/file_video_capture_device.cc @@ -5,6 +5,7 @@ #include "media/capture/video/file_video_capture_device.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/macros.h" @@ -284,13 +285,13 @@ FileVideoCaptureDevice::GetVideoFileParser( file_parser.reset(new MjpegFileParser(file_path)); } else { LOG(ERROR) << "Unsupported file format."; - return file_parser.Pass(); + return file_parser; } if (!file_parser->Initialize(video_format)) { file_parser.reset(); } - return file_parser.Pass(); + return file_parser; } FileVideoCaptureDevice::FileVideoCaptureDevice(const base::FilePath& file_path) @@ -331,7 +332,7 @@ void FileVideoCaptureDevice::OnAllocateAndStart( scoped_ptr<VideoCaptureDevice::Client> client) { DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); - client_ = client.Pass(); + client_ = std::move(client); DCHECK(!file_parser_); file_parser_ = GetVideoFileParser(file_path_, &capture_format_); diff --git a/media/capture/video/linux/v4l2_capture_delegate.cc b/media/capture/video/linux/v4l2_capture_delegate.cc index 6e821ff..612672b 100644 --- a/media/capture/video/linux/v4l2_capture_delegate.cc +++ b/media/capture/video/linux/v4l2_capture_delegate.cc @@ -8,6 +8,7 @@ #include <sys/fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> +#include <utility> #include "base/bind.h" #include "base/files/file_enumerator.h" @@ -176,7 +177,7 @@ void V4L2CaptureDelegate::AllocateAndStart( scoped_ptr<VideoCaptureDevice::Client> client) { DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); DCHECK(client); - client_ = client.Pass(); + client_ = std::move(client); // Need to open camera with O_RDWR after Linux kernel 3.3. device_fd_.reset(HANDLE_EINTR(open(device_name_.id().c_str(), O_RDWR))); diff --git a/media/capture/video/video_capture_device_factory.cc b/media/capture/video/video_capture_device_factory.cc index 9163e27..9aaa73a 100644 --- a/media/capture/video/video_capture_device_factory.cc +++ b/media/capture/video/video_capture_device_factory.cc @@ -4,6 +4,8 @@ #include "media/capture/video/video_capture_device_factory.h" +#include <utility> + #include "base/command_line.h" #include "build/build_config.h" #include "media/base/media_switches.h" @@ -49,7 +51,7 @@ void VideoCaptureDeviceFactory::EnumerateDeviceNames(const base::Callback< scoped_ptr<VideoCaptureDevice::Names> device_names( new VideoCaptureDevice::Names()); GetDeviceNames(device_names.get()); - callback.Run(device_names.Pass()); + callback.Run(std::move(device_names)); } #if !defined(OS_MACOSX) && !defined(OS_LINUX) && !defined(OS_ANDROID) && \ diff --git a/media/capture/video/video_capture_device_unittest.cc b/media/capture/video/video_capture_device_unittest.cc index 763fa1d..7db16aa 100644 --- a/media/capture/video/video_capture_device_unittest.cc +++ b/media/capture/video/video_capture_device_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/capture/video/video_capture_device.h" + #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -16,7 +19,6 @@ #include "base/threading/thread.h" #include "build/build_config.h" #include "media/base/video_capture_types.h" -#include "media/capture/video/video_capture_device.h" #include "media/capture/video/video_capture_device_factory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -323,7 +325,7 @@ TEST_P(VideoCaptureDeviceTest, CaptureWithSize) { capture_params.requested_format.frame_rate = 30.0f; capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); // Get captured video frames. WaitForCapturedFrame(); EXPECT_EQ(last_format().frame_size.width(), width); @@ -357,7 +359,7 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) { capture_params.requested_format.frame_rate = 35; capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); WaitForCapturedFrame(); device->StopAndDeAllocate(); EXPECT_EQ(last_format().frame_size.width(), input_size.width()); @@ -389,7 +391,7 @@ TEST_F(VideoCaptureDeviceTest, DISABLED_ReAllocateCamera) { capture_params.requested_format.frame_size = resolution; capture_params.requested_format.frame_rate = 30; capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); device->StopAndDeAllocate(); } @@ -403,7 +405,7 @@ TEST_F(VideoCaptureDeviceTest, DISABLED_ReAllocateCamera) { scoped_ptr<VideoCaptureDevice> device( video_capture_device_factory_->Create(names_->front())); - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); WaitForCapturedFrame(); device->StopAndDeAllocate(); device.reset(); @@ -427,7 +429,7 @@ TEST_F(VideoCaptureDeviceTest, DeAllocateCameraWhileRunning) { capture_params.requested_format.frame_size.SetSize(640, 480); capture_params.requested_format.frame_rate = 30; capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); // Get captured video frames. WaitForCapturedFrame(); EXPECT_EQ(last_format().frame_size.width(), 640); @@ -460,7 +462,7 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_CaptureMjpeg) { capture_params.requested_format.frame_size.SetSize(1280, 720); capture_params.requested_format.frame_rate = 30; capture_params.requested_format.pixel_format = PIXEL_FORMAT_MJPEG; - device->AllocateAndStart(capture_params, client_.Pass()); + device->AllocateAndStart(capture_params, std::move(client_)); // Get captured video frames. WaitForCapturedFrame(); // Verify we get MJPEG from the device. Not all devices can capture 1280x720 diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc index e3def4f..ea1f2ac 100644 --- a/media/cast/cast_environment.cc +++ b/media/cast/cast_environment.cc @@ -4,6 +4,8 @@ #include "media/cast/cast_environment.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/logging.h" @@ -21,7 +23,7 @@ CastEnvironment::CastEnvironment( : main_thread_proxy_(main_thread_proxy), audio_thread_proxy_(audio_thread_proxy), video_thread_proxy_(video_thread_proxy), - clock_(clock.Pass()), + clock_(std::move(clock)), logger_(this) {} CastEnvironment::~CastEnvironment() {} diff --git a/media/cast/logging/encoding_event_subscriber_unittest.cc b/media/cast/logging/encoding_event_subscriber_unittest.cc index 0baeee7..6d6dcb3 100644 --- a/media/cast/logging/encoding_event_subscriber_unittest.cc +++ b/media/cast/logging/encoding_event_subscriber_unittest.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/logging/encoding_event_subscriber.h" + #include <stdint.h> +#include <utility> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/test/simple_test_tick_clock.h" #include "base/time/tick_clock.h" #include "media/cast/cast_environment.h" -#include "media/cast/logging/encoding_event_subscriber.h" #include "media/cast/logging/logging_defines.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -35,11 +37,11 @@ class EncodingEventSubscriberTest : public ::testing::Test { EncodingEventSubscriberTest() : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)), + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, + task_runner_, + task_runner_)), first_rtp_timestamp_(0) {} void Init(EventMediaType event_media_type) { @@ -83,7 +85,8 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = i * 100; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); capture_end_event->timestamp = now; @@ -92,7 +95,8 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { capture_end_event->rtp_timestamp = i * 100; capture_end_event->width = width; capture_end_event->height = height; - cast_environment_->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_end_event)); scoped_ptr<FrameEvent> decoded_event(new FrameEvent()); decoded_event->timestamp = now; @@ -100,7 +104,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { decoded_event->media_type = VIDEO_EVENT; decoded_event->rtp_timestamp = i * 100; decoded_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(decoded_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decoded_event)); width += 160; height += 90; @@ -137,7 +141,7 @@ TEST_F(EncodingEventSubscriberTest, PacketEventTruncating) { receive_event->packet_id = i; receive_event->max_packet_id = 10; receive_event->size = 123; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); } GetEventsAndReset(); @@ -158,7 +162,7 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { video_event->media_type = VIDEO_EVENT; video_event->rtp_timestamp = rtp_timestamp; video_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(video_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(video_event)); // This is an AUDIO_EVENT and shouldn't be processed by the subscriber. scoped_ptr<FrameEvent> audio_event(new FrameEvent()); @@ -167,7 +171,7 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { audio_event->media_type = AUDIO_EVENT; audio_event->rtp_timestamp = rtp_timestamp; audio_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(audio_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(audio_event)); GetEventsAndReset(); @@ -195,7 +199,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEvent) { decode_event->media_type = VIDEO_EVENT; decode_event->rtp_timestamp = rtp_timestamp; decode_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); GetEventsAndReset(); @@ -232,7 +236,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = 0; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(delay_ms); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); GetEventsAndReset(); @@ -275,7 +279,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventSize) { encode_event->target_bitrate = target_bitrate; encode_event->encoder_cpu_utilization = encoder_cpu_utilization; encode_event->idealized_bitrate_utilization = idealized_bitrate_utilization; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); GetEventsAndReset(); @@ -314,7 +318,7 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { playout_event->rtp_timestamp = rtp_timestamp1; playout_event->frame_id = 0; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(100); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); @@ -327,7 +331,7 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { encode_event->size = 123; encode_event->encoder_cpu_utilization = 0.44; encode_event->idealized_bitrate_utilization = 0.55; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now3(testing_clock_->NowTicks()); @@ -337,7 +341,7 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { decode_event->media_type = AUDIO_EVENT; decode_event->rtp_timestamp = rtp_timestamp1; decode_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); GetEventsAndReset(); @@ -393,7 +397,7 @@ TEST_F(EncodingEventSubscriberTest, PacketEvent) { receive_event->packet_id = packet_id; receive_event->max_packet_id = 10; receive_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); GetEventsAndReset(); @@ -435,7 +439,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { send_event->packet_id = packet_id; send_event->max_packet_id = 10; send_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); @@ -448,7 +452,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { retransmit_event->packet_id = packet_id; retransmit_event->max_packet_id = 10; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(retransmit_event)); GetEventsAndReset(); @@ -490,7 +494,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { send_event->packet_id = packet_id_1; send_event->max_packet_id = 10; send_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); @@ -503,7 +507,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { retransmit_event->packet_id = packet_id_2; retransmit_event->max_packet_id = 10; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(retransmit_event)); GetEventsAndReset(); @@ -551,7 +555,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { send_event->packet_id = packet_id_1; send_event->max_packet_id = 10; send_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); @@ -564,7 +568,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { retransmit_event->packet_id = packet_id_2; retransmit_event->max_packet_id = 10; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(retransmit_event)); GetEventsAndReset(); @@ -613,7 +617,8 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); capture_end_event->timestamp = now; @@ -622,7 +627,7 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { capture_end_event->rtp_timestamp = rtp_timestamp + 30; capture_end_event->width = 1280; capture_end_event->height = 720; - cast_environment_->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(capture_end_event)); GetEventsAndReset(); @@ -644,7 +649,8 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); GetEventsAndReset(); @@ -661,7 +667,8 @@ TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); // RtpTimestamp has now wrapped around. scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); @@ -671,7 +678,7 @@ TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { capture_end_event->rtp_timestamp = rtp_timestamp + 30; capture_end_event->width = 1280; capture_end_event->height = 720; - cast_environment_->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(capture_end_event)); GetEventsAndReset(); @@ -696,7 +703,7 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp; ack_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(30)); } @@ -721,7 +728,7 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { send_event->packet_id = i; send_event->max_packet_id = kMaxPacketsPerFrame; send_event->size = 123; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(30)); } @@ -752,7 +759,7 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { send_event->packet_id = 0; send_event->max_packet_id = 0; send_event->size = 123; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); task_runner_->Sleep(base::TimeDelta::FromMilliseconds(30)); } diff --git a/media/cast/logging/log_event_dispatcher.cc b/media/cast/logging/log_event_dispatcher.cc index ac0e9ab..428a642 100644 --- a/media/cast/logging/log_event_dispatcher.cc +++ b/media/cast/logging/log_event_dispatcher.cc @@ -5,6 +5,7 @@ #include "media/cast/logging/log_event_dispatcher.h" #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -25,7 +26,7 @@ LogEventDispatcher::~LogEventDispatcher() {} void LogEventDispatcher::DispatchFrameEvent( scoped_ptr<FrameEvent> event) const { if (env_->CurrentlyOn(CastEnvironment::MAIN)) { - impl_->DispatchFrameEvent(event.Pass()); + impl_->DispatchFrameEvent(std::move(event)); } else { env_->PostTask(CastEnvironment::MAIN, FROM_HERE, base::Bind(&LogEventDispatcher::Impl::DispatchFrameEvent, @@ -36,7 +37,7 @@ void LogEventDispatcher::DispatchFrameEvent( void LogEventDispatcher::DispatchPacketEvent( scoped_ptr<PacketEvent> event) const { if (env_->CurrentlyOn(CastEnvironment::MAIN)) { - impl_->DispatchPacketEvent(event.Pass()); + impl_->DispatchPacketEvent(std::move(event)); } else { env_->PostTask(CastEnvironment::MAIN, FROM_HERE, base::Bind(&LogEventDispatcher::Impl::DispatchPacketEvent, @@ -48,7 +49,8 @@ void LogEventDispatcher::DispatchBatchOfEvents( scoped_ptr<std::vector<FrameEvent>> frame_events, scoped_ptr<std::vector<PacketEvent>> packet_events) const { if (env_->CurrentlyOn(CastEnvironment::MAIN)) { - impl_->DispatchBatchOfEvents(frame_events.Pass(), packet_events.Pass()); + impl_->DispatchBatchOfEvents(std::move(frame_events), + std::move(packet_events)); } else { env_->PostTask( CastEnvironment::MAIN, FROM_HERE, diff --git a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc index 7cff1f01..73ddd62 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/logging/receiver_time_offset_estimator_impl.h" + #include <stdint.h> +#include <utility> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -10,7 +13,6 @@ #include "base/time/tick_clock.h" #include "media/cast/cast_environment.h" #include "media/cast/logging/logging_defines.h" -#include "media/cast/logging/receiver_time_offset_estimator_impl.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,11 +24,11 @@ class ReceiverTimeOffsetEstimatorImplTest : public ::testing::Test { ReceiverTimeOffsetEstimatorImplTest() : sender_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(sender_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(sender_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)) { + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(sender_clock_), + task_runner_, + task_runner_, + task_runner_)) { cast_environment_->logger()->Subscribe(&estimator_); } @@ -76,7 +78,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); scoped_ptr<PacketEvent> send_event(new PacketEvent()); send_event->timestamp = sender_clock_->NowTicks(); @@ -87,7 +89,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { send_event->packet_id = 56; send_event->max_packet_id = 78; send_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -98,7 +100,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { ack_sent_event->media_type = VIDEO_EVENT; ack_sent_event->rtp_timestamp = rtp_timestamp; ack_sent_event->frame_id = frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); scoped_ptr<PacketEvent> receive_event(new PacketEvent()); receive_event->timestamp = receiver_clock_.NowTicks(); @@ -109,7 +111,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { receive_event->packet_id = 56; receive_event->max_packet_id = 78; receive_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -120,7 +122,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp; ack_event->frame_id = frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -159,7 +161,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); scoped_ptr<PacketEvent> send_event(new PacketEvent()); send_event->timestamp = sender_clock_->NowTicks(); @@ -170,7 +172,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { send_event->packet_id = 56; send_event->max_packet_id = 78; send_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -185,7 +187,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp; ack_event->frame_id = frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -198,7 +200,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { receive_event->packet_id = 56; receive_event->max_packet_id = 78; receive_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); scoped_ptr<FrameEvent> ack_sent_event(new FrameEvent()); ack_sent_event->timestamp = event_b_time; @@ -206,7 +208,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { ack_sent_event->media_type = VIDEO_EVENT; ack_sent_event->rtp_timestamp = rtp_timestamp; ack_sent_event->frame_id = frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -249,7 +251,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); scoped_ptr<PacketEvent> send_event(new PacketEvent()); send_event->timestamp = sender_clock_->NowTicks(); @@ -260,7 +262,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { send_event->packet_id = 56; send_event->max_packet_id = 78; send_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); encode_event.reset(new FrameEvent()); @@ -274,7 +276,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); send_event.reset(new PacketEvent()); send_event->timestamp = sender_clock_->NowTicks(); @@ -285,7 +287,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { send_event->packet_id = 56; send_event->max_packet_id = 78; send_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); scoped_ptr<FrameEvent> ack_sent_event(new FrameEvent()); ack_sent_event->timestamp = receiver_clock_.NowTicks(); @@ -293,7 +295,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_sent_event->media_type = VIDEO_EVENT; ack_sent_event->rtp_timestamp = rtp_timestamp_a; ack_sent_event->frame_id = frame_id_a; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); @@ -306,7 +308,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { receive_event->packet_id = 56; receive_event->max_packet_id = 78; receive_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); ack_sent_event.reset(new FrameEvent()); ack_sent_event->timestamp = receiver_clock_.NowTicks(); @@ -314,7 +316,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_sent_event->media_type = VIDEO_EVENT; ack_sent_event->rtp_timestamp = rtp_timestamp_b; ack_sent_event->frame_id = frame_id_b; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(5)); scoped_ptr<FrameEvent> ack_event(new FrameEvent()); @@ -323,7 +325,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp_b; ack_event->frame_id = frame_id_b; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(5)); ack_event.reset(new FrameEvent()); @@ -332,7 +334,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp_a; ack_event->frame_id = frame_id_a; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(17)); encode_event.reset(new FrameEvent()); @@ -346,7 +348,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); send_event.reset(new PacketEvent()); send_event->timestamp = sender_clock_->NowTicks(); @@ -357,7 +359,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { send_event->packet_id = 56; send_event->max_packet_id = 78; send_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(3)); receive_event.reset(new PacketEvent()); @@ -369,7 +371,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { receive_event->packet_id = 56; receive_event->max_packet_id = 78; receive_event->size = 1500; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); ack_sent_event.reset(new FrameEvent()); ack_sent_event->timestamp = receiver_clock_.NowTicks(); @@ -377,7 +379,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_sent_event->media_type = VIDEO_EVENT; ack_sent_event->rtp_timestamp = rtp_timestamp_c; ack_sent_event->frame_id = frame_id_c; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(30)); ack_event.reset(new FrameEvent()); @@ -386,7 +388,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { ack_event->media_type = VIDEO_EVENT; ack_event->rtp_timestamp = rtp_timestamp_c; ack_event->frame_id = frame_id_c; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); int64_t lower_bound_ms = lower_bound.InMilliseconds(); diff --git a/media/cast/logging/simple_event_subscriber_unittest.cc b/media/cast/logging/simple_event_subscriber_unittest.cc index 92b6c6e..f1f5f14 100644 --- a/media/cast/logging/simple_event_subscriber_unittest.cc +++ b/media/cast/logging/simple_event_subscriber_unittest.cc @@ -2,13 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/logging/simple_event_subscriber.h" + +#include <utility> + #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/test/simple_test_tick_clock.h" #include "base/time/tick_clock.h" #include "media/cast/cast_environment.h" #include "media/cast/logging/logging_defines.h" -#include "media/cast/logging/simple_event_subscriber.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,11 +23,11 @@ class SimpleEventSubscriberTest : public ::testing::Test { SimpleEventSubscriberTest() : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)) { + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, + task_runner_, + task_runner_)) { cast_environment_->logger()->Subscribe(&event_subscriber_); } @@ -51,7 +54,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { encode_event->target_bitrate = 128u; encode_event->encoder_cpu_utilization = 0.01; encode_event->idealized_bitrate_utilization = 0.02; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); scoped_ptr<FrameEvent> playout_event(new FrameEvent()); playout_event->timestamp = testing_clock_->NowTicks(); @@ -60,7 +63,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { playout_event->rtp_timestamp = 100u; playout_event->frame_id = 0u; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(100); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); scoped_ptr<FrameEvent> decode_event(new FrameEvent()); decode_event->timestamp = testing_clock_->NowTicks(); @@ -68,7 +71,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { decode_event->media_type = AUDIO_EVENT; decode_event->rtp_timestamp = 200u; decode_event->frame_id = 0u; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); // Log some packet events. scoped_ptr<PacketEvent> receive_event(new PacketEvent()); @@ -80,7 +83,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { receive_event->packet_id = 1u; receive_event->max_packet_id = 5u; receive_event->size = 100u; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); receive_event.reset(new PacketEvent()); receive_event->timestamp = testing_clock_->NowTicks(); @@ -91,7 +94,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { receive_event->packet_id = 1u; receive_event->max_packet_id = 10u; receive_event->size = 1024u; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); std::vector<FrameEvent> frame_events; event_subscriber_.GetFrameEventsAndReset(&frame_events); diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index ff5e6f8..61cd4ae 100644 --- a/media/cast/logging/stats_event_subscriber.cc +++ b/media/cast/logging/stats_event_subscriber.cc @@ -92,7 +92,7 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const { buckets_.back()); histo->Append(bucket.release()); } - return histo.Pass(); + return histo; } StatsEventSubscriber::StatsEventSubscriber( @@ -247,7 +247,7 @@ scoped_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const { ret->Set(event_media_type_ == AUDIO_EVENT ? "audio" : "video", stats.release()); - return ret.Pass(); + return ret; } void StatsEventSubscriber::Reset() { diff --git a/media/cast/logging/stats_event_subscriber_unittest.cc b/media/cast/logging/stats_event_subscriber_unittest.cc index 6416ae6..7acfddd 100644 --- a/media/cast/logging/stats_event_subscriber_unittest.cc +++ b/media/cast/logging/stats_event_subscriber_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/logging/stats_event_subscriber.h" + #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -13,7 +16,6 @@ #include "base/values.h" #include "media/cast/cast_environment.h" #include "media/cast/logging/logging_defines.h" -#include "media/cast/logging/stats_event_subscriber.h" #include "media/cast/test/fake_receiver_time_offset_estimator.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -30,11 +32,11 @@ class StatsEventSubscriberTest : public ::testing::Test { StatsEventSubscriberTest() : sender_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(sender_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(sender_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)), + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(sender_clock_), + task_runner_, + task_runner_, + task_runner_)), fake_offset_estimator_( base::TimeDelta::FromSeconds(kReceiverOffsetSecs)) { receiver_clock_.Advance(base::TimeDelta::FromSeconds(kReceiverOffsetSecs)); @@ -85,7 +87,8 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); AdvanceClocks(base::TimeDelta::FromMicroseconds(10)); scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); @@ -93,7 +96,8 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { capture_end_event->type = FRAME_CAPTURE_END; capture_end_event->media_type = VIDEO_EVENT; capture_end_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_end_event)); if (i % 2 == 0) { AdvanceClocks(base::TimeDelta::FromMicroseconds(10)); @@ -108,7 +112,7 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); } else if (i < extra_frames) { dropped_frames++; } @@ -172,7 +176,7 @@ TEST_F(StatsEventSubscriberTest, Encode) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); last_event_time = sender_clock_->NowTicks(); AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); @@ -229,7 +233,7 @@ TEST_F(StatsEventSubscriberTest, Decode) { decode_event->media_type = VIDEO_EVENT; decode_event->rtp_timestamp = rtp_timestamp; decode_event->frame_id = frame_id; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); rtp_timestamp += 90; @@ -269,7 +273,7 @@ TEST_F(StatsEventSubscriberTest, PlayoutDelay) { playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = frame_id; playout_event->delay_delta = delay; - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); rtp_timestamp += 90; @@ -299,7 +303,8 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); int latency_micros = 100000 + base::RandInt(-5000, 50000); base::TimeDelta latency = base::TimeDelta::FromMicroseconds(latency_micros); @@ -316,7 +321,7 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = frame_id; playout_event->delay_delta = delay; - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); rtp_timestamp += 90; frame_id++; @@ -358,7 +363,7 @@ TEST_F(StatsEventSubscriberTest, Packets) { encode_event->media_type = VIDEO_EVENT; encode_event->rtp_timestamp = rtp_timestamp; encode_event->frame_id = 0; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); // Every 2nd packet will be retransmitted once. // Every 4th packet will be retransmitted twice. @@ -376,7 +381,7 @@ TEST_F(StatsEventSubscriberTest, Packets) { send_event->packet_id = i; send_event->max_packet_id = num_packets - 1; send_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); num_packets_transmitted++; total_queueing_latency += sender_clock_->NowTicks() - sender_encoded_time; @@ -407,7 +412,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { retransmit_event->packet_id = i; retransmit_event->max_packet_id = num_packets - 1; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent( + std::move(retransmit_event)); retransmit_total_size += size; num_packets_transmitted++; @@ -426,7 +432,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { retransmit_event->packet_id = i; retransmit_event->max_packet_id = num_packets - 1; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent( + std::move(retransmit_event)); retransmit_total_size += size; num_packets_transmitted++; @@ -445,7 +452,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { retransmit_event->packet_id = i; retransmit_event->max_packet_id = num_packets - 1; retransmit_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(retransmit_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent( + std::move(retransmit_event)); scoped_ptr<PacketEvent> reject_event(new PacketEvent()); reject_event->timestamp = receiver_clock_.NowTicks(); @@ -456,7 +464,7 @@ TEST_F(StatsEventSubscriberTest, Packets) { reject_event->packet_id = i; reject_event->max_packet_id = num_packets - 1; reject_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(reject_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(reject_event)); retransmit_total_size += size; num_packets_transmitted++; @@ -473,7 +481,7 @@ TEST_F(StatsEventSubscriberTest, Packets) { receive_event->packet_id = i; receive_event->max_packet_id = num_packets - 1; receive_event->size = size; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); num_packets_received++; } @@ -574,7 +582,8 @@ TEST_F(StatsEventSubscriberTest, Histograms) { capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; capture_begin_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_begin_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); @@ -582,7 +591,8 @@ TEST_F(StatsEventSubscriberTest, Histograms) { capture_end_event->type = FRAME_CAPTURE_END; capture_end_event->media_type = VIDEO_EVENT; capture_end_event->rtp_timestamp = rtp_timestamp; - cast_environment_->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent( + std::move(capture_end_event)); AdvanceClocks(base::TimeDelta::FromMilliseconds(15)); scoped_ptr<FrameEvent> encode_event(new FrameEvent()); @@ -596,7 +606,7 @@ TEST_F(StatsEventSubscriberTest, Histograms) { encode_event->target_bitrate = 5678; encode_event->encoder_cpu_utilization = 9.10; encode_event->idealized_bitrate_utilization = 11.12; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); } // Send 3 packets for the last frame. @@ -612,7 +622,7 @@ TEST_F(StatsEventSubscriberTest, Histograms) { send_event->packet_id = i; send_event->max_packet_id = 2; send_event->size = 123; - cast_environment_->logger()->DispatchPacketEvent(send_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(send_event)); } // Receive 3 packets for the last frame. @@ -629,7 +639,7 @@ TEST_F(StatsEventSubscriberTest, Histograms) { receive_event->packet_id = i; receive_event->max_packet_id = 2; receive_event->size = 123; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); } scoped_ptr<FrameEvent> playout_event(new FrameEvent()); @@ -639,7 +649,7 @@ TEST_F(StatsEventSubscriberTest, Histograms) { playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = frame_id; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(100); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); StatsEventSubscriber::SimpleHistogram* histogram; scoped_ptr<base::ListValue> values; @@ -647,19 +657,19 @@ TEST_F(StatsEventSubscriberTest, Histograms) { histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::CAPTURE_LATENCY_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "10-14", 10)); histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::ENCODE_TIME_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "15-19", 10)); histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::QUEUEING_LATENCY_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "200-219", 1)); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "300-319", 1)); @@ -667,7 +677,7 @@ TEST_F(StatsEventSubscriberTest, Histograms) { histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::NETWORK_LATENCY_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "200-219", 1)); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "300-319", 1)); @@ -675,13 +685,13 @@ TEST_F(StatsEventSubscriberTest, Histograms) { histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::PACKET_LATENCY_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "400-419", 3)); histogram = subscriber_->GetHistogramForTesting( StatsEventSubscriber::LATE_FRAME_MS_HISTO); ASSERT_TRUE(histogram); - values = histogram->GetHistogram().Pass(); + values = histogram->GetHistogram(); EXPECT_TRUE(CheckHistogramHasValue(values.get(), "100-119", 1)); } diff --git a/media/cast/net/cast_transport_sender_impl.cc b/media/cast/net/cast_transport_sender_impl.cc index fb32d50..48652b8b 100644 --- a/media/cast/net/cast_transport_sender_impl.cc +++ b/media/cast/net/cast_transport_sender_impl.cc @@ -5,6 +5,7 @@ #include "media/cast/net/cast_transport_sender_impl.h" #include <stddef.h> +#include <utility> #include "base/single_thread_task_runner.h" #include "base/values.h" @@ -66,18 +67,10 @@ scoped_ptr<CastTransportSender> CastTransportSender::Create( base::TimeDelta raw_events_callback_interval, const PacketReceiverCallback& packet_callback, const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner) { - return scoped_ptr<CastTransportSender>( - new CastTransportSenderImpl(net_log, - clock, - local_end_point, - remote_end_point, - options.Pass(), - status_callback, - raw_events_callback, - raw_events_callback_interval, - transport_task_runner.get(), - packet_callback, - NULL)); + return scoped_ptr<CastTransportSender>(new CastTransportSenderImpl( + net_log, clock, local_end_point, remote_end_point, std::move(options), + status_callback, raw_events_callback, raw_events_callback_interval, + transport_task_runner.get(), packet_callback, NULL)); } PacketReceiverCallback CastTransportSender::PacketReceiverForTesting() { @@ -349,7 +342,7 @@ void CastTransportSenderImpl::SendRawEvents() { scoped_ptr<std::vector<PacketEvent>> packet_events( new std::vector<PacketEvent>()); packet_events->swap(recent_packet_events_); - raw_events_callback_.Run(frame_events.Pass(), packet_events.Pass()); + raw_events_callback_.Run(std::move(frame_events), std::move(packet_events)); } transport_task_runner_->PostDelayedTask( @@ -386,7 +379,7 @@ bool CastTransportSenderImpl::OnReceivedPacket(scoped_ptr<Packet> packet) { VLOG(1) << "Stale packet received."; return false; } - packet_callback_.Run(packet.Pass()); + packet_callback_.Run(std::move(packet)); return true; } diff --git a/media/cast/net/cast_transport_sender_impl_unittest.cc b/media/cast/net/cast_transport_sender_impl_unittest.cc index 685818c..8c1a9b2 100644 --- a/media/cast/net/cast_transport_sender_impl_unittest.cc +++ b/media/cast/net/cast_transport_sender_impl_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/net/cast_transport_sender_impl.h" + #include <gtest/gtest.h> #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -12,7 +15,6 @@ #include "base/test/simple_test_tick_clock.h" #include "base/values.h" #include "media/cast/net/cast_transport_config.h" -#include "media/cast/net/cast_transport_sender_impl.h" #include "media/cast/net/rtcp/rtcp.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -98,18 +100,11 @@ class CastTransportSenderImplTest : public ::testing::Test { options->SetBoolean("media_streaming_mode", true); options->SetInteger("pacer_target_burst_size", 20); options->SetInteger("pacer_max_burst_size", 100); - transport_sender_.reset( - new CastTransportSenderImpl(NULL, - &testing_clock_, - net::IPEndPoint(), - net::IPEndPoint(), - options.Pass(), - base::Bind(&UpdateCastTransportStatus), - BulkRawEventsCallback(), - base::TimeDelta(), - task_runner_, - PacketReceiverCallback(), - &transport_)); + transport_sender_.reset(new CastTransportSenderImpl( + NULL, &testing_clock_, net::IPEndPoint(), net::IPEndPoint(), + std::move(options), base::Bind(&UpdateCastTransportStatus), + BulkRawEventsCallback(), base::TimeDelta(), task_runner_, + PacketReceiverCallback(), &transport_)); task_runner_->RunTasks(); } diff --git a/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc b/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc index f725714..c09a66f 100644 --- a/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc +++ b/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" + #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -11,7 +14,6 @@ #include "base/time/tick_clock.h" #include "media/cast/cast_environment.h" #include "media/cast/logging/logging_defines.h" -#include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" @@ -30,11 +32,11 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { ReceiverRtcpEventSubscriberTest() : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)) {} + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, + task_runner_, + task_runner_)) {} ~ReceiverRtcpEventSubscriberTest() override {} @@ -60,7 +62,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { playout_event->rtp_timestamp = 100u; playout_event->frame_id = 2u; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(kDelayMs); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); scoped_ptr<FrameEvent> decode_event(new FrameEvent()); decode_event->timestamp = testing_clock_->NowTicks(); @@ -68,7 +70,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { decode_event->media_type = VIDEO_EVENT; decode_event->rtp_timestamp = 200u; decode_event->frame_id = 1u; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); scoped_ptr<PacketEvent> receive_event(new PacketEvent()); receive_event->timestamp = testing_clock_->NowTicks(); @@ -79,7 +81,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { receive_event->packet_id = 1u; receive_event->max_packet_id = 10u; receive_event->size = 1024u; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); // Audio events playout_event.reset(new FrameEvent()); @@ -89,7 +91,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { playout_event->rtp_timestamp = 300u; playout_event->frame_id = 4u; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(kDelayMs); - cast_environment_->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); decode_event.reset(new FrameEvent()); decode_event->timestamp = testing_clock_->NowTicks(); @@ -97,7 +99,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { decode_event->media_type = AUDIO_EVENT; decode_event->rtp_timestamp = 400u; decode_event->frame_id = 3u; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); receive_event.reset(new PacketEvent()); receive_event->timestamp = testing_clock_->NowTicks(); @@ -108,7 +110,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { receive_event->packet_id = 1u; receive_event->max_packet_id = 10u; receive_event->size = 128u; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); // Unrelated events scoped_ptr<FrameEvent> encode_event(new FrameEvent()); @@ -117,7 +119,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { encode_event->media_type = VIDEO_EVENT; encode_event->rtp_timestamp = 100u; encode_event->frame_id = 1u; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); encode_event.reset(new FrameEvent()); encode_event->timestamp = testing_clock_->NowTicks(); @@ -125,7 +127,7 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { encode_event->media_type = AUDIO_EVENT; encode_event->rtp_timestamp = 100u; encode_event->frame_id = 1u; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); } base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. @@ -162,7 +164,7 @@ TEST_F(ReceiverRtcpEventSubscriberTest, DropEventsWhenSizeExceeded) { decode_event->media_type = VIDEO_EVENT; decode_event->rtp_timestamp = i * 10; decode_event->frame_id = i; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); } ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; diff --git a/media/cast/net/rtcp/rtcp_builder_unittest.cc b/media/cast/net/rtcp/rtcp_builder_unittest.cc index b430e71..1c44268 100644 --- a/media/cast/net/rtcp/rtcp_builder_unittest.cc +++ b/media/cast/net/rtcp/rtcp_builder_unittest.cc @@ -78,10 +78,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReport) { RtcpReportBlock report_block = GetReportBlock(); - ExpectPacketEQ( - p2.GetPacket().Pass(), - rtcp_builder_->BuildRtcpFromReceiver( - &report_block, NULL, NULL, NULL, kDefaultDelay)); + ExpectPacketEQ(p2.GetPacket(), + rtcp_builder_->BuildRtcpFromReceiver(&report_block, NULL, NULL, + NULL, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtr) { @@ -98,13 +97,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtr) { rrtr.ntp_seconds = kNtpHigh; rrtr.ntp_fraction = kNtpLow; - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - &rrtr, - NULL, - NULL, - kDefaultDelay)); + &report_block, &rrtr, NULL, NULL, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithCast) { @@ -127,13 +122,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithCast) { cast_message.missing_frames_and_packets[kFrameIdWithLostPackets] = missing_packets; - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - NULL, - &cast_message, - NULL, - kDefaultDelay)); + &report_block, NULL, &cast_message, NULL, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtraAndCastMessage) { @@ -161,13 +152,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtraAndCastMessage) { cast_message.missing_frames_and_packets[kFrameIdWithLostPackets] = missing_packets; - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - &rrtr, - &cast_message, - NULL, - kDefaultDelay)); + &report_block, &rrtr, &cast_message, NULL, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtrCastMessageAndLog) { @@ -201,13 +188,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtrCastMessageAndLog) { ReceiverRtcpEventSubscriber event_subscriber(500, VIDEO_EVENT); ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; - ExpectPacketEQ(p.GetPacket().Pass(), - rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - &rrtr, - &cast_message, - &rtcp_events, - kDefaultDelay)); + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( + &report_block, &rrtr, &cast_message, + &rtcp_events, kDefaultDelay)); base::SimpleTestTickClock testing_clock; testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs)); @@ -235,14 +218,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtrCastMessageAndLog) { event_subscriber.GetRtcpEventsWithRedundancy(&rtcp_events); EXPECT_EQ(2u, rtcp_events.size()); - ExpectPacketEQ( - p.GetPacket().Pass(), - rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - &rrtr, - &cast_message, - &rtcp_events, - kDefaultDelay)); + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( + &report_block, &rrtr, &cast_message, + &rtcp_events, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOversizedFrameLog) { @@ -289,13 +267,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOversizedFrameLog) { ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; event_subscriber.GetRtcpEventsWithRedundancy(&rtcp_events); - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - NULL, - NULL, - &rtcp_events, - kDefaultDelay)); + &report_block, NULL, NULL, &rtcp_events, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithTooManyLogFrames) { @@ -335,13 +309,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithTooManyLogFrames) { ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; event_subscriber.GetRtcpEventsWithRedundancy(&rtcp_events); - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - NULL, - NULL, - &rtcp_events, - kDefaultDelay)); + &report_block, NULL, NULL, &rtcp_events, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOldLogFrames) { @@ -382,13 +352,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOldLogFrames) { ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; event_subscriber.GetRtcpEventsWithRedundancy(&rtcp_events); - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - NULL, - NULL, - &rtcp_events, - kDefaultDelay)); + &report_block, NULL, NULL, &rtcp_events, kDefaultDelay)); } TEST_F(RtcpBuilderTest, RtcpReceiverReportRedundancy) { @@ -430,13 +396,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportRedundancy) { ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; event_subscriber.GetRtcpEventsWithRedundancy(&rtcp_events); - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromReceiver( - &report_block, - NULL, - NULL, - &rtcp_events, - kDefaultDelay)); + &report_block, NULL, NULL, &rtcp_events, kDefaultDelay)); testing_clock.Advance( base::TimeDelta::FromMilliseconds(kTimeBetweenEventsMs)); @@ -456,7 +418,7 @@ TEST_F(RtcpBuilderTest, RtcpSenderReport) { TestRtcpPacketBuilder p; p.AddSr(kSendingSsrc, 0); - ExpectPacketEQ(p.GetPacket().Pass(), + ExpectPacketEQ(p.GetPacket(), rtcp_builder_->BuildRtcpFromSender(sender_info)); } diff --git a/media/cast/net/udp_transport.cc b/media/cast/net/udp_transport.cc index 316d4ff..97ec7f4 100644 --- a/media/cast/net/udp_transport.cc +++ b/media/cast/net/udp_transport.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <string> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -182,7 +183,7 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) { VLOG(1) << "Setting remote address from first received packet: " << remote_addr_.ToString(); next_packet_->resize(length_or_status); - if (!packet_receiver_.Run(next_packet_.Pass())) { + if (!packet_receiver_.Run(std::move(next_packet_))) { VLOG(1) << "Packet was not valid, resetting remote address."; remote_addr_ = net::IPEndPoint(); } @@ -191,7 +192,7 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) { << recv_addr_.ToString() << "."; } else { next_packet_->resize(length_or_status); - packet_receiver_.Run(next_packet_.Pass()); + packet_receiver_.Run(std::move(next_packet_)); } length_or_status = net::ERR_IO_PENDING; } diff --git a/media/cast/receiver/audio_decoder.cc b/media/cast/receiver/audio_decoder.cc index be3f57c..67f8679 100644 --- a/media/cast/receiver/audio_decoder.cc +++ b/media/cast/receiver/audio_decoder.cc @@ -5,6 +5,7 @@ #include "media/cast/receiver/audio_decoder.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -69,7 +70,7 @@ class AudioDecoder::ImplBase event->media_type = AUDIO_EVENT; event->rtp_timestamp = encoded_frame->rtp_timestamp; event->frame_id = encoded_frame->frame_id; - cast_environment_->logger()->DispatchFrameEvent(event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(event)); cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, @@ -141,11 +142,11 @@ class AudioDecoder::OpusImpl : public AudioDecoder::ImplBase { const opus_int32 num_samples_decoded = opus_decode_float( opus_decoder_, data, len, buffer_.get(), max_samples_per_frame_, 0); if (num_samples_decoded <= 0) - return audio_bus.Pass(); // Decode error. + return audio_bus; // Decode error. // Copy interleaved samples from |buffer_| into a new AudioBus (where // samples are stored in planar format, for each channel). - audio_bus = AudioBus::Create(num_channels_, num_samples_decoded).Pass(); + audio_bus = AudioBus::Create(num_channels_, num_samples_decoded); // TODO(miu): This should be moved into AudioBus::FromInterleaved(). for (int ch = 0; ch < num_channels_; ++ch) { const float* src = buffer_.get() + ch; @@ -154,7 +155,7 @@ class AudioDecoder::OpusImpl : public AudioDecoder::ImplBase { for (; src < src_end; src += num_channels_, ++dest) *dest = *src; } - return audio_bus.Pass(); + return audio_bus; } const scoped_ptr<uint8_t[]> decoder_memory_; @@ -191,7 +192,7 @@ class AudioDecoder::Pcm16Impl : public AudioDecoder::ImplBase { scoped_ptr<AudioBus> audio_bus; const int num_samples = len / sizeof(int16_t) / num_channels_; if (num_samples <= 0) - return audio_bus.Pass(); + return audio_bus; int16_t* const pcm_data = reinterpret_cast<int16_t*>(data); #if defined(ARCH_CPU_LITTLE_ENDIAN) @@ -200,9 +201,9 @@ class AudioDecoder::Pcm16Impl : public AudioDecoder::ImplBase { for (int i = 0; i < num_elements; ++i) pcm_data[i] = static_cast<int16_t>(base::NetToHost16(pcm_data[i])); #endif - audio_bus = AudioBus::Create(num_channels_, num_samples).Pass(); + audio_bus = AudioBus::Create(num_channels_, num_samples); audio_bus->FromInterleaved(pcm_data, num_samples, sizeof(int16_t)); - return audio_bus.Pass(); + return audio_bus; } DISALLOW_COPY_AND_ASSIGN(Pcm16Impl); diff --git a/media/cast/receiver/audio_decoder_unittest.cc b/media/cast/receiver/audio_decoder_unittest.cc index 74369b7..afd1e8f 100644 --- a/media/cast/receiver/audio_decoder_unittest.cc +++ b/media/cast/receiver/audio_decoder_unittest.cc @@ -90,7 +90,7 @@ class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { last_frame_id_ = encoded_frame->frame_id; const scoped_ptr<AudioBus> audio_bus( - audio_bus_factory_->NextAudioBus(duration).Pass()); + audio_bus_factory_->NextAudioBus(duration)); // Encode |audio_bus| into |encoded_frame->data|. const int num_elements = audio_bus->channels() * audio_bus->frames(); diff --git a/media/cast/receiver/cast_receiver_impl.cc b/media/cast/receiver/cast_receiver_impl.cc index d19479f..076bd26 100644 --- a/media/cast/receiver/cast_receiver_impl.cc +++ b/media/cast/receiver/cast_receiver_impl.cc @@ -5,6 +5,7 @@ #include "media/cast/receiver/cast_receiver_impl.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -129,13 +130,9 @@ void CastReceiverImpl::DecodeEncodedAudioFrame( const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; const base::TimeTicks playout_time = encoded_frame->reference_time; audio_decoder_->DecodeFrame( - encoded_frame.Pass(), - base::Bind(&CastReceiverImpl::EmitDecodedAudioFrame, - cast_environment_, - callback, - frame_id, - rtp_timestamp, - playout_time)); + std::move(encoded_frame), + base::Bind(&CastReceiverImpl::EmitDecodedAudioFrame, cast_environment_, + callback, frame_id, rtp_timestamp, playout_time)); } void CastReceiverImpl::DecodeEncodedVideoFrame( @@ -161,13 +158,9 @@ void CastReceiverImpl::DecodeEncodedVideoFrame( const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; const base::TimeTicks playout_time = encoded_frame->reference_time; video_decoder_->DecodeFrame( - encoded_frame.Pass(), - base::Bind(&CastReceiverImpl::EmitDecodedVideoFrame, - cast_environment_, - callback, - frame_id, - rtp_timestamp, - playout_time)); + std::move(encoded_frame), + base::Bind(&CastReceiverImpl::EmitDecodedVideoFrame, cast_environment_, + callback, frame_id, rtp_timestamp, playout_time)); } // static @@ -191,10 +184,10 @@ void CastReceiverImpl::EmitDecodedAudioFrame( playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = frame_id; playout_event->delay_delta = playout_time - playout_event->timestamp; - cast_environment->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment->logger()->DispatchFrameEvent(std::move(playout_event)); } - callback.Run(audio_bus.Pass(), playout_time, is_continuous); + callback.Run(std::move(audio_bus), playout_time, is_continuous); } // static @@ -218,7 +211,7 @@ void CastReceiverImpl::EmitDecodedVideoFrame( playout_event->rtp_timestamp = rtp_timestamp; playout_event->frame_id = frame_id; playout_event->delay_delta = playout_time - playout_event->timestamp; - cast_environment->logger()->DispatchFrameEvent(playout_event.Pass()); + cast_environment->logger()->DispatchFrameEvent(std::move(playout_event)); // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc TRACE_EVENT_INSTANT1( diff --git a/media/cast/receiver/frame_receiver.cc b/media/cast/receiver/frame_receiver.cc index 303a718..3c92be1 100644 --- a/media/cast/receiver/frame_receiver.cc +++ b/media/cast/receiver/frame_receiver.cc @@ -5,6 +5,7 @@ #include "media/cast/receiver/frame_receiver.h" #include <algorithm> +#include <utility> #include "base/big_endian.h" #include "base/bind.h" @@ -123,7 +124,7 @@ void FrameReceiver::ProcessParsedPacket(const RtpCastHeader& rtp_header, receive_event->packet_id = rtp_header.packet_id; receive_event->max_packet_id = rtp_header.max_packet_id; receive_event->size = payload_size; - cast_environment_->logger()->DispatchPacketEvent(receive_event.Pass()); + cast_environment_->logger()->DispatchPacketEvent(std::move(receive_event)); bool duplicate = false; const bool complete = @@ -182,7 +183,7 @@ void FrameReceiver::CastFeedback(const RtcpCastMessage& cast_message) { ack_sent_event->media_type = event_media_type_; ack_sent_event->rtp_timestamp = rtp_timestamp; ack_sent_event->frame_id = cast_message.ack_frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_sent_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_sent_event)); ReceiverRtcpEventSubscriber::RtcpEvents rtcp_events; event_subscriber_.GetRtcpEventsWithRedundancy(&rtcp_events); @@ -293,7 +294,7 @@ void FrameReceiver::EmitOneFrame(const ReceiveEncodedFrameCallback& callback, scoped_ptr<EncodedFrame> encoded_frame) const { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); if (!callback.is_null()) - callback.Run(encoded_frame.Pass()); + callback.Run(std::move(encoded_frame)); } base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const { diff --git a/media/cast/receiver/frame_receiver_unittest.cc b/media/cast/receiver/frame_receiver_unittest.cc index 5db3ec9..59451c4 100644 --- a/media/cast/receiver/frame_receiver_unittest.cc +++ b/media/cast/receiver/frame_receiver_unittest.cc @@ -6,7 +6,6 @@ #include <stdint.h> #include <deque> -#include <utility> #include "base/bind.h" #include "base/macros.h" @@ -76,10 +75,8 @@ class FrameReceiverTest : public ::testing::Test { task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); cast_environment_ = - new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_); + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, task_runner_, task_runner_); } ~FrameReceiverTest() override {} @@ -132,7 +129,7 @@ class FrameReceiverTest : public ::testing::Test { TestRtcpPacketBuilder rtcp_packet; rtcp_packet.AddSrWithNtp(config_.sender_ssrc, ntp_seconds, ntp_fraction, static_cast<uint32_t>(rtp_timestamp)); - ASSERT_TRUE(receiver_->ProcessPacket(rtcp_packet.GetPacket().Pass())); + ASSERT_TRUE(receiver_->ProcessPacket(rtcp_packet.GetPacket())); } FrameReceiverConfig config_; @@ -160,7 +157,7 @@ TEST_F(FrameReceiverTest, RejectsUnparsablePackets) { cast_environment_->logger()->Subscribe(&event_subscriber); const bool success = receiver_->ProcessPacket( - scoped_ptr<Packet>(new Packet(kPacketSize, 0xff)).Pass()); + scoped_ptr<Packet>(new Packet(kPacketSize, 0xff))); EXPECT_FALSE(success); // Confirm no log events. diff --git a/media/cast/receiver/video_decoder.cc b/media/cast/receiver/video_decoder.cc index c875160..ef512c4 100644 --- a/media/cast/receiver/video_decoder.cc +++ b/media/cast/receiver/video_decoder.cc @@ -5,6 +5,7 @@ #include "media/cast/receiver/video_decoder.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -72,7 +73,7 @@ class VideoDecoder::ImplBase decode_event->media_type = VIDEO_EVENT; decode_event->rtp_timestamp = encoded_frame->rtp_timestamp; decode_event->frame_id = encoded_frame->frame_id; - cast_environment_->logger()->DispatchFrameEvent(decode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); cast_environment_->PostTask( CastEnvironment::MAIN, diff --git a/media/cast/sender/audio_encoder_unittest.cc b/media/cast/sender/audio_encoder_unittest.cc index 6bdffe6..388192b 100644 --- a/media/cast/sender/audio_encoder_unittest.cc +++ b/media/cast/sender/audio_encoder_unittest.cc @@ -110,10 +110,8 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> { void SetUp() final { task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); cast_environment_ = - new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_); + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, task_runner_, task_runner_); } virtual ~AudioEncoderTest() {} diff --git a/media/cast/sender/audio_sender.cc b/media/cast/sender/audio_sender.cc index be2fc39..9af7791 100644 --- a/media/cast/sender/audio_sender.cc +++ b/media/cast/sender/audio_sender.cc @@ -4,6 +4,8 @@ #include "media/cast/sender/audio_sender.h" +#include <utility> + #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -90,7 +92,7 @@ void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus, samples_in_encoder_ += audio_bus->frames(); - audio_encoder_->InsertAudio(audio_bus.Pass(), recorded_time); + audio_encoder_->InsertAudio(std::move(audio_bus), recorded_time); } int AudioSender::GetNumberOfFramesInEncoder() const { @@ -114,7 +116,7 @@ void AudioSender::OnEncodedAudioFrame( samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; DCHECK_GE(samples_in_encoder_, 0); - SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); + SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); } } // namespace cast diff --git a/media/cast/sender/audio_sender_unittest.cc b/media/cast/sender/audio_sender_unittest.cc index 21fd266..6819928 100644 --- a/media/cast/sender/audio_sender_unittest.cc +++ b/media/cast/sender/audio_sender_unittest.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/sender/audio_sender.h" + #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -16,7 +19,6 @@ #include "media/cast/constants.h" #include "media/cast/net/cast_transport_config.h" #include "media/cast/net/cast_transport_sender_impl.h" -#include "media/cast/sender/audio_sender.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "media/cast/test/utility/audio_utility.h" #include "testing/gtest/include/gtest/gtest.h" @@ -75,10 +77,8 @@ class AudioSenderTest : public ::testing::Test { testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); cast_environment_ = - new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_); + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, task_runner_, task_runner_); audio_config_.codec = CODEC_AUDIO_OPUS; audio_config_.use_external_encoder = false; audio_config_.frequency = kDefaultAudioSamplingRate; @@ -133,7 +133,7 @@ TEST_F(AudioSenderTest, Encode20ms) { TestAudioBusFactory::kMiddleANoteFreq, 0.5f).NextAudioBus(kDuration)); - audio_sender_->InsertAudio(bus.Pass(), testing_clock_->NowTicks()); + audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks()); task_runner_->RunTasks(); EXPECT_LE(1, transport_.number_of_rtp_packets()); EXPECT_LE(1, transport_.number_of_rtcp_packets()); @@ -147,7 +147,7 @@ TEST_F(AudioSenderTest, RtcpTimer) { TestAudioBusFactory::kMiddleANoteFreq, 0.5f).NextAudioBus(kDuration)); - audio_sender_->InsertAudio(bus.Pass(), testing_clock_->NowTicks()); + audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks()); task_runner_->RunTasks(); // Make sure that we send at least one RTCP packet. diff --git a/media/cast/sender/external_video_encoder.cc b/media/cast/sender/external_video_encoder.cc index 0bfbe71..1a3c3e7 100644 --- a/media/cast/sender/external_video_encoder.cc +++ b/media/cast/sender/external_video_encoder.cc @@ -5,6 +5,7 @@ #include "media/cast/sender/external_video_encoder.h" #include <cmath> +#include <utility> #include "base/bind.h" #include "base/debug/crash_logging.h" @@ -88,7 +89,7 @@ class ExternalVideoEncoder::VEAClientImpl max_frame_rate_(max_frame_rate), status_change_cb_(status_change_cb), create_video_encode_memory_cb_(create_video_encode_memory_cb), - video_encode_accelerator_(vea.Pass()), + video_encode_accelerator_(std::move(vea)), encoder_active_(false), next_frame_id_(0u), key_frame_encountered_(false), @@ -368,7 +369,7 @@ class ExternalVideoEncoder::VEAClientImpl void OnReceivedSharedMemory(scoped_ptr<base::SharedMemory> memory) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); - output_buffers_.push_back(memory.Pass()); + output_buffers_.push_back(std::move(memory)); // Wait until all requested buffers are received. if (output_buffers_.size() < kOutputBufferCount) @@ -598,12 +599,9 @@ void ExternalVideoEncoder::OnCreateVideoEncodeAccelerator( } DCHECK(!client_); - client_ = new VEAClientImpl(cast_environment_, - encoder_task_runner, - vea.Pass(), - video_config.max_frame_rate, - status_change_cb, - create_video_encode_memory_cb_); + client_ = new VEAClientImpl(cast_environment_, encoder_task_runner, + std::move(vea), video_config.max_frame_rate, + status_change_cb, create_video_encode_memory_cb_); client_->task_runner()->PostTask(FROM_HERE, base::Bind(&VEAClientImpl::Initialize, client_, diff --git a/media/cast/sender/fake_video_encode_accelerator_factory.cc b/media/cast/sender/fake_video_encode_accelerator_factory.cc index 24eba4b..b06eb56 100644 --- a/media/cast/sender/fake_video_encode_accelerator_factory.cc +++ b/media/cast/sender/fake_video_encode_accelerator_factory.cc @@ -4,6 +4,8 @@ #include "media/cast/sender/fake_video_encode_accelerator_factory.h" +#include <utility> + #include "base/callback_helpers.h" namespace media { @@ -66,15 +68,16 @@ void FakeVideoEncodeAcceleratorFactory::RespondWithVideoEncodeAccelerator() { DCHECK(next_response_vea_.get()); last_response_vea_ = next_response_vea_.get(); ++vea_response_count_; - base::ResetAndReturn(&vea_response_callback_).Run( - task_runner_, next_response_vea_.Pass()); + base::ResetAndReturn(&vea_response_callback_) + .Run(task_runner_, std::move(next_response_vea_)); } void FakeVideoEncodeAcceleratorFactory::RespondWithSharedMemory() { DCHECK(next_response_shm_.get()); last_response_shm_ = next_response_shm_.get(); ++shm_response_count_; - base::ResetAndReturn(&shm_response_callback_).Run(next_response_shm_.Pass()); + base::ResetAndReturn(&shm_response_callback_) + .Run(std::move(next_response_shm_)); } } // namespace cast diff --git a/media/cast/sender/frame_sender.cc b/media/cast/sender/frame_sender.cc index 8303483..fe8b1e0 100644 --- a/media/cast/sender/frame_sender.cc +++ b/media/cast/sender/frame_sender.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <limits> +#include <utility> #include <vector> #include "base/macros.h" @@ -245,7 +246,7 @@ void FrameSender::SendEncodedFrame( encode_event->encoder_cpu_utilization = encoded_frame->deadline_utilization; encode_event->idealized_bitrate_utilization = encoded_frame->lossy_utilization; - cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); RecordLatestFrameTimestamps(frame_id, encoded_frame->reference_time, @@ -348,7 +349,7 @@ void FrameSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { ack_event->rtp_timestamp = GetRecordedRtpTimestamp(cast_feedback.ack_frame_id); ack_event->frame_id = cast_feedback.ack_frame_id; - cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); + cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); const bool is_acked_out_of_order = static_cast<int32_t>(cast_feedback.ack_frame_id - diff --git a/media/cast/sender/size_adaptable_video_encoder_base.cc b/media/cast/sender/size_adaptable_video_encoder_base.cc index 733b50c..6d1399f 100644 --- a/media/cast/sender/size_adaptable_video_encoder_base.cc +++ b/media/cast/sender/size_adaptable_video_encoder_base.cc @@ -4,6 +4,8 @@ #include "media/cast/sender/size_adaptable_video_encoder_base.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "media/base/video_frame.h" @@ -132,7 +134,7 @@ void SizeAdaptableVideoEncoderBase::TrySpawningReplacementEncoder( << frame_size_.ToString() << " to " << size_needed.ToString() << ")."; frame_size_ = size_needed; - encoder_ = CreateEncoder().Pass(); + encoder_ = CreateEncoder(); DCHECK(encoder_); } @@ -155,7 +157,7 @@ void SizeAdaptableVideoEncoderBase::OnEncodedVideoFrame( --frames_in_encoder_; DCHECK_GE(frames_in_encoder_, 0); last_frame_id_ = encoded_frame->frame_id; - frame_encoded_callback.Run(encoded_frame.Pass()); + frame_encoded_callback.Run(std::move(encoded_frame)); } } // namespace cast diff --git a/media/cast/sender/video_encoder_unittest.cc b/media/cast/sender/video_encoder_unittest.cc index 487c140..9624e43 100644 --- a/media/cast/sender/video_encoder_unittest.cc +++ b/media/cast/sender/video_encoder_unittest.cc @@ -36,11 +36,11 @@ class VideoEncoderTest VideoEncoderTest() : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)), + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, + task_runner_, + task_runner_)), video_config_(GetDefaultVideoSenderConfig()), operational_status_(STATUS_UNINITIALIZED), count_frames_delivered_(0) { @@ -67,15 +67,14 @@ class VideoEncoderTest ASSERT_EQ(STATUS_UNINITIALIZED, operational_status_); video_config_.max_number_of_video_buffers_used = 1; video_encoder_ = VideoEncoder::Create( - cast_environment_, - video_config_, + cast_environment_, video_config_, base::Bind(&VideoEncoderTest::OnOperationalStatusChange, base::Unretained(this)), base::Bind( &FakeVideoEncodeAcceleratorFactory::CreateVideoEncodeAccelerator, base::Unretained(vea_factory_.get())), base::Bind(&FakeVideoEncodeAcceleratorFactory::CreateSharedMemory, - base::Unretained(vea_factory_.get()))).Pass(); + base::Unretained(vea_factory_.get()))); RunTasksAndAdvanceClock(); if (is_encoder_present()) ASSERT_EQ(STATUS_INITIALIZED, operational_status_); @@ -212,7 +211,7 @@ class VideoEncoderTest // Create the VideoFrameFactory the first time status changes to // STATUS_INITIALIZED. if (operational_status_ == STATUS_INITIALIZED && !video_frame_factory_) - video_frame_factory_ = video_encoder_->CreateVideoFrameFactory().Pass(); + video_frame_factory_ = video_encoder_->CreateVideoFrameFactory(); } // Checks that |encoded_frame| matches expected values. This is the method diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc index 0f1d556..efe2a67 100644 --- a/media/cast/sender/video_sender.cc +++ b/media/cast/sender/video_sender.cc @@ -5,10 +5,10 @@ #include "media/cast/sender/video_sender.h" #include <stdint.h> - #include <algorithm> #include <cmath> #include <cstring> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -70,8 +70,9 @@ void LogVideoCaptureTimestamps(CastEnvironment* cast_environment, cast_environment->Clock()->NowTicks(); } - cast_environment->logger()->DispatchFrameEvent(capture_begin_event.Pass()); - cast_environment->logger()->DispatchFrameEvent(capture_end_event.Pass()); + cast_environment->logger()->DispatchFrameEvent( + std::move(capture_begin_event)); + cast_environment->logger()->DispatchFrameEvent(std::move(capture_end_event)); } } // namespace @@ -385,7 +386,7 @@ void VideoSender::OnEncodedVideoFrame( std::min(1.0, attenuated_utilization) : attenuated_utilization); } - SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); + SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); } } // namespace cast diff --git a/media/cast/sender/video_sender_unittest.cc b/media/cast/sender/video_sender_unittest.cc index b4bd086..4707660 100644 --- a/media/cast/sender/video_sender_unittest.cc +++ b/media/cast/sender/video_sender_unittest.cc @@ -145,11 +145,11 @@ class VideoSenderTest : public ::testing::Test { VideoSenderTest() : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)), + cast_environment_( + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), + task_runner_, + task_runner_, + task_runner_)), operational_status_(STATUS_UNINITIALIZED), vea_factory_(task_runner_) { testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); diff --git a/media/cast/test/cast_benchmarks.cc b/media/cast/test/cast_benchmarks.cc index a867eb2..dcd433e 100644 --- a/media/cast/test/cast_benchmarks.cc +++ b/media/cast/test/cast_benchmarks.cc @@ -24,8 +24,8 @@ #include <math.h> #include <stddef.h> #include <stdint.h> - #include <map> +#include <utility> #include <vector> #include "base/at_exit.h" @@ -211,12 +211,12 @@ class RunOneBenchmark { task_runner_receiver_( new test::SkewedSingleThreadTaskRunner(task_runner_)), cast_environment_sender_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(), + scoped_ptr<base::TickClock>(testing_clock_sender_), task_runner_sender_, task_runner_sender_, task_runner_sender_)), cast_environment_receiver_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_receiver_).Pass(), + scoped_ptr<base::TickClock>(testing_clock_receiver_), task_runner_receiver_, task_runner_receiver_, task_runner_receiver_)), @@ -318,20 +318,18 @@ class RunOneBenchmark { CreateDefaultVideoEncodeAcceleratorCallback(), CreateDefaultVideoEncodeMemoryCallback()); - receiver_to_sender_.Initialize( - CreateSimplePipe(p).Pass(), - transport_sender_.PacketReceiverForTesting(), - task_runner_, &testing_clock_); + receiver_to_sender_.Initialize(CreateSimplePipe(p), + transport_sender_.PacketReceiverForTesting(), + task_runner_, &testing_clock_); sender_to_receiver_.Initialize( - CreateSimplePipe(p).Pass(), - transport_receiver_->PacketReceiverForTesting(), + CreateSimplePipe(p), transport_receiver_->PacketReceiverForTesting(), task_runner_, &testing_clock_); task_runner_->RunTasks(); } void ReceivePacket(scoped_ptr<Packet> packet) { - cast_receiver_->ReceivePacket(packet.Pass()); + cast_receiver_->ReceivePacket(std::move(packet)); } virtual ~RunOneBenchmark() { @@ -386,10 +384,9 @@ class RunOneBenchmark { scoped_ptr<test::PacketPipe> CreateSimplePipe(const MeasuringPoint& p) { scoped_ptr<test::PacketPipe> pipe = test::NewBuffer(65536, p.bitrate); - pipe->AppendToPipe( - test::NewRandomDrop(p.percent_packet_drop / 100.0).Pass()); + pipe->AppendToPipe(test::NewRandomDrop(p.percent_packet_drop / 100.0)); pipe->AppendToPipe(test::NewConstantDelay(p.latency / 1000.0)); - return pipe.Pass(); + return pipe; } void Run(const MeasuringPoint& p) { diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc index 85b885b..d7eb22d 100644 --- a/media/cast/test/end2end_unittest.cc +++ b/media/cast/test/end2end_unittest.cc @@ -12,10 +12,10 @@ #include <math.h> #include <stddef.h> #include <stdint.h> - #include <functional> #include <list> #include <map> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -168,7 +168,7 @@ class LoopBackPacketPipe : public test::PacketPipe { // PacketPipe implementations. void Send(scoped_ptr<Packet> packet) final { - packet_receiver_.Run(packet.Pass()); + packet_receiver_.Run(std::move(packet)); } private: @@ -197,9 +197,9 @@ class LoopBackTransport : public PacketSender { scoped_ptr<test::PacketPipe> loopback_pipe( new LoopBackPacketPipe(packet_receiver)); if (packet_pipe_) { - packet_pipe_->AppendToPipe(loopback_pipe.Pass()); + packet_pipe_->AppendToPipe(std::move(loopback_pipe)); } else { - packet_pipe_ = loopback_pipe.Pass(); + packet_pipe_ = std::move(loopback_pipe); } packet_pipe_->InitOnIOThread(task_runner, clock); } @@ -217,7 +217,7 @@ class LoopBackTransport : public PacketSender { } scoped_ptr<Packet> packet_copy(new Packet(packet->data)); - packet_pipe_->Send(packet_copy.Pass()); + packet_pipe_->Send(std::move(packet_copy)); return true; } @@ -231,8 +231,8 @@ class LoopBackTransport : public PacketSender { void SetPacketPipe(scoped_ptr<test::PacketPipe> pipe) { // Append the loopback pipe to the end. - pipe->AppendToPipe(packet_pipe_.Pass()); - packet_pipe_ = pipe.Pass(); + pipe->AppendToPipe(std::move(packet_pipe_)); + packet_pipe_ = std::move(pipe); } private: @@ -263,7 +263,7 @@ class TestReceiverAudioCallback scoped_ptr<ExpectedAudioFrame> expected_audio_frame( new ExpectedAudioFrame()); expected_audio_frame->audio_bus = - AudioBus::Create(audio_bus.channels(), audio_bus.frames()).Pass(); + AudioBus::Create(audio_bus.channels(), audio_bus.frames()); audio_bus.CopyTo(expected_audio_frame->audio_bus.get()); expected_audio_frame->playout_time = playout_time; expected_frames_.push_back(expected_audio_frame.release()); @@ -333,7 +333,7 @@ class TestReceiverAudioCallback audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16_t)); // Delegate the checking from here... - CheckAudioFrame(audio_bus.Pass(), audio_frame->reference_time, true); + CheckAudioFrame(std::move(audio_bus), audio_frame->reference_time, true); } int number_times_called() const { return num_called_; } @@ -439,12 +439,12 @@ class End2EndTest : public ::testing::Test { task_runner_receiver_( new test::SkewedSingleThreadTaskRunner(task_runner_)), cast_environment_sender_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(), + scoped_ptr<base::TickClock>(testing_clock_sender_), task_runner_sender_, task_runner_sender_, task_runner_sender_)), cast_environment_receiver_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_receiver_).Pass(), + scoped_ptr<base::TickClock>(testing_clock_receiver_), task_runner_receiver_, task_runner_receiver_, task_runner_receiver_)), @@ -544,7 +544,7 @@ class End2EndTest : public ::testing::Test { reference_time + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs)); } - audio_frame_input_->InsertAudio(audio_bus.Pass(), reference_time); + audio_frame_input_->InsertAudio(std::move(audio_bus), reference_time); } } @@ -560,7 +560,7 @@ class End2EndTest : public ::testing::Test { *audio_bus, reference_time + delay + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs)); - audio_frame_input_->InsertAudio(audio_bus.Pass(), reference_time); + audio_frame_input_->InsertAudio(std::move(audio_bus), reference_time); } } @@ -574,7 +574,7 @@ class End2EndTest : public ::testing::Test { } void ReceivePacket(scoped_ptr<Packet> packet) { - cast_receiver_->ReceivePacket(packet.Pass()); + cast_receiver_->ReceivePacket(std::move(packet)); } void Create() { @@ -1330,8 +1330,8 @@ TEST_F(End2EndTest, SmoothPlayoutWithFivePercentClockRateSkew) { TEST_F(End2EndTest, EvilNetwork) { Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, 1); - receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass()); - sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass()); + receiver_to_sender_.SetPacketPipe(test::EvilNetwork()); + sender_to_receiver_.SetPacketPipe(test::EvilNetwork()); Create(); StartBasicPlayer(); @@ -1353,8 +1353,8 @@ TEST_F(End2EndTest, EvilNetwork) { TEST_F(End2EndTest, ShoveHighFrameRateDownYerThroat) { Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, 1); - receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass()); - sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass()); + receiver_to_sender_.SetPacketPipe(test::EvilNetwork()); + sender_to_receiver_.SetPacketPipe(test::EvilNetwork()); Create(); StartBasicPlayer(); @@ -1386,7 +1386,7 @@ TEST_F(End2EndTest, OldPacketNetwork) { echo_chamber->AppendToPipe( test::NewDuplicateAndDelay(1, 160 * kFrameTimerMs)); - receiver_to_sender_.SetPacketPipe(echo_chamber.Pass()); + receiver_to_sender_.SetPacketPipe(std::move(echo_chamber)); Create(); StartBasicPlayer(); diff --git a/media/cast/test/fake_media_source.cc b/media/cast/test/fake_media_source.cc index 3c7a8e0..0dbe950 100644 --- a/media/cast/test/fake_media_source.cc +++ b/media/cast/test/fake_media_source.cc @@ -4,6 +4,8 @@ #include "media/cast/test/fake_media_source.h" +#include <utility> + #include "base/bind.h" #include "base/files/scoped_file.h" #include "base/logging.h" @@ -271,8 +273,7 @@ void FakeMediaSource::SendNextFakeFrame() { CHECK(!audio_bus_queue_.empty()) << "No audio decoded."; scoped_ptr<AudioBus> bus(audio_bus_queue_.front()); audio_bus_queue_.pop(); - audio_frame_input_->InsertAudio( - bus.Pass(), start_time_ + audio_time); + audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time); } else { audio_frame_input_->InsertAudio( audio_bus_factory_->NextAudioBus( @@ -364,8 +365,7 @@ bool FakeMediaSource::SendNextTranscodedAudio(base::TimeDelta elapsed_time) { scoped_ptr<AudioBus> bus(audio_bus_queue_.front()); audio_bus_queue_.pop(); audio_sent_ts_->AddFrames(bus->frames()); - audio_frame_input_->InsertAudio( - bus.Pass(), start_time_ + audio_time); + audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time); // Make sure queue is not empty. Decode(true); @@ -419,7 +419,7 @@ ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) { if (av_read_frame(av_format_context_, packet.get()) < 0) { VLOG(1) << "Failed to read one AVPacket."; packet.reset(); - return packet.Pass(); + return packet; } int stream_index = static_cast<int>(packet->stream_index); @@ -432,7 +432,7 @@ ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) { LOG(INFO) << "Unknown packet."; packet.reset(); } - return packet.Pass(); + return packet; } void FakeMediaSource::DecodeAudio(ScopedAVPacket packet) { @@ -570,9 +570,9 @@ void FakeMediaSource::Decode(bool decode_audio) { } if (audio_packet) - DecodeAudio(packet.Pass()); + DecodeAudio(std::move(packet)); else - DecodeVideo(packet.Pass()); + DecodeVideo(std::move(packet)); } } diff --git a/media/cast/test/loopback_transport.cc b/media/cast/test/loopback_transport.cc index 570d0a0..d82dcbd 100644 --- a/media/cast/test/loopback_transport.cc +++ b/media/cast/test/loopback_transport.cc @@ -4,6 +4,8 @@ #include "media/cast/test/loopback_transport.h" +#include <utility> + #include "base/macros.h" #include "base/single_thread_task_runner.h" #include "base/time/tick_clock.h" @@ -25,7 +27,7 @@ class LoopBackPacketPipe : public test::PacketPipe { // PacketPipe implementations. void Send(scoped_ptr<Packet> packet) final { - packet_receiver_.Run(packet.Pass()); + packet_receiver_.Run(std::move(packet)); } private: @@ -49,7 +51,7 @@ bool LoopBackTransport::SendPacket(PacketRef packet, const base::Closure& cb) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); scoped_ptr<Packet> packet_copy(new Packet(packet->data)); - packet_pipe_->Send(packet_copy.Pass()); + packet_pipe_->Send(std::move(packet_copy)); bytes_sent_ += packet->data.size(); return true; } @@ -67,10 +69,10 @@ void LoopBackTransport::Initialize( new LoopBackPacketPipe(packet_receiver)); if (pipe) { // Append the loopback pipe to the end. - pipe->AppendToPipe(loopback_pipe.Pass()); - packet_pipe_ = pipe.Pass(); + pipe->AppendToPipe(std::move(loopback_pipe)); + packet_pipe_ = std::move(pipe); } else { - packet_pipe_ = loopback_pipe.Pass(); + packet_pipe_ = std::move(loopback_pipe); } packet_pipe_->InitOnIOThread(task_runner, clock); } diff --git a/media/cast/test/receiver.cc b/media/cast/test/receiver.cc index 2dd0be2..67d8462 100644 --- a/media/cast/test/receiver.cc +++ b/media/cast/test/receiver.cc @@ -345,7 +345,7 @@ class NaivePlayer : public InProcessReceiver, if (audio_playout_queue_.empty()) break; - currently_playing_audio_frame_ = PopOneAudioFrame(false).Pass(); + currently_playing_audio_frame_ = PopOneAudioFrame(false); currently_playing_audio_frame_start_ = 0; } @@ -472,7 +472,7 @@ class NaivePlayer : public InProcessReceiver, scoped_ptr<AudioBus> ret(audio_playout_queue_.front().second); audio_playout_queue_.pop_front(); ++num_audio_frames_processed_; - return ret.Pass(); + return ret; } void CheckAVSync() { diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc index 4eab2a2..206bfb5 100644 --- a/media/cast/test/sender.cc +++ b/media/cast/test/sender.cc @@ -6,8 +6,8 @@ // or read from a file. #include <stdint.h> - #include <queue> +#include <utility> #include "base/at_exit.h" #include "base/base_paths.h" @@ -127,19 +127,15 @@ void WriteLogsToFileAndDestroySubscribers( video_event_subscriber->GetEventsAndReset( &log_metadata, &frame_events, &packet_events); - DumpLoggingData(log_metadata, - frame_events, - packet_events, - video_log_file.Pass()); + DumpLoggingData(log_metadata, frame_events, packet_events, + std::move(video_log_file)); VLOG(0) << "Dumping logging data for audio stream."; audio_event_subscriber->GetEventsAndReset( &log_metadata, &frame_events, &packet_events); - DumpLoggingData(log_metadata, - frame_events, - packet_events, - audio_log_file.Pass()); + DumpLoggingData(log_metadata, frame_events, packet_events, + std::move(audio_log_file)); } void WriteStatsAndDestroySubscribers( diff --git a/media/cast/test/simulator.cc b/media/cast/test/simulator.cc index 896b20d..a2aa6e4 100644 --- a/media/cast/test/simulator.cc +++ b/media/cast/test/simulator.cc @@ -36,6 +36,7 @@ #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/at_exit.h" #include "base/base_paths.h" @@ -301,20 +302,12 @@ void RunSimulation(const base::FilePath& source_path, base::ThreadTaskRunnerHandle task_runner_handle(task_runner); // CastEnvironments. - scoped_refptr<CastEnvironment> sender_env = - new CastEnvironment( - scoped_ptr<base::TickClock>( - new test::SkewedTickClock(&testing_clock)).Pass(), - task_runner, - task_runner, - task_runner); - scoped_refptr<CastEnvironment> receiver_env = - new CastEnvironment( - scoped_ptr<base::TickClock>( - new test::SkewedTickClock(&testing_clock)).Pass(), - task_runner, - task_runner, - task_runner); + scoped_refptr<CastEnvironment> sender_env = new CastEnvironment( + scoped_ptr<base::TickClock>(new test::SkewedTickClock(&testing_clock)), + task_runner, task_runner, task_runner); + scoped_refptr<CastEnvironment> receiver_env = new CastEnvironment( + scoped_ptr<base::TickClock>(new test::SkewedTickClock(&testing_clock)), + task_runner, task_runner, task_runner); // Event subscriber. Store at most 1 hour of events. EncodingEventSubscriber audio_event_subscriber(AUDIO_EVENT, @@ -360,7 +353,7 @@ void RunSimulation(const base::FilePath& source_path, PacketProxy() : receiver(NULL) {} void ReceivePacket(scoped_ptr<Packet> packet) { if (receiver) - receiver->ReceivePacket(packet.Pass()); + receiver->ReceivePacket(std::move(packet)); } CastReceiver* receiver; }; @@ -413,12 +406,11 @@ void RunSimulation(const base::FilePath& source_path, ipp.reset(new test::InterruptedPoissonProcess( average_rates, ipp_model.coef_burstiness(), ipp_model.coef_variance(), 0)); - receiver_to_sender.Initialize( - ipp->NewBuffer(128 * 1024).Pass(), - transport_sender->PacketReceiverForTesting(), - task_runner, &testing_clock); + receiver_to_sender.Initialize(ipp->NewBuffer(128 * 1024), + transport_sender->PacketReceiverForTesting(), + task_runner, &testing_clock); sender_to_receiver.Initialize( - ipp->NewBuffer(128 * 1024).Pass(), + ipp->NewBuffer(128 * 1024), transport_receiver->PacketReceiverForTesting(), task_runner, &testing_clock); } else { diff --git a/media/cast/test/utility/audio_utility.cc b/media/cast/test/utility/audio_utility.cc index 348b692..0d50b37 100644 --- a/media/cast/test/utility/audio_utility.cc +++ b/media/cast/test/utility/audio_utility.cc @@ -37,7 +37,7 @@ scoped_ptr<AudioBus> TestAudioBusFactory::NextAudioBus( scoped_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples)); source_.OnMoreData(bus.get(), 0, 0); bus->Scale(volume_); - return bus.Pass(); + return bus; } int CountZeroCrossings(const float* samples, int length) { diff --git a/media/cast/test/utility/in_process_receiver.cc b/media/cast/test/utility/in_process_receiver.cc index 788325f..1e97c9a 100644 --- a/media/cast/test/utility/in_process_receiver.cc +++ b/media/cast/test/utility/in_process_receiver.cc @@ -4,6 +4,8 @@ #include "media/cast/test/utility/in_process_receiver.h" +#include <utility> + #include "base/bind_helpers.h" #include "base/synchronization/waitable_event.h" #include "base/time/time.h" @@ -104,7 +106,7 @@ void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame, bool is_continuous) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); if (audio_frame.get()) - OnAudioFrame(audio_frame.Pass(), playout_time, is_continuous); + OnAudioFrame(std::move(audio_frame), playout_time, is_continuous); PullNextAudioFrame(); } @@ -133,7 +135,7 @@ void InProcessReceiver::PullNextVideoFrame() { void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) { // TODO(Hubbe): Make an InsertPacket method instead. - cast_receiver_->ReceivePacket(packet.Pass()); + cast_receiver_->ReceivePacket(std::move(packet)); } } // namespace cast diff --git a/media/cast/test/utility/tap_proxy.cc b/media/cast/test/utility/tap_proxy.cc index c0d8b3a..57166a8 100644 --- a/media/cast/test/utility/tap_proxy.cc +++ b/media/cast/test/utility/tap_proxy.cc @@ -17,9 +17,9 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> - #include <deque> #include <map> +#include <utility> #include "base/at_exit.h" #include "base/bind.h" @@ -70,21 +70,17 @@ class SendToFDPipe : public PacketPipe { class QueueManager : public base::MessageLoopForIO::Watcher { public: - QueueManager(int input_fd, - int output_fd, - scoped_ptr<PacketPipe> pipe) : - input_fd_(input_fd), - packet_pipe_(pipe.Pass()) { - + QueueManager(int input_fd, int output_fd, scoped_ptr<PacketPipe> pipe) + : input_fd_(input_fd), packet_pipe_(std::move(pipe)) { CHECK(base::MessageLoopForIO::current()->WatchFileDescriptor( input_fd_, true, base::MessageLoopForIO::WATCH_READ, &read_socket_watcher_, this)); scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd)); if (packet_pipe_) { - packet_pipe_->AppendToPipe(tmp.Pass()); + packet_pipe_->AppendToPipe(std::move(tmp)); } else { - packet_pipe_ = tmp.Pass(); + packet_pipe_ = std::move(tmp); } packet_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), &tick_clock_); @@ -105,7 +101,7 @@ class QueueManager : public base::MessageLoopForIO::Watcher { } if (nread == 0) return; packet->resize(nread); - packet_pipe_->Send(packet.Pass()); + packet_pipe_->Send(std::move(packet)); } void OnFileCanWriteWithoutBlocking(int fd) final { NOTREACHED(); } @@ -176,7 +172,7 @@ class ByteCounterPipe : public media::cast::test::PacketPipe { ByteCounterPipe(ByteCounter* counter) : counter_(counter) {} void Send(scoped_ptr<media::cast::Packet> packet) final { counter_->Increment(packet->size()); - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } private: ByteCounter* counter_; @@ -187,10 +183,9 @@ void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe, ByteCounter* pipe_output_counter) { media::cast::test::PacketPipe* new_pipe = new ByteCounterPipe(pipe_input_counter); - new_pipe->AppendToPipe(pipe->Pass()); - new_pipe->AppendToPipe( - scoped_ptr<media::cast::test::PacketPipe>( - new ByteCounterPipe(pipe_output_counter)).Pass()); + new_pipe->AppendToPipe(std::move(*pipe)); + new_pipe->AppendToPipe(scoped_ptr<media::cast::test::PacketPipe>( + new ByteCounterPipe(pipe_output_counter))); pipe->reset(new_pipe); } @@ -286,17 +281,17 @@ int main(int argc, char **argv) { if (network_type == "perfect") { // No action needed. } else if (network_type == "good") { - in_pipe = media::cast::test::GoodNetwork().Pass(); - out_pipe = media::cast::test::GoodNetwork().Pass(); + in_pipe = media::cast::test::GoodNetwork(); + out_pipe = media::cast::test::GoodNetwork(); } else if (network_type == "wifi") { - in_pipe = media::cast::test::WifiNetwork().Pass(); - out_pipe = media::cast::test::WifiNetwork().Pass(); + in_pipe = media::cast::test::WifiNetwork(); + out_pipe = media::cast::test::WifiNetwork(); } else if (network_type == "bad") { - in_pipe = media::cast::test::BadNetwork().Pass(); - out_pipe = media::cast::test::BadNetwork().Pass(); + in_pipe = media::cast::test::BadNetwork(); + out_pipe = media::cast::test::BadNetwork(); } else if (network_type == "evil") { - in_pipe = media::cast::test::EvilNetwork().Pass(); - out_pipe = media::cast::test::EvilNetwork().Pass(); + in_pipe = media::cast::test::EvilNetwork(); + out_pipe = media::cast::test::EvilNetwork(); } else { fprintf(stderr, "Unknown network type.\n"); exit(1); @@ -311,8 +306,8 @@ int main(int argc, char **argv) { base::MessageLoopForIO message_loop; last_printout = base::TimeTicks::Now(); - media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass()); - media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass()); + media::cast::test::QueueManager qm1(fd1, fd2, std::move(in_pipe)); + media::cast::test::QueueManager qm2(fd2, fd1, std::move(out_pipe)); CheckByteCounters(); printf("Press Ctrl-C when done.\n"); message_loop.Run(); diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc index c5c54e5..1e5c4fa 100644 --- a/media/cast/test/utility/udp_proxy.cc +++ b/media/cast/test/utility/udp_proxy.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/cast/test/utility/udp_proxy.h" + #include <math.h> #include <stdlib.h> +#include <utility> #include <vector> -#include "media/cast/test/utility/udp_proxy.h" - #include "base/logging.h" #include "base/macros.h" #include "base/rand_util.h" @@ -38,9 +39,9 @@ void PacketPipe::InitOnIOThread( } void PacketPipe::AppendToPipe(scoped_ptr<PacketPipe> pipe) { if (pipe_) { - pipe_->AppendToPipe(pipe.Pass()); + pipe_->AppendToPipe(std::move(pipe)); } else { - pipe_ = pipe.Pass(); + pipe_ = std::move(pipe); } } @@ -94,7 +95,7 @@ class Buffer : public PacketPipe { bytes_to_send -= packet->size(); buffer_size_ -= packet->size(); buffer_.pop_front(); - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } if (!buffer_.empty()) { Schedule(); @@ -110,7 +111,7 @@ class Buffer : public PacketPipe { }; scoped_ptr<PacketPipe> NewBuffer(size_t buffer_size, double bandwidth) { - return scoped_ptr<PacketPipe>(new Buffer(buffer_size, bandwidth)).Pass(); + return scoped_ptr<PacketPipe>(new Buffer(buffer_size, bandwidth)); } class RandomDrop : public PacketPipe { @@ -120,7 +121,7 @@ class RandomDrop : public PacketPipe { void Send(scoped_ptr<Packet> packet) final { if (rand() > drop_fraction_) { - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } } @@ -129,7 +130,7 @@ class RandomDrop : public PacketPipe { }; scoped_ptr<PacketPipe> NewRandomDrop(double drop_fraction) { - return scoped_ptr<PacketPipe>(new RandomDrop(drop_fraction)).Pass(); + return scoped_ptr<PacketPipe>(new RandomDrop(drop_fraction)); } class SimpleDelayBase : public PacketPipe { @@ -150,7 +151,7 @@ class SimpleDelayBase : public PacketPipe { private: virtual void SendInternal(scoped_ptr<Packet> packet) { - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } base::WeakPtrFactory<SimpleDelayBase> weak_factory_; @@ -166,7 +167,7 @@ class ConstantDelay : public SimpleDelayBase { }; scoped_ptr<PacketPipe> NewConstantDelay(double delay_seconds) { - return scoped_ptr<PacketPipe>(new ConstantDelay(delay_seconds)).Pass(); + return scoped_ptr<PacketPipe>(new ConstantDelay(delay_seconds)); } class RandomUnsortedDelay : public SimpleDelayBase { @@ -180,7 +181,7 @@ class RandomUnsortedDelay : public SimpleDelayBase { }; scoped_ptr<PacketPipe> NewRandomUnsortedDelay(double random_delay) { - return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay)).Pass(); + return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay)); } class DuplicateAndDelay : public RandomUnsortedDelay { @@ -192,7 +193,7 @@ class DuplicateAndDelay : public RandomUnsortedDelay { } void Send(scoped_ptr<Packet> packet) final { pipe_->Send(scoped_ptr<Packet>(new Packet(*packet.get()))); - RandomUnsortedDelay::Send(packet.Pass()); + RandomUnsortedDelay::Send(std::move(packet)); } double GetDelay() final { return RandomUnsortedDelay::GetDelay() + delay_min_; @@ -203,8 +204,7 @@ class DuplicateAndDelay : public RandomUnsortedDelay { scoped_ptr<PacketPipe> NewDuplicateAndDelay(double delay_min, double random_delay) { - return scoped_ptr<PacketPipe>( - new DuplicateAndDelay(delay_min, random_delay)).Pass(); + return scoped_ptr<PacketPipe>(new DuplicateAndDelay(delay_min, random_delay)); } class RandomSortedDelay : public PacketPipe { @@ -262,7 +262,7 @@ class RandomSortedDelay : public PacketPipe { base::TimeTicks now = clock_->NowTicks(); while (!buffer_.empty() && next_send_ <= now) { scoped_ptr<Packet> packet(buffer_.front().release()); - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); buffer_.pop_front(); next_send_ += base::TimeDelta::FromSecondsD( @@ -291,10 +291,8 @@ scoped_ptr<PacketPipe> NewRandomSortedDelay( double random_delay, double extra_delay, double seconds_between_extra_delay) { - return scoped_ptr<PacketPipe>( - new RandomSortedDelay( - random_delay, extra_delay, seconds_between_extra_delay)) - .Pass(); + return scoped_ptr<PacketPipe>(new RandomSortedDelay( + random_delay, extra_delay, seconds_between_extra_delay)); } class NetworkGlitchPipe : public PacketPipe { @@ -314,7 +312,7 @@ class NetworkGlitchPipe : public PacketPipe { void Send(scoped_ptr<Packet> packet) final { if (works_) { - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } } @@ -339,8 +337,7 @@ class NetworkGlitchPipe : public PacketPipe { scoped_ptr<PacketPipe> NewNetworkGlitchPipe(double average_work_time, double average_outage_time) { return scoped_ptr<PacketPipe>( - new NetworkGlitchPipe(average_work_time, average_outage_time)) - .Pass(); + new NetworkGlitchPipe(average_work_time, average_outage_time)); } @@ -380,7 +377,7 @@ class InterruptedPoissonProcess::InternalBuffer : public PacketPipe { stored_size_ -= packet->size(); buffer_.pop_front(); buffer_time_.pop_front(); - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); DCHECK(buffer_.size() == buffer_time_.size()); } @@ -447,7 +444,7 @@ scoped_ptr<PacketPipe> InterruptedPoissonProcess::NewBuffer(size_t size) { scoped_ptr<InternalBuffer> buffer( new InternalBuffer(weak_factory_.GetWeakPtr(), size)); send_buffers_.push_back(buffer->GetWeakPtr()); - return buffer.Pass(); + return std::move(buffer); } base::TimeDelta InterruptedPoissonProcess::NextEvent(double rate) { @@ -559,7 +556,7 @@ class PacketSender : public PacketPipe { namespace { void BuildPipe(scoped_ptr<PacketPipe>* pipe, PacketPipe* next) { if (*pipe) { - (*pipe)->AppendToPipe(scoped_ptr<PacketPipe>(next).Pass()); + (*pipe)->AppendToPipe(scoped_ptr<PacketPipe>(next)); } else { pipe->reset(next); } @@ -574,7 +571,7 @@ scoped_ptr<PacketPipe> GoodNetwork() { BuildPipe(&pipe, new RandomSortedDelay(1E-3, 2E-3, 3)); // This represents the buffer on the receiving device. BuildPipe(&pipe, new Buffer(2 << 20, 50)); - return pipe.Pass(); + return pipe; } scoped_ptr<PacketPipe> WifiNetwork() { @@ -591,7 +588,7 @@ scoped_ptr<PacketPipe> WifiNetwork() { BuildPipe(&pipe, new RandomDrop(0.005)); // This represents the buffer on the receiving device. BuildPipe(&pipe, new Buffer(256 << 10, 20)); - return pipe.Pass(); + return pipe; } scoped_ptr<PacketPipe> BadNetwork() { @@ -608,7 +605,7 @@ scoped_ptr<PacketPipe> BadNetwork() { BuildPipe(&pipe, new RandomUnsortedDelay(5E-3)); // This represents the buffer on the receiving device. BuildPipe(&pipe, new Buffer(64 << 10, 5)); // 64 kb buf, 5mbit/s - return pipe.Pass(); + return pipe; } @@ -626,7 +623,7 @@ scoped_ptr<PacketPipe> EvilNetwork() { BuildPipe(&pipe, new RandomUnsortedDelay(20E-3)); // This represents the buffer on the receiving device. BuildPipe(&pipe, new Buffer(4 << 10, 2)); // 4 kb buf, 2mbit/s - return pipe.Pass(); + return pipe; } scoped_ptr<InterruptedPoissonProcess> DefaultInterruptedPoissonProcess() { @@ -660,7 +657,7 @@ scoped_ptr<InterruptedPoissonProcess> DefaultInterruptedPoissonProcess() { scoped_ptr<InterruptedPoissonProcess> ipp( new InterruptedPoissonProcess( average_rates, burstiness, variance, 0)); - return ipp.Pass(); + return ipp; } class UDPProxyImpl : public UDPProxy { @@ -674,8 +671,8 @@ class UDPProxyImpl : public UDPProxy { destination_(destination), destination_is_mutable_(destination.address().empty()), proxy_thread_("media::cast::test::UdpProxy Thread"), - to_dest_pipe_(to_dest_pipe.Pass()), - from_dest_pipe_(from_dest_pipe.Pass()), + to_dest_pipe_(std::move(to_dest_pipe)), + from_dest_pipe_(std::move(from_dest_pipe)), blocked_(false), weak_factory_(this) { proxy_thread_.StartWithOptions( @@ -778,12 +775,12 @@ class UDPProxyImpl : public UDPProxy { } if (recv_address_ == destination_) { set_destination_next_ = false; - from_dest_pipe_->Send(packet_.Pass()); + from_dest_pipe_->Send(std::move(packet_)); } else { set_destination_next_ = true; VLOG(1) << "Return address = " << recv_address_.ToString(); return_address_ = recv_address_; - to_dest_pipe_->Send(packet_.Pass()); + to_dest_pipe_->Send(std::move(packet_)); } } @@ -842,7 +839,7 @@ class UDPProxyImpl : public UDPProxy { }; void PacketSender::Send(scoped_ptr<Packet> packet) { - udp_proxy_->Send(packet.Pass(), *destination_); + udp_proxy_->Send(std::move(packet), *destination_); } scoped_ptr<UDPProxy> UDPProxy::Create( @@ -851,12 +848,10 @@ scoped_ptr<UDPProxy> UDPProxy::Create( scoped_ptr<PacketPipe> to_dest_pipe, scoped_ptr<PacketPipe> from_dest_pipe, net::NetLog* net_log) { - scoped_ptr<UDPProxy> ret(new UDPProxyImpl(local_port, - destination, - to_dest_pipe.Pass(), - from_dest_pipe.Pass(), - net_log)); - return ret.Pass(); + scoped_ptr<UDPProxy> ret( + new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), + std::move(from_dest_pipe), net_log)); + return ret; } } // namespace test diff --git a/media/cast/test/utility/udp_proxy_main.cc b/media/cast/test/utility/udp_proxy_main.cc index bfa4e48..8877300 100644 --- a/media/cast/test/utility/udp_proxy_main.cc +++ b/media/cast/test/utility/udp_proxy_main.cc @@ -3,11 +3,11 @@ // found in the LICENSE file. #include <stdint.h> - #include <cstdio> #include <cstdlib> #include <deque> #include <string> +#include <utility> #include "base/at_exit.h" #include "base/bind.h" @@ -81,7 +81,7 @@ class ByteCounterPipe : public media::cast::test::PacketPipe { ByteCounterPipe(ByteCounter* counter) : counter_(counter) {} void Send(scoped_ptr<media::cast::Packet> packet) final { counter_->Increment(packet->size()); - pipe_->Send(packet.Pass()); + pipe_->Send(std::move(packet)); } private: ByteCounter* counter_; @@ -92,10 +92,9 @@ void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe, ByteCounter* pipe_output_counter) { media::cast::test::PacketPipe* new_pipe = new ByteCounterPipe(pipe_input_counter); - new_pipe->AppendToPipe(pipe->Pass()); - new_pipe->AppendToPipe( - scoped_ptr<media::cast::test::PacketPipe>( - new ByteCounterPipe(pipe_output_counter)).Pass()); + new_pipe->AppendToPipe(std::move(*pipe)); + new_pipe->AppendToPipe(scoped_ptr<media::cast::test::PacketPipe>( + new ByteCounterPipe(pipe_output_counter))); pipe->reset(new_pipe); } @@ -173,17 +172,17 @@ int main(int argc, char** argv) { if (network_type == "perfect") { // No action needed. } else if (network_type == "wifi") { - in_pipe = media::cast::test::WifiNetwork().Pass(); - out_pipe = media::cast::test::WifiNetwork().Pass(); + in_pipe = media::cast::test::WifiNetwork(); + out_pipe = media::cast::test::WifiNetwork(); } else if (network_type == "bad") { - in_pipe = media::cast::test::BadNetwork().Pass(); - out_pipe = media::cast::test::BadNetwork().Pass(); + in_pipe = media::cast::test::BadNetwork(); + out_pipe = media::cast::test::BadNetwork(); } else if (network_type == "evil") { - in_pipe = media::cast::test::EvilNetwork().Pass(); - out_pipe = media::cast::test::EvilNetwork().Pass(); + in_pipe = media::cast::test::EvilNetwork(); + out_pipe = media::cast::test::EvilNetwork(); } else if (network_type == "poisson-wifi") { - in_pipe = ipp->NewBuffer(128 * 1024).Pass(); - out_pipe = ipp->NewBuffer(128 * 1024).Pass(); + in_pipe = ipp->NewBuffer(128 * 1024); + out_pipe = ipp->NewBuffer(128 * 1024); } else { fprintf(stderr, "Unknown network type.\n"); exit(1); @@ -197,11 +196,9 @@ int main(int argc, char** argv) { printf("Press Ctrl-C when done.\n"); scoped_ptr<media::cast::test::UDPProxy> proxy( - media::cast::test::UDPProxy::Create(local_endpoint, - remote_endpoint, - in_pipe.Pass(), - out_pipe.Pass(), - NULL)); + media::cast::test::UDPProxy::Create(local_endpoint, remote_endpoint, + std::move(in_pipe), + std::move(out_pipe), NULL)); base::MessageLoop message_loop; g_counter.Get().last_printout = base::TimeTicks::Now(); CheckByteCounters(); diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index c194adf..87d3ebf 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc @@ -5,8 +5,8 @@ #include "media/cdm/aes_decryptor.h" #include <stddef.h> - #include <list> +#include <utility> #include <vector> #include "base/logging.h" @@ -396,7 +396,7 @@ void AesDecryptor::UpdateSession(const std::string& session_id, } } - session_keys_change_cb_.Run(session_id, key_added, keys_info.Pass()); + session_keys_change_cb_.Run(session_id, key_added, std::move(keys_info)); } void AesDecryptor::CloseSession(const std::string& session_id, @@ -425,7 +425,7 @@ void AesDecryptor::RemoveSession(const std::string& session_id, // TODO(jrummell): Remove the close() call when prefixed EME is removed. // http://crbug.com/249976. if (valid_sessions_.find(session_id) != valid_sessions_.end()) { - CloseSession(session_id, promise.Pass()); + CloseSession(session_id, std::move(promise)); return; } @@ -544,15 +544,15 @@ bool AesDecryptor::AddDecryptionKey(const std::string& session_id, base::AutoLock auto_lock(key_map_lock_); KeyIdToSessionKeysMap::iterator key_id_entry = key_map_.find(key_id); if (key_id_entry != key_map_.end()) { - key_id_entry->second->Insert(session_id, decryption_key.Pass()); + key_id_entry->second->Insert(session_id, std::move(decryption_key)); return true; } // |key_id| not found, so need to create new entry. scoped_ptr<SessionIdDecryptionKeyMap> inner_map( new SessionIdDecryptionKeyMap()); - inner_map->Insert(session_id, decryption_key.Pass()); - key_map_.add(key_id, inner_map.Pass()); + inner_map->Insert(session_id, std::move(decryption_key)); + key_map_.add(key_id, std::move(inner_map)); return true; } diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc index 90172fd..82338be 100644 --- a/media/cdm/aes_decryptor_unittest.cc +++ b/media/cdm/aes_decryptor_unittest.cc @@ -301,7 +301,7 @@ class AesDecryptorTest : public testing::TestWithParam<std::string> { base::Bind(&AesDecryptorTest::OnReject, base::Unretained(this), expected_result))); - return promise.Pass(); + return promise; } scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( @@ -314,7 +314,7 @@ class AesDecryptorTest : public testing::TestWithParam<std::string> { base::Bind(&AesDecryptorTest::OnReject, base::Unretained(this), expected_result))); - return promise.Pass(); + return promise; } // Creates a new session using |key_id|. Returns the session ID. diff --git a/media/cdm/cdm_adapter.cc b/media/cdm/cdm_adapter.cc index bdc03ec..11e7764 100644 --- a/media/cdm/cdm_adapter.cc +++ b/media/cdm/cdm_adapter.cc @@ -5,6 +5,7 @@ #include "media/cdm/cdm_adapter.h" #include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -346,7 +347,7 @@ void CdmAdapter::Create( scoped_ptr<CdmInitializedPromise> cdm_created_promise( new CdmInitializedPromise(cdm_created_cb, cdm)); - cdm->Initialize(cdm_path, cdm_created_promise.Pass()); + cdm->Initialize(cdm_path, std::move(cdm_created_promise)); } CdmAdapter::CdmAdapter( @@ -433,7 +434,7 @@ void CdmAdapter::SetServerCertificate(const std::vector<uint8_t>& certificate, return; } - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->SetServerCertificate(promise_id, certificate.data(), certificate.size()); } @@ -445,7 +446,7 @@ void CdmAdapter::CreateSessionAndGenerateRequest( scoped_ptr<NewSessionCdmPromise> promise) { DCHECK(task_runner_->BelongsToCurrentThread()); - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->CreateSessionAndGenerateRequest( promise_id, ToCdmSessionType(session_type), ToCdmInitDataType(init_data_type), init_data.data(), init_data.size()); @@ -456,7 +457,7 @@ void CdmAdapter::LoadSession(SessionType session_type, scoped_ptr<NewSessionCdmPromise> promise) { DCHECK(task_runner_->BelongsToCurrentThread()); - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->LoadSession(promise_id, ToCdmSessionType(session_type), session_id.data(), session_id.size()); } @@ -468,7 +469,7 @@ void CdmAdapter::UpdateSession(const std::string& session_id, DCHECK(!session_id.empty()); DCHECK(!response.empty()); - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->UpdateSession(promise_id, session_id.data(), session_id.size(), response.data(), response.size()); } @@ -478,7 +479,7 @@ void CdmAdapter::CloseSession(const std::string& session_id, DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(!session_id.empty()); - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->CloseSession(promise_id, session_id.data(), session_id.size()); } @@ -487,7 +488,7 @@ void CdmAdapter::RemoveSession(const std::string& session_id, DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(!session_id.empty()); - uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); + uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); cdm_->RemoveSession(promise_id, session_id.data(), session_id.size()); } @@ -645,7 +646,8 @@ void CdmAdapter::DecryptAndDecodeAudio( Decryptor::AudioFrames audio_frame_list; DCHECK(audio_frames->FrameBuffer()); - if (!AudioFramesDataToAudioFrames(audio_frames.Pass(), &audio_frame_list)) { + if (!AudioFramesDataToAudioFrames(std::move(audio_frames), + &audio_frame_list)) { DVLOG(1) << __FUNCTION__ << " unable to convert Audio Frames"; audio_decode_cb.Run(Decryptor::kError, empty_frames); return; @@ -808,7 +810,7 @@ void CdmAdapter::OnSessionKeysChange(const char* session_id, } session_keys_change_cb_.Run(std::string(session_id, session_id_size), - has_additional_usable_key, keys.Pass()); + has_additional_usable_key, std::move(keys)); } void CdmAdapter::OnExpirationChange(const char* session_id, diff --git a/media/cdm/cdm_adapter_unittest.cc b/media/cdm/cdm_adapter_unittest.cc index ed23d47..46de924 100644 --- a/media/cdm/cdm_adapter_unittest.cc +++ b/media/cdm/cdm_adapter_unittest.cc @@ -177,7 +177,7 @@ class CdmAdapterTest : public testing::Test { scoped_ptr<SimpleCdmPromise> promise(new CdmCallbackPromise<>( base::Bind(&CdmAdapterTest::OnResolve, base::Unretained(this)), base::Bind(&CdmAdapterTest::OnReject, base::Unretained(this)))); - return promise.Pass(); + return promise; } // Create a promise to be used when a new session is created. @@ -196,7 +196,7 @@ class CdmAdapterTest : public testing::Test { base::Bind(&CdmAdapterTest::OnResolveWithSession, base::Unretained(this)), base::Bind(&CdmAdapterTest::OnReject, base::Unretained(this)))); - return promise.Pass(); + return promise; } void RunUntilIdle() { message_loop_.RunUntilIdle(); } diff --git a/media/cdm/json_web_key.cc b/media/cdm/json_web_key.cc index 13b5837..850c44c 100644 --- a/media/cdm/json_web_key.cc +++ b/media/cdm/json_web_key.cc @@ -63,7 +63,7 @@ static scoped_ptr<base::DictionaryValue> CreateJSONDictionary( jwk->SetString(kKeyTypeTag, kKeyTypeOct); jwk->SetString(kKeyTag, key_string); jwk->SetString(kKeyIdTag, key_id_string); - return jwk.Pass(); + return jwk; } std::string GenerateJWKSet(const uint8_t* key, diff --git a/media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc b/media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc index 59adfde..47b5386 100644 --- a/media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc +++ b/media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc @@ -50,7 +50,7 @@ scoped_ptr<CdmVideoDecoder> CreateVideoDecoder( #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER - return video_decoder.Pass(); + return video_decoder; } } // namespace media diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc index 917c5ac..a164057 100644 --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <cstring> #include <sstream> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -112,7 +113,7 @@ static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( input_buffer.iv_size), subsamples)); - output_buffer->set_decrypt_config(decrypt_config.Pass()); + output_buffer->set_decrypt_config(std::move(decrypt_config)); output_buffer->set_timestamp( base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); @@ -306,7 +307,7 @@ void ClearKeyCdm::CreateSessionAndGenerateRequest( decryptor_->CreateSessionAndGenerateRequest( ConvertSessionType(session_type), ConvertInitDataType(init_data_type), std::vector<uint8_t>(init_data, init_data + init_data_size), - promise.Pass()); + std::move(promise)); if (key_system_ == kExternalClearKeyFileIOTestKeySystem) StartFileIOTest(); @@ -341,7 +342,7 @@ void ClearKeyCdm::LoadSession(uint32_t promise_id, promise_id))); decryptor_->CreateSessionAndGenerateRequest( MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, - std::vector<uint8_t>(), promise.Pass()); + std::vector<uint8_t>(), std::move(promise)); } void ClearKeyCdm::UpdateSession(uint32_t promise_id, @@ -363,7 +364,7 @@ void ClearKeyCdm::UpdateSession(uint32_t promise_id, promise_id))); decryptor_->UpdateSession( web_session_str, std::vector<uint8_t>(response, response + response_size), - promise.Pass()); + std::move(promise)); if (!renewal_timer_set_) { ScheduleNextRenewal(); @@ -386,7 +387,7 @@ void ClearKeyCdm::CloseSession(uint32_t promise_id, &ClearKeyCdm::OnPromiseResolved, base::Unretained(this), promise_id), base::Bind( &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); - decryptor_->CloseSession(web_session_str, promise.Pass()); + decryptor_->CloseSession(web_session_str, std::move(promise)); } void ClearKeyCdm::RemoveSession(uint32_t promise_id, @@ -415,7 +416,7 @@ void ClearKeyCdm::RemoveSession(uint32_t promise_id, promise_id), base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); - decryptor_->RemoveSession(web_session_str, promise.Pass()); + decryptor_->RemoveSession(web_session_str, std::move(promise)); } void ClearKeyCdm::SetServerCertificate(uint32_t promise_id, @@ -700,7 +701,7 @@ void ClearKeyCdm::LoadLoadableSession() { promise_id_for_emulated_loadsession_))); decryptor_->UpdateSession( session_id_for_emulated_loadsession_, - std::vector<uint8_t>(jwk_set.begin(), jwk_set.end()), promise.Pass()); + std::vector<uint8_t>(jwk_set.begin(), jwk_set.end()), std::move(promise)); } void ClearKeyCdm::OnSessionMessage(const std::string& session_id, diff --git a/media/cdm/proxy_decryptor.cc b/media/cdm/proxy_decryptor.cc index 4aea6b3..8d0085b 100644 --- a/media/cdm/proxy_decryptor.cc +++ b/media/cdm/proxy_decryptor.cc @@ -5,8 +5,8 @@ #include "media/cdm/proxy_decryptor.h" #include <stddef.h> - #include <cstring> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -185,7 +185,7 @@ void ProxyDecryptor::GenerateKeyRequestInternal( MediaKeys::PERSISTENT_LICENSE_SESSION, std::string(reinterpret_cast<const char*>(stripped_init_data.data()), stripped_init_data.size()), - promise.Pass()); + std::move(promise)); return; } @@ -199,7 +199,7 @@ void ProxyDecryptor::GenerateKeyRequestInternal( DCHECK(!key_system_.empty()); if (CanUseAesDecryptor(key_system_) || IsExternalClearKey(key_system_)) { OnPermissionStatus(session_type, init_data_type, stripped_init_data, - promise.Pass(), true /* granted */); + std::move(promise), true /* granted */); return; } @@ -211,7 +211,7 @@ void ProxyDecryptor::GenerateKeyRequestInternal( stripped_init_data, base::Passed(&promise))); #else OnPermissionStatus(session_type, init_data_type, stripped_init_data, - promise.Pass(), true /* granted */); + std::move(promise), true /* granted */); #endif } @@ -228,7 +228,7 @@ void ProxyDecryptor::OnPermissionStatus( DVLOG_IF(1, !granted) << "Permission request rejected."; media_keys_->CreateSessionAndGenerateRequest(session_type, init_data_type, - init_data, promise.Pass()); + init_data, std::move(promise)); } void ProxyDecryptor::AddKey(const uint8_t* key, @@ -282,13 +282,13 @@ void ProxyDecryptor::AddKey(const uint8_t* key, DCHECK(!jwk.empty()); media_keys_->UpdateSession(new_session_id, std::vector<uint8_t>(jwk.begin(), jwk.end()), - promise.Pass()); + std::move(promise)); return; } media_keys_->UpdateSession(new_session_id, std::vector<uint8_t>(key, key + key_length), - promise.Pass()); + std::move(promise)); } void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) { @@ -305,7 +305,7 @@ void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) { weak_ptr_factory_.GetWeakPtr(), session_id), base::Bind(&ProxyDecryptor::OnLegacySessionError, weak_ptr_factory_.GetWeakPtr(), session_id))); - media_keys_->RemoveSession(session_id, promise.Pass()); + media_keys_->RemoveSession(session_id, std::move(promise)); } void ProxyDecryptor::OnSessionMessage(const std::string& session_id, diff --git a/media/filters/audio_decoder_selector_unittest.cc b/media/filters/audio_decoder_selector_unittest.cc index 84b56e6..8f2151e 100644 --- a/media/filters/audio_decoder_selector_unittest.cc +++ b/media/filters/audio_decoder_selector_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include <stddef.h> - +#include <utility> #include <vector> #include "base/bind.h" @@ -86,7 +86,7 @@ class AudioDecoderSelectorTest : public ::testing::Test { void MockOnDecoderSelected(scoped_ptr<AudioDecoder> decoder, scoped_ptr<DecryptingDemuxerStream> stream) { OnDecoderSelected(decoder.get(), stream.get()); - selected_decoder_ = decoder.Pass(); + selected_decoder_ = std::move(decoder); } void UseClearStream() { @@ -138,9 +138,8 @@ class AudioDecoderSelectorTest : public ::testing::Test { all_decoders_.erase( all_decoders_.begin() + num_decoders, all_decoders_.end()); - decoder_selector_.reset( - new AudioDecoderSelector(message_loop_.task_runner(), - all_decoders_.Pass(), new MediaLog())); + decoder_selector_.reset(new AudioDecoderSelector( + message_loop_.task_runner(), std::move(all_decoders_), new MediaLog())); } void SelectDecoder() { diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc index bef4b3c..224abc43 100644 --- a/media/filters/chunk_demuxer.cc +++ b/media/filters/chunk_demuxer.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <limits> #include <list> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -1386,7 +1387,7 @@ ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, media_log_)); scoped_ptr<SourceState> source_state(new SourceState( - stream_parser.Pass(), frame_processor.Pass(), + std::move(stream_parser), std::move(frame_processor), base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this)), media_log_)); diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc index 75cba6c..2e4983d 100644 --- a/media/filters/chunk_demuxer_unittest.cc +++ b/media/filters/chunk_demuxer_unittest.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/filters/chunk_demuxer.h" + #include <stddef.h> #include <stdint.h> - #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/macros.h" @@ -21,7 +23,6 @@ #include "media/base/test_data_util.h" #include "media/base/test_helpers.h" #include "media/base/timestamp_constants.h" -#include "media/filters/chunk_demuxer.h" #include "media/formats/webm/cluster_builder.h" #include "media/formats/webm/webm_constants.h" #include "testing/gtest/include/gtest/gtest.h" @@ -379,7 +380,7 @@ class ChunkDemuxerTest : public ::testing::Test { } void AppendCluster(scoped_ptr<Cluster> cluster) { - AppendCluster(kSourceId, cluster.Pass()); + AppendCluster(kSourceId, std::move(cluster)); } void AppendCluster(int timecode, int block_count) { diff --git a/media/filters/decoder_selector.cc b/media/filters/decoder_selector.cc index c13fc0d..87e58a6 100644 --- a/media/filters/decoder_selector.cc +++ b/media/filters/decoder_selector.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "decoder_selector.h" +#include "media/filters/decoder_selector.h" + +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -59,7 +61,7 @@ DecoderSelector<StreamType>::DecoderSelector( ScopedVector<Decoder> decoders, const scoped_refptr<MediaLog>& media_log) : task_runner_(task_runner), - decoders_(decoders.Pass()), + decoders_(std::move(decoders)), media_log_(media_log), input_stream_(nullptr), weak_ptr_factory_(this) {} @@ -142,7 +144,7 @@ void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { if (success) { base::ResetAndReturn(&select_decoder_cb_) - .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); + .Run(std::move(decoder_), scoped_ptr<DecryptingDemuxerStream>()); return; } @@ -220,7 +222,7 @@ void DecoderSelector<StreamType>::DecoderInitDone(bool success) { } base::ResetAndReturn(&select_decoder_cb_) - .Run(decoder_.Pass(), decrypted_stream_.Pass()); + .Run(std::move(decoder_), std::move(decrypted_stream_)); } template <DemuxerStream::Type StreamType> diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc index c74e350..52f9458 100644 --- a/media/filters/decoder_stream.cc +++ b/media/filters/decoder_stream.cc @@ -4,6 +4,8 @@ #include "media/filters/decoder_stream.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" @@ -49,7 +51,7 @@ DecoderStream<StreamType>::DecoderStream( state_(STATE_UNINITIALIZED), stream_(NULL), decoder_selector_(new DecoderSelector<StreamType>(task_runner, - decoders.Pass(), + std::move(decoders), media_log)), decoded_frames_since_fallback_(0), active_splice_(false), @@ -251,11 +253,11 @@ void DecoderStream<StreamType>::OnDecoderSelected( DCHECK(decoder_); } - previous_decoder_ = decoder_.Pass(); + previous_decoder_ = std::move(decoder_); decoded_frames_since_fallback_ = 0; - decoder_ = selected_decoder.Pass(); + decoder_ = std::move(selected_decoder); if (decrypting_demuxer_stream) { - decrypting_demuxer_stream_ = decrypting_demuxer_stream.Pass(); + decrypting_demuxer_stream_ = std::move(decrypting_demuxer_stream); stream_ = decrypting_demuxer_stream_.get(); } diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index 4bf80a2..f942ea4 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -5,6 +5,7 @@ #include "media/filters/ffmpeg_demuxer.h" #include <algorithm> +#include <utility> #include "base/base64.h" #include "base/bind.h" @@ -221,7 +222,7 @@ scoped_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create( } return make_scoped_ptr(new FFmpegDemuxerStream( - demuxer, stream, audio_config.Pass(), video_config.Pass())); + demuxer, stream, std::move(audio_config), std::move(video_config))); } // @@ -415,7 +416,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { } if (decrypt_config) - buffer->set_decrypt_config(decrypt_config.Pass()); + buffer->set_decrypt_config(std::move(decrypt_config)); } if (packet->duration >= 0) { @@ -1438,7 +1439,7 @@ void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) { } FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; - demuxer_stream->EnqueuePacket(packet.Pass()); + demuxer_stream->EnqueuePacket(std::move(packet)); } // Keep reading until we've reached capacity. diff --git a/media/filters/file_data_source.cc b/media/filters/file_data_source.cc index 8bf6b0d..55bfc51 100644 --- a/media/filters/file_data_source.cc +++ b/media/filters/file_data_source.cc @@ -5,6 +5,7 @@ #include "media/filters/file_data_source.h" #include <algorithm> +#include <utility> #include "base/logging.h" @@ -20,7 +21,7 @@ FileDataSource::FileDataSource(base::File file) : force_read_errors_(false), force_streaming_(false), bytes_read_(0) { - file_.Initialize(file.Pass()); + file_.Initialize(std::move(file)); } bool FileDataSource::Initialize(const base::FilePath& file_path) { diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc index 31931c5..8b9f029 100644 --- a/media/filters/gpu_video_decoder.cc +++ b/media/filters/gpu_video_decoder.cc @@ -5,6 +5,7 @@ #include "media/filters/gpu_video_decoder.h" #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -39,8 +40,7 @@ static const size_t kSharedMemorySegmentBytes = 100 << 10; GpuVideoDecoder::SHMBuffer::SHMBuffer(scoped_ptr<base::SharedMemory> m, size_t s) - : shm(m.Pass()), size(s) { -} + : shm(std::move(m)), size(s) {} GpuVideoDecoder::SHMBuffer::~SHMBuffer() {} @@ -184,7 +184,7 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, return; } - vda_ = factories_->CreateVideoDecodeAccelerator().Pass(); + vda_ = factories_->CreateVideoDecodeAccelerator(); VideoDecodeAccelerator::Config vda_config(config); @@ -566,11 +566,11 @@ scoped_ptr<GpuVideoDecoder::SHMBuffer> GpuVideoDecoder::GetSHM( // CreateSharedMemory() can return NULL during Shutdown. if (!shm) return NULL; - return make_scoped_ptr(new SHMBuffer(shm.Pass(), size_to_allocate)); + return make_scoped_ptr(new SHMBuffer(std::move(shm), size_to_allocate)); } scoped_ptr<SHMBuffer> ret(available_shm_segments_.back()); available_shm_segments_.pop_back(); - return ret.Pass(); + return ret; } void GpuVideoDecoder::PutSHM(scoped_ptr<SHMBuffer> shm_buffer) { diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc index 09f5539..cfc881f 100644 --- a/media/filters/stream_parser_factory.cc +++ b/media/filters/stream_parser_factory.cc @@ -435,7 +435,7 @@ scoped_ptr<StreamParser> StreamParserFactory::Create( stream_parser.reset(factory_function(codecs, media_log)); } - return stream_parser.Pass(); + return stream_parser; } } // namespace media diff --git a/media/filters/video_decoder_selector_unittest.cc b/media/filters/video_decoder_selector_unittest.cc index 35fd6c9..d0d8405 100644 --- a/media/filters/video_decoder_selector_unittest.cc +++ b/media/filters/video_decoder_selector_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include <stddef.h> - +#include <utility> #include <vector> #include "base/bind.h" @@ -88,7 +88,7 @@ class VideoDecoderSelectorTest : public ::testing::Test { scoped_ptr<VideoDecoder> decoder, scoped_ptr<DecryptingDemuxerStream> stream) { OnDecoderSelected(decoder.get(), stream.get()); - selected_decoder_ = decoder.Pass(); + selected_decoder_ = std::move(decoder); } void UseClearStream() { @@ -132,9 +132,8 @@ class VideoDecoderSelectorTest : public ::testing::Test { all_decoders_.erase( all_decoders_.begin() + num_decoders, all_decoders_.end()); - decoder_selector_.reset( - new VideoDecoderSelector(message_loop_.task_runner(), - all_decoders_.Pass(), new MediaLog())); + decoder_selector_.reset(new VideoDecoderSelector( + message_loop_.task_runner(), std::move(all_decoders_), new MediaLog())); } void SelectDecoder() { diff --git a/media/filters/video_frame_stream_unittest.cc b/media/filters/video_frame_stream_unittest.cc index 8a3d3a6..b1a793e 100644 --- a/media/filters/video_frame_stream_unittest.cc +++ b/media/filters/video_frame_stream_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/macros.h" @@ -101,7 +103,7 @@ class VideoFrameStreamTest decoders.push_back(decoder3_); video_frame_stream_.reset(new VideoFrameStream( - message_loop_.task_runner(), decoders.Pass(), new MediaLog())); + message_loop_.task_runner(), std::move(decoders), new MediaLog())); EXPECT_CALL(*cdm_context_, GetDecryptor()) .WillRepeatedly(Return(decryptor_.get())); diff --git a/media/formats/webm/cluster_builder.cc b/media/formats/webm/cluster_builder.cc index b28b03b..b3ecc98 100644 --- a/media/formats/webm/cluster_builder.cc +++ b/media/formats/webm/cluster_builder.cc @@ -4,6 +4,8 @@ #include "media/formats/webm/cluster_builder.h" +#include <utility> + #include "base/logging.h" #include "media/base/data_buffer.h" #include "media/formats/webm/webm_constants.h" @@ -55,7 +57,7 @@ enum { }; Cluster::Cluster(scoped_ptr<uint8_t[]> data, int size) - : data_(data.Pass()), size_(size) {} + : data_(std::move(data)), size_(size) {} Cluster::~Cluster() {} ClusterBuilder::ClusterBuilder() { Reset(); } @@ -189,9 +191,9 @@ scoped_ptr<Cluster> ClusterBuilder::Finish() { UpdateUInt64(kClusterSizeOffset, bytes_used_ - (kClusterSizeOffset + 8)); - scoped_ptr<Cluster> ret(new Cluster(buffer_.Pass(), bytes_used_)); + scoped_ptr<Cluster> ret(new Cluster(std::move(buffer_), bytes_used_)); Reset(); - return ret.Pass(); + return ret; } scoped_ptr<Cluster> ClusterBuilder::FinishWithUnknownSize() { @@ -199,9 +201,9 @@ scoped_ptr<Cluster> ClusterBuilder::FinishWithUnknownSize() { UpdateUInt64(kClusterSizeOffset, kWebMUnknownSize); - scoped_ptr<Cluster> ret(new Cluster(buffer_.Pass(), bytes_used_)); + scoped_ptr<Cluster> ret(new Cluster(std::move(buffer_), bytes_used_)); Reset(); - return ret.Pass(); + return ret; } void ClusterBuilder::Reset() { diff --git a/media/formats/webm/opus_packet_builder.cc b/media/formats/webm/opus_packet_builder.cc index b2dd8dc..bd85c3c 100644 --- a/media/formats/webm/opus_packet_builder.cc +++ b/media/formats/webm/opus_packet_builder.cc @@ -83,7 +83,7 @@ ScopedVector<OpusPacket> BuildAllOpusPackets() { } } - return opus_packets.Pass(); + return opus_packets; } } // namespace media diff --git a/media/formats/webm/webm_cluster_parser.cc b/media/formats/webm/webm_cluster_parser.cc index 27094de..e4fb5bb 100644 --- a/media/formats/webm/webm_cluster_parser.cc +++ b/media/formats/webm/webm_cluster_parser.cc @@ -4,6 +4,7 @@ #include "media/formats/webm/webm_cluster_parser.h" +#include <utility> #include <vector> #include "base/logging.h" @@ -504,7 +505,7 @@ bool WebMClusterParser::OnBlock(bool is_simple_block, is_keyframe, buffer_type, track_num); if (decrypt_config) - buffer->set_decrypt_config(decrypt_config.Pass()); + buffer->set_decrypt_config(std::move(decrypt_config)); } else { std::string id, settings, content; WebMWebVTTParser::Parse(data, size, &id, &settings, &content); diff --git a/media/midi/midi_manager_alsa.cc b/media/midi/midi_manager_alsa.cc index e51a502..6110e56 100644 --- a/media/midi/midi_manager_alsa.cc +++ b/media/midi/midi_manager_alsa.cc @@ -387,7 +387,7 @@ scoped_ptr<base::Value> MidiManagerAlsa::MidiPort::Value() const { SetStringIfNonEmpty(value.get(), "usbInterfaceNum", id_.usb_interface_num()); SetStringIfNonEmpty(value.get(), "serial", id_.serial()); - return value.Pass(); + return std::move(value); } std::string MidiManagerAlsa::MidiPort::JSONValue() const { @@ -578,7 +578,7 @@ uint32_t MidiManagerAlsa::MidiPortState::push_back(scoped_ptr<MidiPort> port) { break; } port->set_web_port_index(web_port_index); - MidiPortStateBase::push_back(port.Pass()); + MidiPortStateBase::push_back(std::move(port)); return web_port_index; } @@ -705,7 +705,7 @@ MidiManagerAlsa::AlsaSeqState::ToMidiPortState(const AlsaCardMap& alsa_cards) { } } - return midi_ports.Pass(); + return midi_ports; } MidiManagerAlsa::AlsaSeqState::Port::Port( @@ -1176,7 +1176,7 @@ void MidiManagerAlsa::UpdatePortStateAndGenerateEvents() { const auto& client_id = new_port->client_id(); const auto& port_id = new_port->port_id(); - uint32_t web_port_index = port_state_.push_back(new_port.Pass()); + uint32_t web_port_index = port_state_.push_back(std::move(new_port)); it = new_port_state->erase(it); MidiPortInfo info(opaque_key, manufacturer, port_name, version, diff --git a/media/midi/midi_manager_alsa.h b/media/midi/midi_manager_alsa.h index eccd543..a84d5f0 100644 --- a/media/midi/midi_manager_alsa.h +++ b/media/midi/midi_manager_alsa.h @@ -8,6 +8,7 @@ #include <alsa/asoundlib.h> #include <stdint.h> #include <map> +#include <utility> #include <vector> #include "base/gtest_prod_util.h" @@ -196,7 +197,9 @@ class MIDI_EXPORT MidiManagerAlsa final : public MidiManager { protected: MidiPortStateBase(); iterator erase(iterator position) { return ports_.erase(position); } - void push_back(scoped_ptr<MidiPort> port) { ports_.push_back(port.Pass()); } + void push_back(scoped_ptr<MidiPort> port) { + ports_.push_back(std::move(port)); + } private: std::vector<scoped_ptr<MidiPort>> ports_; @@ -210,7 +213,7 @@ class MIDI_EXPORT MidiManagerAlsa final : public MidiManager { return MidiPortStateBase::erase(position); }; void push_back(scoped_ptr<MidiPort> port) { - MidiPortStateBase::push_back(port.Pass()); + MidiPortStateBase::push_back(std::move(port)); } }; diff --git a/media/midi/midi_manager_alsa_unittest.cc b/media/midi/midi_manager_alsa_unittest.cc index 4c91625..d5aee86 100644 --- a/media/midi/midi_manager_alsa_unittest.cc +++ b/media/midi/midi_manager_alsa_unittest.cc @@ -4,6 +4,8 @@ #include "media/midi/midi_manager_alsa.h" +#include <utility> + #include "testing/gtest/include/gtest/gtest.h" namespace media { @@ -376,10 +378,10 @@ TEST_F(MidiManagerAlsaTest, PortIndexSet) { port_input_1_->set_web_port_index(5000); port_output_1_->set_web_port_index(5000); - midi_port_state_0_.push_back(port_input_0_.Pass()); - midi_port_state_0_.push_back(port_output_0_.Pass()); - midi_port_state_0_.push_back(port_input_1_.Pass()); - midi_port_state_0_.push_back(port_output_1_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_)); + midi_port_state_0_.push_back(std::move(port_output_0_)); + midi_port_state_0_.push_back(std::move(port_input_1_)); + midi_port_state_0_.push_back(std::move(port_output_1_)); // First port of each type has index of 0. EXPECT_EQ(0U, port_input_0_tracking_pointer->web_port_index()); @@ -400,10 +402,10 @@ TEST_F(MidiManagerAlsaTest, PortIndexNotSet) { port_input_1_->set_web_port_index(5000); port_output_1_->set_web_port_index(5000); - temporary_midi_port_state_0_.push_back(port_input_0_.Pass()); - temporary_midi_port_state_0_.push_back(port_output_0_.Pass()); - temporary_midi_port_state_0_.push_back(port_input_1_.Pass()); - temporary_midi_port_state_0_.push_back(port_output_1_.Pass()); + temporary_midi_port_state_0_.push_back(std::move(port_input_0_)); + temporary_midi_port_state_0_.push_back(std::move(port_output_0_)); + temporary_midi_port_state_0_.push_back(std::move(port_input_1_)); + temporary_midi_port_state_0_.push_back(std::move(port_output_1_)); // web_port_index is untouched. EXPECT_EQ(0U, port_input_0_tracking_pointer->web_port_index()); @@ -420,12 +422,12 @@ TEST_F(MidiManagerAlsaTest, SeparateInputOutput) { auto* port_output_1_tracking_pointer = port_input_1_.get(); // First port of each type has index of 0. - EXPECT_EQ(0U, midi_port_state_0_.push_back(port_input_0_.Pass())); - EXPECT_EQ(0U, midi_port_state_0_.push_back(port_output_0_.Pass())); + EXPECT_EQ(0U, midi_port_state_0_.push_back(std::move(port_input_0_))); + EXPECT_EQ(0U, midi_port_state_0_.push_back(std::move(port_output_0_))); // Second port of each type has index of 1. - EXPECT_EQ(1U, midi_port_state_0_.push_back(port_input_1_.Pass())); - EXPECT_EQ(1U, midi_port_state_0_.push_back(port_output_1_.Pass())); + EXPECT_EQ(1U, midi_port_state_0_.push_back(std::move(port_input_1_))); + EXPECT_EQ(1U, midi_port_state_0_.push_back(std::move(port_output_1_))); // Check again that the field matches what was returned. EXPECT_EQ(0U, port_input_0_tracking_pointer->web_port_index()); @@ -440,7 +442,7 @@ TEST_F(MidiManagerAlsaTest, FindConnected) { auto* port_input_1_tracking_pointer = port_input_1_.get(); // Insert port_input_0. - midi_port_state_0_.push_back(port_input_0_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_)); // Look for port_input_1 (every field matches port_input_0). auto it = midi_port_state_0_.FindConnected(*port_input_1_tracking_pointer); EXPECT_EQ(port_input_0_tracking_pointer, it->get()); @@ -454,13 +456,13 @@ TEST_F(MidiManagerAlsaTest, FindConnected2) { auto* port_input_1_tracking_pointer = port_input_1_.get(); // Insert some stuff. - midi_port_state_0_.push_back(port_input_0_alt_path_.Pass()); - midi_port_state_0_.push_back(port_input_0_alt_id_.Pass()); - midi_port_state_0_.push_back(port_input_0_alt_client_name_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_alt_path_)); + midi_port_state_0_.push_back(std::move(port_input_0_alt_id_)); + midi_port_state_0_.push_back(std::move(port_input_0_alt_client_name_)); // Insert port_input_0. - midi_port_state_0_.push_back(port_input_0_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_)); // Insert some more stuff. - midi_port_state_0_.push_back(port_input_0_alt_port_id_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_alt_port_id_)); // Look for port_input_1 (matches to port_input_0). auto it = midi_port_state_0_.FindConnected(*port_input_1_tracking_pointer); EXPECT_EQ(port_input_0_tracking_pointer, it->get()); @@ -493,17 +495,17 @@ TEST_F(MidiManagerAlsaTest, FindDisconnected2) { port_input_0_->set_connected(false); // Insert some stuff. - midi_port_state_0_.push_back(port_input_0_alt_id_.Pass()); - midi_port_state_0_.push_back(port_input_0_alt_path_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_alt_id_)); + midi_port_state_0_.push_back(std::move(port_input_0_alt_path_)); // Insert port_input_0. - midi_port_state_0_.push_back(port_input_0_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_)); // Add "no card" stuff. port_input_1_no_card_->set_connected(false); - midi_port_state_0_.push_back(port_input_1_no_card_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_1_no_card_)); // Insert some more stuff. - midi_port_state_0_.push_back(port_input_0_alt_port_id_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_alt_port_id_)); // Look for port_input_1, should trigger exact match. EXPECT_EQ(port_input_0_tracking_pointer, @@ -530,12 +532,12 @@ TEST_F(MidiManagerAlsaTest, FindDisconnected3) { port_input_0_->set_connected(false); // Insert some stuff. - midi_port_state_0_.push_back(port_input_0_alt_path_.Pass()); - midi_port_state_0_.push_back(port_input_0_alt_id_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_0_alt_path_)); + midi_port_state_0_.push_back(std::move(port_input_0_alt_id_)); // Add no card stuff. port_input_1_no_card_->set_connected(false); - midi_port_state_0_.push_back(port_input_1_no_card_.Pass()); + midi_port_state_0_.push_back(std::move(port_input_1_no_card_)); // Look for port_input_0, should find port_input_0_alt_path. EXPECT_EQ(port_input_0_alt_path_tracking_pointer, diff --git a/media/midi/midi_manager_usb.cc b/media/midi/midi_manager_usb.cc index 9dd93f4..64633b9 100644 --- a/media/midi/midi_manager_usb.cc +++ b/media/midi/midi_manager_usb.cc @@ -4,6 +4,8 @@ #include "media/midi/midi_manager_usb.h" +#include <utility> + #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/strings/stringprintf.h" @@ -14,8 +16,7 @@ namespace media { namespace midi { MidiManagerUsb::MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> factory) - : device_factory_(factory.Pass()) { -} + : device_factory_(std::move(factory)) {} MidiManagerUsb::~MidiManagerUsb() { } @@ -69,7 +70,7 @@ void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, void MidiManagerUsb::OnDeviceAttached(scoped_ptr<UsbMidiDevice> device) { int device_id = static_cast<int>(devices_.size()); - devices_.push_back(device.Pass()); + devices_.push_back(std::move(device)); AddPorts(devices_.back(), device_id); } diff --git a/media/midi/midi_manager_usb_unittest.cc b/media/midi/midi_manager_usb_unittest.cc index 662ec19..2eefb49 100644 --- a/media/midi/midi_manager_usb_unittest.cc +++ b/media/midi/midi_manager_usb_unittest.cc @@ -6,8 +6,8 @@ #include <stddef.h> #include <stdint.h> - #include <string> +#include <utility> #include "base/macros.h" #include "base/message_loop/message_loop.h" @@ -167,7 +167,7 @@ class MidiManagerUsbForTesting : public MidiManagerUsb { public: explicit MidiManagerUsbForTesting( scoped_ptr<UsbMidiDevice::Factory> device_factory) - : MidiManagerUsb(device_factory.Pass()) {} + : MidiManagerUsb(std::move(device_factory)) {} ~MidiManagerUsbForTesting() override {} void CallCompleteInitialization(Result result) { @@ -185,7 +185,7 @@ class MidiManagerUsbTest : public ::testing::Test { MidiManagerUsbTest() : message_loop_(new base::MessageLoop) { scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory); factory_ = factory.get(); - manager_.reset(new MidiManagerUsbForTesting(factory.Pass())); + manager_.reset(new MidiManagerUsbForTesting(std::move(factory))); } ~MidiManagerUsbTest() override { manager_->Shutdown(); @@ -262,7 +262,7 @@ TEST_F(MidiManagerUsbTest, Initialize) { Initialize(); ScopedVector<UsbMidiDevice> devices; - devices.push_back(device.Pass()); + devices.push_back(std::move(device)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::OK, GetInitializationResult()); @@ -322,8 +322,8 @@ TEST_F(MidiManagerUsbTest, InitializeMultipleDevices) { Initialize(); ScopedVector<UsbMidiDevice> devices; - devices.push_back(device1.Pass()); - devices.push_back(device2.Pass()); + devices.push_back(std::move(device1)); + devices.push_back(std::move(device2)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::OK, GetInitializationResult()); @@ -385,7 +385,7 @@ TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptors) { Initialize(); ScopedVector<UsbMidiDevice> devices; - devices.push_back(device.Pass()); + devices.push_back(std::move(device)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); @@ -416,7 +416,7 @@ TEST_F(MidiManagerUsbTest, Send) { }; ScopedVector<UsbMidiDevice> devices; - devices.push_back(device.Pass()); + devices.push_back(std::move(device)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::OK, GetInitializationResult()); @@ -460,7 +460,7 @@ TEST_F(MidiManagerUsbTest, SendFromCompromizedRenderer) { Initialize(); ScopedVector<UsbMidiDevice> devices; - devices.push_back(device.Pass()); + devices.push_back(std::move(device)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::OK, GetInitializationResult()); @@ -503,7 +503,7 @@ TEST_F(MidiManagerUsbTest, Receive) { Initialize(); ScopedVector<UsbMidiDevice> devices; UsbMidiDevice* device_raw = device.get(); - devices.push_back(device.Pass()); + devices.push_back(std::move(device)); EXPECT_FALSE(IsInitializationCallbackInvoked()); RunCallbackUntilCallbackInvoked(true, &devices); EXPECT_EQ(Result::OK, GetInitializationResult()); @@ -554,7 +554,7 @@ TEST_F(MidiManagerUsbTest, AttachDevice) { scoped_ptr<FakeUsbMidiDevice> new_device(new FakeUsbMidiDevice(&logger_)); new_device->SetDescriptors(ToVector(descriptors)); - manager_->OnDeviceAttached(new_device.Pass()); + manager_->OnDeviceAttached(std::move(new_device)); ASSERT_EQ(1u, input_ports().size()); ASSERT_EQ(2u, output_ports().size()); diff --git a/media/mojo/services/demuxer_stream_provider_shim.cc b/media/mojo/services/demuxer_stream_provider_shim.cc index 2c16cc5..86c8394 100644 --- a/media/mojo/services/demuxer_stream_provider_shim.cc +++ b/media/mojo/services/demuxer_stream_provider_shim.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/demuxer_stream_provider_shim.h" +#include <utility> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback_helpers.h" @@ -22,16 +24,14 @@ DemuxerStreamProviderShim::DemuxerStreamProviderShim( if (audio) { streams_.push_back(new MojoDemuxerStreamAdapter( - audio.Pass(), - base::Bind(&DemuxerStreamProviderShim::OnStreamReady, - weak_factory_.GetWeakPtr()))); + std::move(audio), base::Bind(&DemuxerStreamProviderShim::OnStreamReady, + weak_factory_.GetWeakPtr()))); } if (video) { streams_.push_back(new MojoDemuxerStreamAdapter( - video.Pass(), - base::Bind(&DemuxerStreamProviderShim::OnStreamReady, - weak_factory_.GetWeakPtr()))); + std::move(video), base::Bind(&DemuxerStreamProviderShim::OnStreamReady, + weak_factory_.GetWeakPtr()))); } } diff --git a/media/mojo/services/media_apptest.cc b/media/mojo/services/media_apptest.cc index 6064d34..be5e4ab 100644 --- a/media/mojo/services/media_apptest.cc +++ b/media/mojo/services/media_apptest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -106,7 +107,8 @@ class MediaAppTest : public mojo::test::ApplicationTestBase { EXPECT_CALL(*this, OnRendererInitialized(expected_result)) .Times(Exactly(1)) .WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit)); - renderer_->Initialize(client_ptr.Pass(), nullptr, video_stream.Pass(), + renderer_->Initialize(std::move(client_ptr), nullptr, + std::move(video_stream), base::Bind(&MediaAppTest::OnRendererInitialized, base::Unretained(this))); } diff --git a/media/mojo/services/media_type_converters.cc b/media/mojo/services/media_type_converters.cc index db6d1e8..d3cc1e3 100644 --- a/media/mojo/services/media_type_converters.cc +++ b/media/mojo/services/media_type_converters.cc @@ -360,7 +360,7 @@ media::interfaces::SubsampleEntryPtr TypeConverter< media::interfaces::SubsampleEntry::New()); mojo_subsample_entry->clear_bytes = input.clear_bytes; mojo_subsample_entry->cypher_bytes = input.cypher_bytes; - return mojo_subsample_entry.Pass(); + return mojo_subsample_entry; } // static @@ -380,7 +380,7 @@ media::interfaces::DecryptConfigPtr TypeConverter< mojo_decrypt_config->iv = input.iv(); mojo_decrypt_config->subsamples = Array<media::interfaces::SubsampleEntryPtr>::From(input.subsamples()); - return mojo_decrypt_config.Pass(); + return mojo_decrypt_config; } // static @@ -403,7 +403,7 @@ TypeConverter<media::interfaces::DecoderBufferPtr, media::interfaces::DecoderBufferPtr mojo_buffer( media::interfaces::DecoderBuffer::New()); if (input->end_of_stream()) - return mojo_buffer.Pass(); + return mojo_buffer; mojo_buffer->timestamp_usec = input->timestamp().InMicroseconds(); mojo_buffer->duration_usec = input->duration().InMicroseconds(); @@ -431,7 +431,7 @@ TypeConverter<media::interfaces::DecoderBufferPtr, // the DecoderBuffer here; this must instead be done by clients via their // own DataPipe. See http://crbug.com/432960 - return mojo_buffer.Pass(); + return mojo_buffer; } // static @@ -494,7 +494,7 @@ media::interfaces::AudioDecoderConfigPtr TypeConverter< config->seek_preroll_usec = input.seek_preroll().InMicroseconds(); config->codec_delay = input.codec_delay(); config->is_encrypted = input.is_encrypted(); - return config.Pass(); + return config; } // static @@ -531,7 +531,7 @@ media::interfaces::VideoDecoderConfigPtr TypeConverter< config->natural_size = Size::From(input.natural_size()); config->extra_data = mojo::Array<uint8_t>::From(input.extra_data()); config->is_encrypted = input.is_encrypted(); - return config.Pass(); + return config; } // static @@ -561,7 +561,7 @@ media::interfaces::CdmKeyInformationPtr TypeConverter< info->key_id.Swap(&key_id_copy); info->status = static_cast<media::interfaces::CdmKeyStatus>(input.status); info->system_code = input.system_code; - return info.Pass(); + return info; } // static @@ -583,7 +583,7 @@ TypeConverter<media::interfaces::CdmConfigPtr, media::CdmConfig>::Convert( config->allow_distinctive_identifier = input.allow_distinctive_identifier; config->allow_persistent_state = input.allow_persistent_state; config->use_hw_secure_codecs = input.use_hw_secure_codecs; - return config.Pass(); + return config; } // static @@ -620,7 +620,7 @@ TypeConverter<media::interfaces::AudioBufferPtr, buffer->data.Swap(&input_data); } - return buffer.Pass(); + return buffer; } // static @@ -657,7 +657,7 @@ TypeConverter<media::interfaces::VideoFramePtr, buffer->end_of_stream = input->metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM); if (buffer->end_of_stream) - return buffer.Pass(); + return buffer; // handle non EOS buffer. buffer->format = static_cast<media::interfaces::VideoFormat>(input->format()); @@ -682,7 +682,7 @@ TypeConverter<media::interfaces::VideoFramePtr, buffer->v_data.Swap(&v_data); } - return buffer.Pass(); + return buffer; } // static diff --git a/media/mojo/services/mojo_cdm.cc b/media/mojo/services/mojo_cdm.cc index 0ce8815..31dd4a7 100644 --- a/media/mojo/services/mojo_cdm.cc +++ b/media/mojo/services/mojo_cdm.cc @@ -42,7 +42,7 @@ void MojoCdm::Create( const media::SessionExpirationUpdateCB& session_expiration_update_cb, const media::CdmCreatedCB& cdm_created_cb) { scoped_refptr<MojoCdm> mojo_cdm( - new MojoCdm(remote_cdm.Pass(), session_message_cb, session_closed_cb, + new MojoCdm(std::move(remote_cdm), session_message_cb, session_closed_cb, legacy_session_error_cb, session_keys_change_cb, session_expiration_update_cb)); @@ -51,7 +51,7 @@ void MojoCdm::Create( new CdmInitializedPromise(cdm_created_cb, mojo_cdm)); mojo_cdm->InitializeCdm(key_system, security_origin, cdm_config, - promise.Pass()); + std::move(promise)); } MojoCdm::MojoCdm(interfaces::ContentDecryptionModulePtr remote_cdm, @@ -60,7 +60,7 @@ MojoCdm::MojoCdm(interfaces::ContentDecryptionModulePtr remote_cdm, const LegacySessionErrorCB& legacy_session_error_cb, const SessionKeysChangeCB& session_keys_change_cb, const SessionExpirationUpdateCB& session_expiration_update_cb) - : remote_cdm_(remote_cdm.Pass()), + : remote_cdm_(std::move(remote_cdm)), binding_(this), cdm_id_(CdmContext::kInvalidCdmId), session_message_cb_(session_message_cb), @@ -78,7 +78,7 @@ MojoCdm::MojoCdm(interfaces::ContentDecryptionModulePtr remote_cdm, interfaces::ContentDecryptionModuleClientPtr client_ptr; binding_.Bind(GetProxy(&client_ptr)); - remote_cdm_->SetClient(client_ptr.Pass()); + remote_cdm_->SetClient(std::move(client_ptr)); } MojoCdm::~MojoCdm() { @@ -229,7 +229,7 @@ void MojoCdm::OnSessionKeysChange( keys_info[i].To<scoped_ptr<media::CdmKeyInformation>>().release()); } session_keys_change_cb_.Run(session_id, has_additional_usable_key, - key_data.Pass()); + std::move(key_data)); } void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id, @@ -245,7 +245,7 @@ void MojoCdm::OnCdmInitialized(scoped_ptr<CdmInitializedPromise> promise, interfaces::DecryptorPtr decryptor) { DVLOG(2) << __FUNCTION__ << " cdm_id: " << cdm_id; if (!result->success) { - RejectPromise(promise.Pass(), result.Pass()); + RejectPromise(std::move(promise), std::move(result)); return; } diff --git a/media/mojo/services/mojo_cdm.h b/media/mojo/services/mojo_cdm.h index 6ff7d109..6e39dff 100644 --- a/media/mojo/services/mojo_cdm.h +++ b/media/mojo/services/mojo_cdm.h @@ -6,7 +6,7 @@ #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ #include <stdint.h> - +#include <utility> #include <vector> #include "base/macros.h" @@ -121,7 +121,7 @@ class MojoCdm : public MediaKeys, if (result->success) promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. else - RejectPromise(promise.Pass(), result.Pass()); + RejectPromise(std::move(promise), std::move(result)); } interfaces::ContentDecryptionModulePtr remote_cdm_; diff --git a/media/mojo/services/mojo_cdm_factory.cc b/media/mojo/services/mojo_cdm_factory.cc index 3937c10..063044e 100644 --- a/media/mojo/services/mojo_cdm_factory.cc +++ b/media/mojo/services/mojo_cdm_factory.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/mojo_cdm_factory.h" +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/single_thread_task_runner.h" @@ -56,7 +58,7 @@ void MojoCdmFactory::Create( interfaces::ContentDecryptionModulePtr cdm_ptr; service_factory_->CreateCdm(mojo::GetProxy(&cdm_ptr)); - MojoCdm::Create(key_system, security_origin, cdm_config, cdm_ptr.Pass(), + MojoCdm::Create(key_system, security_origin, cdm_config, std::move(cdm_ptr), session_message_cb, session_closed_cb, legacy_session_error_cb, session_keys_change_cb, session_expiration_update_cb, cdm_created_cb); diff --git a/media/mojo/services/mojo_cdm_promise.cc b/media/mojo/services/mojo_cdm_promise.cc index 6fa1a5a..25131b2 100644 --- a/media/mojo/services/mojo_cdm_promise.cc +++ b/media/mojo/services/mojo_cdm_promise.cc @@ -5,6 +5,7 @@ #include "media/mojo/services/mojo_cdm_promise.h" #include <string> +#include <utility> #include <vector> #include "base/bind.h" @@ -25,7 +26,7 @@ static interfaces::CdmPromiseResultPtr GetRejectResult( static_cast<interfaces::CdmException>(exception); cdm_promise_result->system_code = system_code; cdm_promise_result->error_message = error_message; - return cdm_promise_result.Pass(); + return cdm_promise_result; } template <typename... T> @@ -47,7 +48,7 @@ void MojoCdmPromise<T...>::resolve(const T&... result) { interfaces::CdmPromiseResult::New()); cdm_promise_result->success = true; callback_.Run( - cdm_promise_result.Pass(), + std::move(cdm_promise_result), mojo::TypeConverter<typename MojoTypeTrait<T>::MojoType, T>::Convert( result)...); callback_.reset(); diff --git a/media/mojo/services/mojo_cdm_service.cc b/media/mojo/services/mojo_cdm_service.cc index 95a07d0..991d016 100644 --- a/media/mojo/services/mojo_cdm_service.cc +++ b/media/mojo/services/mojo_cdm_service.cc @@ -82,7 +82,7 @@ MojoCdmService::MojoCdmService( mojo::ServiceProvider* service_provider, CdmFactory* cdm_factory, mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request) - : binding_(this, request.Pass()), + : binding_(this, std::move(request)), context_(context), service_provider_(service_provider), cdm_factory_(cdm_factory), @@ -101,7 +101,7 @@ MojoCdmService::~MojoCdmService() { void MojoCdmService::SetClient( interfaces::ContentDecryptionModuleClientPtr client) { - client_ = client.Pass(); + client_ = std::move(client); } void MojoCdmService::Initialize(const mojo::String& key_system, @@ -247,7 +247,7 @@ void MojoCdmService::OnSessionKeysChange(const std::string& session_id, for (const auto& key : keys_info) keys_data.push_back(interfaces::CdmKeyInformation::From(*key)); client_->OnSessionKeysChange(session_id, has_additional_usable_key, - keys_data.Pass()); + std::move(keys_data)); } void MojoCdmService::OnSessionExpirationUpdate( diff --git a/media/mojo/services/mojo_decryptor_service.cc b/media/mojo/services/mojo_decryptor_service.cc index 60d634d..ad068b4 100644 --- a/media/mojo/services/mojo_decryptor_service.cc +++ b/media/mojo/services/mojo_decryptor_service.cc @@ -25,7 +25,7 @@ MojoDecryptorService::MojoDecryptorService( const scoped_refptr<MediaKeys>& cdm, mojo::InterfaceRequest<interfaces::Decryptor> request, const mojo::Closure& error_handler) - : binding_(this, request.Pass()), cdm_(cdm), weak_factory_(this) { + : binding_(this, std::move(request)), cdm_(cdm), weak_factory_(this) { decryptor_ = cdm->GetCdmContext()->GetDecryptor(); DCHECK(decryptor_); weak_this_ = weak_factory_.GetWeakPtr(); @@ -148,9 +148,10 @@ void MojoDecryptorService::OnAudioDecoded( << status << ")"; mojo::Array<interfaces::AudioBufferPtr> audio_buffers; for (const auto& frame : frames) - audio_buffers.push_back(interfaces::AudioBuffer::From(frame).Pass()); + audio_buffers.push_back(interfaces::AudioBuffer::From(frame)); - callback.Run(static_cast<Decryptor::Status>(status), audio_buffers.Pass()); + callback.Run(static_cast<Decryptor::Status>(status), + std::move(audio_buffers)); } void MojoDecryptorService::OnVideoDecoded( @@ -166,7 +167,7 @@ void MojoDecryptorService::OnVideoDecoded( } callback.Run(static_cast<Decryptor::Status>(status), - interfaces::VideoFrame::From(frame).Pass()); + interfaces::VideoFrame::From(frame)); } interfaces::DecoderBufferPtr MojoDecryptorService::TransferDecoderBuffer( diff --git a/media/mojo/services/mojo_demuxer_stream_adapter.cc b/media/mojo/services/mojo_demuxer_stream_adapter.cc index 2f79704..850f7bc 100644 --- a/media/mojo/services/mojo_demuxer_stream_adapter.cc +++ b/media/mojo/services/mojo_demuxer_stream_adapter.cc @@ -5,6 +5,7 @@ #include "media/mojo/services/mojo_demuxer_stream_adapter.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/callback_helpers.h" @@ -17,7 +18,7 @@ namespace media { MojoDemuxerStreamAdapter::MojoDemuxerStreamAdapter( interfaces::DemuxerStreamPtr demuxer_stream, const base::Closure& stream_ready_cb) - : demuxer_stream_(demuxer_stream.Pass()), + : demuxer_stream_(std::move(demuxer_stream)), stream_ready_cb_(stream_ready_cb), type_(DemuxerStream::UNKNOWN), weak_factory_(this) { @@ -79,8 +80,8 @@ void MojoDemuxerStreamAdapter::OnStreamReady( DCHECK_EQ(DemuxerStream::UNKNOWN, type_); type_ = static_cast<DemuxerStream::Type>(type); - stream_pipe_ = pipe.Pass(); - UpdateConfig(audio_config.Pass(), video_config.Pass()); + stream_pipe_ = std::move(pipe); + UpdateConfig(std::move(audio_config), std::move(video_config)); stream_ready_cb_.Run(); } @@ -96,7 +97,7 @@ void MojoDemuxerStreamAdapter::OnBufferReady( DCHECK(stream_pipe_.is_valid()); if (status == interfaces::DemuxerStream::STATUS_CONFIG_CHANGED) { - UpdateConfig(audio_config.Pass(), video_config.Pass()); + UpdateConfig(std::move(audio_config), std::move(video_config)); base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kConfigChanged, nullptr); return; } diff --git a/media/mojo/services/mojo_demuxer_stream_impl.cc b/media/mojo/services/mojo_demuxer_stream_impl.cc index 7c162f8..40f2059 100644 --- a/media/mojo/services/mojo_demuxer_stream_impl.cc +++ b/media/mojo/services/mojo_demuxer_stream_impl.cc @@ -5,6 +5,7 @@ #include "media/mojo/services/mojo_demuxer_stream_impl.h" #include <stdint.h> +#include <utility> #include "base/bind.h" #include "media/base/audio_decoder_config.h" @@ -18,7 +19,9 @@ namespace media { MojoDemuxerStreamImpl::MojoDemuxerStreamImpl( media::DemuxerStream* stream, mojo::InterfaceRequest<interfaces::DemuxerStream> request) - : binding_(this, request.Pass()), stream_(stream), weak_factory_(this) {} + : binding_(this, std::move(request)), + stream_(stream), + weak_factory_(this) {} MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() { } @@ -45,7 +48,7 @@ void MojoDemuxerStreamImpl::Initialize(const InitializeCallback& callback) { } mojo::DataPipe data_pipe(options); - stream_pipe_ = data_pipe.producer_handle.Pass(); + stream_pipe_ = std::move(data_pipe.producer_handle); // Prepare the initial config. interfaces::AudioDecoderConfigPtr audio_config; @@ -62,8 +65,8 @@ void MojoDemuxerStreamImpl::Initialize(const InitializeCallback& callback) { } callback.Run(static_cast<interfaces::DemuxerStream::Type>(stream_->type()), - data_pipe.consumer_handle.Pass(), audio_config.Pass(), - video_config.Pass()); + std::move(data_pipe.consumer_handle), std::move(audio_config), + std::move(video_config)); } void MojoDemuxerStreamImpl::Read(const ReadCallback& callback) { @@ -94,15 +97,15 @@ void MojoDemuxerStreamImpl::OnBufferReady( } callback.Run(interfaces::DemuxerStream::STATUS_CONFIG_CHANGED, - interfaces::DecoderBufferPtr(), audio_config.Pass(), - video_config.Pass()); + interfaces::DecoderBufferPtr(), std::move(audio_config), + std::move(video_config)); return; } if (status == media::DemuxerStream::kAborted) { callback.Run(interfaces::DemuxerStream::STATUS_ABORTED, - interfaces::DecoderBufferPtr(), audio_config.Pass(), - video_config.Pass()); + interfaces::DecoderBufferPtr(), std::move(audio_config), + std::move(video_config)); return; } @@ -121,8 +124,8 @@ void MojoDemuxerStreamImpl::OnBufferReady( // the producer handle and then read more to keep the pipe full. Waiting for // space can be accomplished using an AsyncWaiter. callback.Run(static_cast<interfaces::DemuxerStream::Status>(status), - interfaces::DecoderBuffer::From(buffer), audio_config.Pass(), - video_config.Pass()); + interfaces::DecoderBuffer::From(buffer), std::move(audio_config), + std::move(video_config)); } } // namespace media diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc index 41e2fee..2770fc8 100644 --- a/media/mojo/services/mojo_media_application.cc +++ b/media/mojo/services/mojo_media_application.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/mojo_media_application.h" +#include <utility> + #include "base/logging.h" #include "media/base/media_log.h" #include "media/mojo/services/mojo_media_client.h" @@ -57,7 +59,7 @@ void MojoMediaApplication::Create( mojo::ApplicationConnection* connection, mojo::InterfaceRequest<interfaces::ServiceFactory> request) { // The created object is owned by the pipe. - new ServiceFactoryImpl(request.Pass(), connection->GetServiceProvider(), + new ServiceFactoryImpl(std::move(request), connection->GetServiceProvider(), media_log_, app_impl_->app_lifetime_helper()->CreateAppRefCount(), mojo_media_client_.get()); diff --git a/media/mojo/services/mojo_renderer_factory.cc b/media/mojo/services/mojo_renderer_factory.cc index 8112c7c..3c198d1 100644 --- a/media/mojo/services/mojo_renderer_factory.cc +++ b/media/mojo/services/mojo_renderer_factory.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/mojo_renderer_factory.h" +#include <utility> + #include "base/single_thread_task_runner.h" #include "media/mojo/interfaces/service_factory.mojom.h" #include "media/mojo/services/mojo_renderer_impl.h" @@ -31,7 +33,7 @@ scoped_ptr<Renderer> MojoRendererFactory::CreateRenderer( service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer)); return scoped_ptr<Renderer>( - new MojoRendererImpl(media_task_runner, mojo_renderer.Pass())); + new MojoRendererImpl(media_task_runner, std::move(mojo_renderer))); } } // namespace media diff --git a/media/mojo/services/mojo_renderer_impl.cc b/media/mojo/services/mojo_renderer_impl.cc index b6545b4..4403a30 100644 --- a/media/mojo/services/mojo_renderer_impl.cc +++ b/media/mojo/services/mojo_renderer_impl.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/mojo_renderer_impl.h" +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" @@ -20,7 +22,7 @@ MojoRendererImpl::MojoRendererImpl( const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, interfaces::RendererPtr remote_renderer) : task_runner_(task_runner), - remote_renderer_(remote_renderer.Pass()), + remote_renderer_(std::move(remote_renderer)), weak_factory_(this) { DVLOG(1) << __FUNCTION__; } @@ -69,7 +71,7 @@ void MojoRendererImpl::Initialize( binding_.reset( new mojo::Binding<RendererClient>(this, GetProxy(&client_ptr))); remote_renderer_->Initialize( - client_ptr.Pass(), audio_stream.Pass(), video_stream.Pass(), + std::move(client_ptr), std::move(audio_stream), std::move(video_stream), BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, weak_factory_.GetWeakPtr()))); } diff --git a/media/mojo/services/mojo_renderer_service.cc b/media/mojo/services/mojo_renderer_service.cc index d0d04d9..f491500 100644 --- a/media/mojo/services/mojo_renderer_service.cc +++ b/media/mojo/services/mojo_renderer_service.cc @@ -4,6 +4,8 @@ #include "media/mojo/services/mojo_renderer_service.h" +#include <utility> + #include "base/bind.h" #include "media/base/renderer.h" #include "media/mojo/services/demuxer_stream_provider_shim.h" @@ -17,9 +19,9 @@ MojoRendererService::MojoRendererService( base::WeakPtr<CdmContextProvider> cdm_context_provider, scoped_ptr<media::Renderer> renderer, mojo::InterfaceRequest<interfaces::Renderer> request) - : binding_(this, request.Pass()), + : binding_(this, std::move(request)), cdm_context_provider_(cdm_context_provider), - renderer_(renderer.Pass()), + renderer_(std::move(renderer)), state_(STATE_UNINITIALIZED), last_media_time_usec_(0), weak_factory_(this) { @@ -37,11 +39,10 @@ void MojoRendererService::Initialize( const mojo::Callback<void(bool)>& callback) { DVLOG(1) << __FUNCTION__; DCHECK_EQ(state_, STATE_UNINITIALIZED); - client_ = client.Pass(); + client_ = std::move(client); state_ = STATE_INITIALIZING; stream_provider_.reset(new DemuxerStreamProviderShim( - audio.Pass(), - video.Pass(), + std::move(audio), std::move(video), base::Bind(&MojoRendererService::OnStreamReady, weak_this_, callback))); } diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc index 4611055..e6d48a6 100644 --- a/media/renderers/audio_renderer_impl.cc +++ b/media/renderers/audio_renderer_impl.cc @@ -6,8 +6,8 @@ #include <math.h> #include <stddef.h> - #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/callback.h" @@ -55,7 +55,7 @@ AudioRendererImpl::AudioRendererImpl( expecting_config_changes_(false), sink_(sink), audio_buffer_stream_( - new AudioBufferStream(task_runner, decoders.Pass(), media_log)), + new AudioBufferStream(task_runner, std::move(decoders), media_log)), hardware_config_(hardware_config), media_log_(media_log), tick_clock_(new base::DefaultTickClock()), diff --git a/media/renderers/audio_renderer_impl_unittest.cc b/media/renderers/audio_renderer_impl_unittest.cc index df8733b..23f36e3 100644 --- a/media/renderers/audio_renderer_impl_unittest.cc +++ b/media/renderers/audio_renderer_impl_unittest.cc @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "media/renderers/audio_renderer_impl.h" + +#include <utility> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/format_macros.h" @@ -17,7 +21,6 @@ #include "media/base/media_util.h" #include "media/base/mock_filters.h" #include "media/base/test_helpers.h" -#include "media/renderers/audio_renderer_impl.h" #include "testing/gtest/include/gtest/gtest.h" using ::base::TimeDelta; @@ -97,10 +100,8 @@ class AudioRendererImplTest : public ::testing::Test { decoders.push_back(decoder_); sink_ = new FakeAudioRendererSink(); renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(), - sink_.get(), - decoders.Pass(), - hardware_config_, - new MediaLog())); + sink_.get(), std::move(decoders), + hardware_config_, new MediaLog())); renderer_->tick_clock_.reset(tick_clock_); tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); } diff --git a/media/renderers/default_renderer_factory.cc b/media/renderers/default_renderer_factory.cc index 89429fb..b708ad9 100644 --- a/media/renderers/default_renderer_factory.cc +++ b/media/renderers/default_renderer_factory.cc @@ -4,9 +4,11 @@ #include "media/renderers/default_renderer_factory.h" +#include <utility> + #include "base/bind.h" -#include "build/build_config.h" #include "base/single_thread_task_runner.h" +#include "build/build_config.h" #include "media/base/media_log.h" #include "media/filters/gpu_video_decoder.h" #include "media/filters/opus_audio_decoder.h" @@ -57,7 +59,7 @@ scoped_ptr<Renderer> DefaultRendererFactory::CreateRenderer( audio_decoders.push_back(new OpusAudioDecoder(media_task_runner)); scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl( - media_task_runner, audio_renderer_sink, audio_decoders.Pass(), + media_task_runner, audio_renderer_sink, std::move(audio_decoders), audio_hardware_config_, media_log_)); // Create our video decoders and renderer. @@ -82,11 +84,11 @@ scoped_ptr<Renderer> DefaultRendererFactory::CreateRenderer( scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl( media_task_runner, worker_task_runner, video_renderer_sink, - video_decoders.Pass(), true, gpu_factories_, media_log_)); + std::move(video_decoders), true, gpu_factories_, media_log_)); // Create renderer. return scoped_ptr<Renderer>(new RendererImpl( - media_task_runner, audio_renderer.Pass(), video_renderer.Pass())); + media_task_runner, std::move(audio_renderer), std::move(video_renderer))); } } // namespace media diff --git a/media/renderers/renderer_impl.cc b/media/renderers/renderer_impl.cc index a7bd113..0f6a4f3e 100644 --- a/media/renderers/renderer_impl.cc +++ b/media/renderers/renderer_impl.cc @@ -4,6 +4,8 @@ #include "media/renderers/renderer_impl.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" @@ -31,8 +33,8 @@ RendererImpl::RendererImpl( scoped_ptr<VideoRenderer> video_renderer) : state_(STATE_UNINITIALIZED), task_runner_(task_runner), - audio_renderer_(audio_renderer.Pass()), - video_renderer_(video_renderer.Pass()), + audio_renderer_(std::move(audio_renderer)), + video_renderer_(std::move(video_renderer)), time_source_(NULL), time_ticking_(false), playback_rate_(0.0), diff --git a/media/renderers/renderer_impl_unittest.cc b/media/renderers/renderer_impl_unittest.cc index 7c5a69b..bbc0e98 100644 --- a/media/renderers/renderer_impl_unittest.cc +++ b/media/renderers/renderer_impl_unittest.cc @@ -85,7 +85,7 @@ class RendererImplTest : public ::testing::Test { DemuxerStream::Type type) { scoped_ptr<StrictMock<MockDemuxerStream> > stream( new StrictMock<MockDemuxerStream>(type)); - return stream.Pass(); + return stream; } // Sets up expectations to allow the audio renderer to initialize. diff --git a/media/renderers/video_renderer_impl.cc b/media/renderers/video_renderer_impl.cc index f53d593..e9eb078 100644 --- a/media/renderers/video_renderer_impl.cc +++ b/media/renderers/video_renderer_impl.cc @@ -4,6 +4,8 @@ #include "media/renderers/video_renderer_impl.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" @@ -35,8 +37,9 @@ VideoRendererImpl::VideoRendererImpl( : task_runner_(media_task_runner), sink_(sink), sink_started_(false), - video_frame_stream_( - new VideoFrameStream(media_task_runner, decoders.Pass(), media_log)), + video_frame_stream_(new VideoFrameStream(media_task_runner, + std::move(decoders), + media_log)), gpu_memory_buffer_pool_(nullptr), media_log_(media_log), low_delay_(false), diff --git a/media/renderers/video_renderer_impl_unittest.cc b/media/renderers/video_renderer_impl_unittest.cc index 3d14c47..332b945 100644 --- a/media/renderers/video_renderer_impl_unittest.cc +++ b/media/renderers/video_renderer_impl_unittest.cc @@ -67,7 +67,7 @@ class VideoRendererImplTest renderer_.reset(new VideoRendererImpl( message_loop_.task_runner(), message_loop_.task_runner().get(), - null_video_sink_.get(), decoders.Pass(), true, + null_video_sink_.get(), std::move(decoders), true, nullptr, // gpu_factories new MediaLog())); renderer_->SetTickClockForTesting(scoped_ptr<base::TickClock>(tick_clock_)); @@ -748,7 +748,8 @@ class VideoRendererImplAsyncAddFrameReadyTest : public VideoRendererImplTest { VideoRendererImplAsyncAddFrameReadyTest() { scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool( new MockGpuMemoryBufferVideoFramePool(&frame_ready_cbs_)); - renderer_->SetGpuMemoryBufferVideoForTesting(gpu_memory_buffer_pool.Pass()); + renderer_->SetGpuMemoryBufferVideoForTesting( + std::move(gpu_memory_buffer_pool)); } protected: diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc index eb0037f2..0644c36 100644 --- a/media/test/pipeline_integration_test.cc +++ b/media/test/pipeline_integration_test.cc @@ -4,6 +4,7 @@ #include <stddef.h> #include <stdint.h> +#include <utility> #include "base/bind.h" #include "base/command_line.h" @@ -236,7 +237,7 @@ class FakeEncryptedMedia { bool has_additional_usable_key, CdmKeysInfo keys_info) { app_->OnSessionKeysChange(session_id, has_additional_usable_key, - keys_info.Pass()); + std::move(keys_info)); } void OnLegacySessionError(const std::string& session_id, @@ -300,7 +301,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { &KeyProvidingApp::OnResolve, base::Unretained(this), expected), base::Bind( &KeyProvidingApp::OnReject, base::Unretained(this), expected))); - return promise.Pass(); + return promise; } scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( @@ -312,7 +313,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { expected), base::Bind( &KeyProvidingApp::OnReject, base::Unretained(this), expected))); - return promise.Pass(); + return promise; } void OnSessionMessage(const std::string& session_id, @@ -492,7 +493,7 @@ class MockMediaSource { virtual ~MockMediaSource() {} - scoped_ptr<Demuxer> GetDemuxer() { return owned_chunk_demuxer_.Pass(); } + scoped_ptr<Demuxer> GetDemuxer() { return std::move(owned_chunk_demuxer_); } void set_encrypted_media_init_data_cb( const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { @@ -653,7 +654,7 @@ class PipelineIntegrationTestHost : public mojo::test::ApplicationTestBase, media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer)); return make_scoped_ptr(new MojoRendererImpl(message_loop_.task_runner(), - mojo_renderer.Pass())); + std::move(mojo_renderer))); } private: @@ -679,7 +680,7 @@ class PipelineIntegrationTest : public PipelineIntegrationTestHost { // Encrypted content not used, so this is never called. EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); - demuxer_ = source->GetDemuxer().Pass(); + demuxer_ = source->GetDemuxer(); pipeline_->Start( demuxer_.get(), CreateRenderer(), base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), @@ -726,7 +727,7 @@ class PipelineIntegrationTest : public PipelineIntegrationTestHost { // never called. EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); - demuxer_ = source->GetDemuxer().Pass(); + demuxer_ = source->GetDemuxer(); pipeline_->SetCdm(encrypted_media->GetCdmContext(), base::Bind(&PipelineIntegrationTest::DecryptorAttached, diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc index b75a04c..a2e4254 100644 --- a/media/test/pipeline_integration_test_base.cc +++ b/media/test/pipeline_integration_test_base.cc @@ -4,6 +4,8 @@ #include "media/test/pipeline_integration_test_base.h" +#include <utility> + #include "base/bind.h" #include "base/memory/scoped_vector.h" #include "media/base/cdm_context.h" @@ -267,7 +269,7 @@ scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { // Disable frame dropping if hashing is enabled. scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl( message_loop_.task_runner(), message_loop_.task_runner().get(), - video_sink_.get(), video_decoders.Pass(), false, nullptr, + video_sink_.get(), std::move(video_decoders), false, nullptr, new MediaLog())); if (!clockless_playback_) { @@ -301,7 +303,7 @@ scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { (clockless_playback_) ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get()) : audio_sink_.get(), - audio_decoders.Pass(), hardware_config_, new MediaLog())); + std::move(audio_decoders), hardware_config_, new MediaLog())); if (hashing_enabled_) { if (clockless_playback_) clockless_audio_sink_->StartAudioHashForTesting(); @@ -310,9 +312,8 @@ scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { } scoped_ptr<RendererImpl> renderer_impl( - new RendererImpl(message_loop_.task_runner(), - audio_renderer.Pass(), - video_renderer.Pass())); + new RendererImpl(message_loop_.task_runner(), std::move(audio_renderer), + std::move(video_renderer))); // Prevent non-deterministic buffering state callbacks from firing (e.g., slow // machine, valgrind). @@ -321,7 +322,7 @@ scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { if (clockless_playback_) renderer_impl->EnableClocklessVideoPlaybackForTesting(); - return renderer_impl.Pass(); + return std::move(renderer_impl); } void PipelineIntegrationTestBase::OnVideoFramePaint( |