Skip to content

Commit

Permalink
Replace DISALLOW_COPY_AND_ASSIGN in media/
Browse files Browse the repository at this point in the history
This replaces DISALLOW_COPY_AND_ASSIGN with explicit constructor deletes
where a local script is able to detect its insertion place (~Foo() is
public => insert before this line).

This is incomplete as not all classes have a public ~Foo() declared, so
not all DISALLOW_COPY_AND_ASSIGN occurrences are replaced.

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: I5d1a79cb74e99aa115b42bc850011645bd1af761
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3173720
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#924014}
  • Loading branch information
pbos authored and Chromium LUCI CQ committed Sep 22, 2021
1 parent b6d3376 commit 4c42559
Show file tree
Hide file tree
Showing 622 changed files with 2,870 additions and 1,541 deletions.
5 changes: 3 additions & 2 deletions media/audio/alive_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class MEDIA_EXPORT AliveChecker {
PowerObserverHelperFactoryCallback
power_observer_helper_factory_callback);

AliveChecker(const AliveChecker&) = delete;
AliveChecker& operator=(const AliveChecker&) = delete;

~AliveChecker();

// Start and stop checking if the client is alive.
Expand Down Expand Up @@ -136,8 +139,6 @@ class MEDIA_EXPORT AliveChecker {
std::unique_ptr<PowerObserverHelper> power_observer_;

base::WeakPtrFactory<AliveChecker> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(AliveChecker);
};

} // namespace media
Expand Down
5 changes: 3 additions & 2 deletions media/audio/alsa/alsa_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class MEDIA_EXPORT AlsaPcmInputStream
const AudioParameters& params,
AlsaWrapper* wrapper);

AlsaPcmInputStream(const AlsaPcmInputStream&) = delete;
AlsaPcmInputStream& operator=(const AlsaPcmInputStream&) = delete;

~AlsaPcmInputStream() override;

// Implementation of AudioInputStream.
Expand Down Expand Up @@ -92,8 +95,6 @@ class MEDIA_EXPORT AlsaPcmInputStream
std::unique_ptr<AudioBus> audio_bus_;
base::Thread capture_thread_;
bool running_;

DISALLOW_COPY_AND_ASSIGN(AlsaPcmInputStream);
};

} // namespace media
Expand Down
5 changes: 3 additions & 2 deletions media/audio/alsa/alsa_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream {
AlsaWrapper* wrapper,
AudioManagerBase* manager);

AlsaPcmOutputStream(const AlsaPcmOutputStream&) = delete;
AlsaPcmOutputStream& operator=(const AlsaPcmOutputStream&) = delete;

~AlsaPcmOutputStream() override;

// Implementation of AudioOutputStream.
Expand Down Expand Up @@ -220,8 +223,6 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream {
// bound by its lifetime.
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream);
};

MEDIA_EXPORT std::ostream& operator<<(std::ostream& os,
Expand Down
6 changes: 4 additions & 2 deletions media/audio/alsa/alsa_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ namespace media {
class MEDIA_EXPORT AlsaWrapper {
public:
AlsaWrapper();

AlsaWrapper(const AlsaWrapper&) = delete;
AlsaWrapper& operator=(const AlsaWrapper&) = delete;

virtual ~AlsaWrapper();

virtual int DeviceNameHint(int card, const char* iface, void*** hints);
Expand Down Expand Up @@ -152,8 +156,6 @@ class MEDIA_EXPORT AlsaWrapper {
virtual void MixerSelemIdFree(snd_mixer_selem_id_t* obj);

virtual const char* StrError(int errnum);

DISALLOW_COPY_AND_ASSIGN(AlsaWrapper);
};

} // namespace media
Expand Down
6 changes: 4 additions & 2 deletions media/audio/alsa/audio_manager_alsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class MEDIA_EXPORT AudioManagerAlsa : public AudioManagerBase {
public:
AudioManagerAlsa(std::unique_ptr<AudioThread> audio_thread,
AudioLogFactory* audio_log_factory);

AudioManagerAlsa(const AudioManagerAlsa&) = delete;
AudioManagerAlsa& operator=(const AudioManagerAlsa&) = delete;

~AudioManagerAlsa() override;

// Implementation of AudioManager.
Expand Down Expand Up @@ -88,8 +92,6 @@ class MEDIA_EXPORT AudioManagerAlsa : public AudioManagerBase {
const std::string& device_id);

std::unique_ptr<AlsaWrapper> wrapper_;

DISALLOW_COPY_AND_ASSIGN(AudioManagerAlsa);
};

} // namespace media
Expand Down
6 changes: 3 additions & 3 deletions media/audio/alsa/mock_alsa_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class MockAlsaWrapper : public AlsaWrapper {
public:
MockAlsaWrapper();

MockAlsaWrapper(const MockAlsaWrapper&) = delete;
MockAlsaWrapper& operator=(const MockAlsaWrapper&) = delete;

~MockAlsaWrapper() override;

MOCK_METHOD3(DeviceNameHint, int(int card, const char* iface, void*** hints));
Expand Down Expand Up @@ -181,9 +184,6 @@ class MockAlsaWrapper : public AlsaWrapper {
MOCK_METHOD1(MixerSelemIdMalloc, int(snd_mixer_selem_id_t** ptr));
MOCK_METHOD1(MixerSelemIdFree, void(snd_mixer_selem_id_t* obj));
MOCK_METHOD1(StrError, const char*(int errnum));

private:
DISALLOW_COPY_AND_ASSIGN(MockAlsaWrapper);
};

} // namespace media
Expand Down
6 changes: 4 additions & 2 deletions media/audio/android/aaudio_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class AAudioOutputStream : public MuteableAudioOutputStream {
AAudioOutputStream(AudioManagerAndroid* manager,
const AudioParameters& params,
aaudio_usage_t usage);

AAudioOutputStream(const AAudioOutputStream&) = delete;
AAudioOutputStream& operator=(const AAudioOutputStream&) = delete;

~AAudioOutputStream() override;

// Implementation of MuteableAudioOutputStream.
Expand Down Expand Up @@ -73,8 +77,6 @@ class AAudioOutputStream : public MuteableAudioOutputStream {
bool muted_ GUARDED_BY(lock_) = false;
double volume_ GUARDED_BY(lock_) = 1.0;
bool device_changed_ GUARDED_BY(lock_) = false;

DISALLOW_COPY_AND_ASSIGN(AAudioOutputStream);
};

} // namespace media
Expand Down
22 changes: 13 additions & 9 deletions media/audio/android/audio_android_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ class FileAudioSource : public AudioOutputStream::AudioSourceCallback {
DVLOG(0) << "Reading from file: " << file_path.value().c_str();
}

FileAudioSource(const FileAudioSource&) = delete;
FileAudioSource& operator=(const FileAudioSource&) = delete;

~FileAudioSource() override {}

// AudioOutputStream::AudioSourceCallback implementation.
Expand Down Expand Up @@ -223,8 +226,6 @@ class FileAudioSource : public AudioOutputStream::AudioSourceCallback {
base::WaitableEvent* event_;
int pos_;
scoped_refptr<DecoderBuffer> file_;

DISALLOW_COPY_AND_ASSIGN(FileAudioSource);
};

// Implements AudioInputStream::AudioInputCallback and writes the recorded
Expand Down Expand Up @@ -252,6 +253,9 @@ class FileAudioSink : public AudioInputStream::AudioInputCallback {
DVLOG(0) << "Writing to file: " << file_path.value().c_str();
}

FileAudioSink(const FileAudioSink&) = delete;
FileAudioSink& operator=(const FileAudioSink&) = delete;

~FileAudioSink() override {
int bytes_written = 0;
while (bytes_written < buffer_->forward_capacity()) {
Expand Down Expand Up @@ -296,8 +300,6 @@ class FileAudioSink : public AudioInputStream::AudioInputCallback {
AudioParameters params_;
std::unique_ptr<media::SeekableBuffer> buffer_;
FILE* binary_file_;

DISALLOW_COPY_AND_ASSIGN(FileAudioSink);
};

// Implements AudioInputCallback and AudioSourceCallback to support full
Expand All @@ -318,6 +320,10 @@ class FullDuplexAudioSinkSource
buffer_.reset(new uint8_t[buffer_size]);
}

FullDuplexAudioSinkSource(const FullDuplexAudioSinkSource&) = delete;
FullDuplexAudioSinkSource& operator=(const FullDuplexAudioSinkSource&) =
delete;

~FullDuplexAudioSinkSource() override {}

// AudioInputStream::AudioInputCallback implementation
Expand Down Expand Up @@ -410,8 +416,6 @@ class FullDuplexAudioSinkSource
std::unique_ptr<media::SeekableBuffer> fifo_;
std::unique_ptr<uint8_t[]> buffer_;
bool started_;

DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource);
};

// Test fixture class for tests which only exercise the output path.
Expand All @@ -428,6 +432,9 @@ class AudioAndroidOutputTest : public testing::Test {
base::RunLoop().RunUntilIdle();
}

AudioAndroidOutputTest(const AudioAndroidOutputTest&) = delete;
AudioAndroidOutputTest& operator=(const AudioAndroidOutputTest&) = delete;

~AudioAndroidOutputTest() override {
audio_manager_->Shutdown();
base::RunLoop().RunUntilIdle();
Expand Down Expand Up @@ -578,9 +585,6 @@ class AudioAndroidOutputTest : public testing::Test {
AudioOutputStream* audio_output_stream_;
base::TimeTicks start_time_;
base::TimeTicks end_time_;

private:
DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest);
};

// Test fixture class for tests which exercise the input path, or both input and
Expand Down
6 changes: 4 additions & 2 deletions media/audio/android/audio_manager_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase {
public:
AudioManagerAndroid(std::unique_ptr<AudioThread> audio_thread,
AudioLogFactory* audio_log_factory);

AudioManagerAndroid(const AudioManagerAndroid&) = delete;
AudioManagerAndroid& operator=(const AudioManagerAndroid&) = delete;

~AudioManagerAndroid() override;

void InitializeIfNeeded();
Expand Down Expand Up @@ -127,8 +131,6 @@ class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase {
// If set, overrides volume level on output streams
bool output_volume_override_set_;
double output_volume_override_;

DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid);
};

} // namespace media
Expand Down
6 changes: 4 additions & 2 deletions media/audio/android/audio_track_output_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class MEDIA_EXPORT AudioTrackOutputStream : public MuteableAudioOutputStream {
public:
AudioTrackOutputStream(AudioManagerBase* manager,
const AudioParameters& params);

AudioTrackOutputStream(const AudioTrackOutputStream&) = delete;
AudioTrackOutputStream& operator=(const AudioTrackOutputStream&) = delete;

~AudioTrackOutputStream() override;

// AudioOutputStream implementation.
Expand Down Expand Up @@ -59,8 +63,6 @@ class MEDIA_EXPORT AudioTrackOutputStream : public MuteableAudioOutputStream {

// Java AudioTrackOutputStream instance.
base::android::ScopedJavaGlobalRef<jobject> j_audio_output_stream_;

DISALLOW_COPY_AND_ASSIGN(AudioTrackOutputStream);
};

} // namespace media
Expand Down
5 changes: 3 additions & 2 deletions media/audio/android/opensles_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class OpenSLESInputStream : public AudioInputStream {
OpenSLESInputStream(AudioManagerAndroid* manager,
const AudioParameters& params);

OpenSLESInputStream(const OpenSLESInputStream&) = delete;
OpenSLESInputStream& operator=(const OpenSLESInputStream&) = delete;

~OpenSLESInputStream() override;

// Implementation of AudioInputStream.
Expand Down Expand Up @@ -107,8 +110,6 @@ class OpenSLESInputStream : public AudioInputStream {

// Set to true at construction if user wants to disable all audio effects.
const bool no_effects_ = false;

DISALLOW_COPY_AND_ASSIGN(OpenSLESInputStream);
};

} // namespace media
Expand Down
5 changes: 3 additions & 2 deletions media/audio/android/opensles_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class OpenSLESOutputStream : public MuteableAudioOutputStream {
const AudioParameters& params,
SLint32 stream_type);

OpenSLESOutputStream(const OpenSLESOutputStream&) = delete;
OpenSLESOutputStream& operator=(const OpenSLESOutputStream&) = delete;

~OpenSLESOutputStream() override;

// Implementation of MuteableAudioOutputStream.
Expand Down Expand Up @@ -150,8 +153,6 @@ class OpenSLESOutputStream : public MuteableAudioOutputStream {
// Adjustment for hardware latency. Needed for some cast targets, since
// OpenSLES's GetPosition doesn't properly account for HAL latency.
base::TimeDelta hardware_latency_;

DISALLOW_COPY_AND_ASSIGN(OpenSLESOutputStream);
};

} // namespace media
Expand Down
5 changes: 3 additions & 2 deletions media/audio/audio_debug_file_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class MEDIA_EXPORT AudioDebugFileWriter {
// Write() must match |params|.
explicit AudioDebugFileWriter(const AudioParameters& params);

AudioDebugFileWriter(const AudioDebugFileWriter&) = delete;
AudioDebugFileWriter& operator=(const AudioDebugFileWriter&) = delete;

virtual ~AudioDebugFileWriter();

// Must be called before calling Write() for the first time after creation or
Expand Down Expand Up @@ -70,8 +73,6 @@ class MEDIA_EXPORT AudioDebugFileWriter {

AudioFileWriterUniquePtr file_writer_;
SEQUENCE_CHECKER(client_sequence_checker_);

DISALLOW_COPY_AND_ASSIGN(AudioDebugFileWriter);
};

} // namespace media
Expand Down
6 changes: 5 additions & 1 deletion media/audio/audio_debug_recording_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class MEDIA_EXPORT AudioDebugRecordingHelper : public AudioDebugRecorder {
const AudioParameters& params,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
base::OnceClosure on_destruction_closure);

AudioDebugRecordingHelper(const AudioDebugRecordingHelper&) = delete;
AudioDebugRecordingHelper& operator=(const AudioDebugRecordingHelper&) =
delete;

~AudioDebugRecordingHelper() override;

// Enable debug recording. Creates |debug_writer_| and runs
Expand Down Expand Up @@ -103,7 +108,6 @@ class MEDIA_EXPORT AudioDebugRecordingHelper : public AudioDebugRecorder {
base::OnceClosure on_destruction_closure_;

base::WeakPtrFactory<AudioDebugRecordingHelper> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingHelper);
};

} // namespace media
Expand Down
22 changes: 15 additions & 7 deletions media/audio/audio_debug_recording_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class MockAudioDebugFileWriter : public AudioDebugFileWriter {
public:
explicit MockAudioDebugFileWriter(const AudioParameters& params)
: AudioDebugFileWriter(params), reference_data_(nullptr) {}

MockAudioDebugFileWriter(const MockAudioDebugFileWriter&) = delete;
MockAudioDebugFileWriter& operator=(const MockAudioDebugFileWriter&) = delete;

~MockAudioDebugFileWriter() override = default;

MOCK_METHOD1(DoStart, void(bool));
Expand Down Expand Up @@ -72,8 +76,6 @@ class MockAudioDebugFileWriter : public AudioDebugFileWriter {

private:
AudioBus* reference_data_;

DISALLOW_COPY_AND_ASSIGN(MockAudioDebugFileWriter);
};

// Sub-class of the helper that overrides the CreateAudioDebugFileWriter
Expand All @@ -87,6 +89,12 @@ class AudioDebugRecordingHelperUnderTest : public AudioDebugRecordingHelper {
: AudioDebugRecordingHelper(params,
std::move(task_runner),
std::move(on_destruction_closure)) {}

AudioDebugRecordingHelperUnderTest(
const AudioDebugRecordingHelperUnderTest&) = delete;
AudioDebugRecordingHelperUnderTest& operator=(
const AudioDebugRecordingHelperUnderTest&) = delete;

~AudioDebugRecordingHelperUnderTest() override = default;

private:
Expand All @@ -98,13 +106,16 @@ class AudioDebugRecordingHelperUnderTest : public AudioDebugRecordingHelper {
EXPECT_CALL(*writer, DoStart(true));
return base::WrapUnique<AudioDebugFileWriter>(writer);
}

DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingHelperUnderTest);
};

class AudioDebugRecordingHelperTest : public ::testing::Test {
public:
AudioDebugRecordingHelperTest() {}

AudioDebugRecordingHelperTest(const AudioDebugRecordingHelperTest&) = delete;
AudioDebugRecordingHelperTest& operator=(
const AudioDebugRecordingHelperTest&) = delete;

~AudioDebugRecordingHelperTest() override = default;

// Helper function that creates a recording helper.
Expand Down Expand Up @@ -147,9 +158,6 @@ class AudioDebugRecordingHelperTest : public ::testing::Test {

// The test task environment.
base::test::TaskEnvironment task_environment_;

private:
DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingHelperTest);
};

// Creates a helper with an on destruction closure, and verifies that it's run.
Expand Down
Loading

0 comments on commit 4c42559

Please sign in to comment.