Skip to content

Commit

Permalink
Standardize usage of virtual/override/final specifiers in base/.
Browse files Browse the repository at this point in the history
The Google C++ style guide states:

  Explicitly annotate overrides of virtual functions or virtual
  destructors with an override or (less frequently) final specifier.
  Older (pre-C++11) code will use the virtual keyword as an inferior
  alternative annotation. For clarity, use exactly one of override,
  final, or virtual when declaring an override.

To better conform to these guidelines, the following constructs have
been rewritten:

- if a base class has a virtual destructor, then:
    virtual ~Foo();                   ->  ~Foo() override;
- virtual void Foo() override;        ->  void Foo() override;
- virtual void Foo() override final;  ->  void Foo() final;

This patch was automatically generated. The clang plugin can generate
fixit hints, which are suggested edits when it is 100% sure it knows how
to fix a problem. The hints from the clang plugin were applied to the
source tree using the tool in https://codereview.chromium.org/598073004.

Several formatting edits by clang-format were manually reverted, due to
mangling of some of the more complicate IPC macros.

BUG=417463

Review URL: https://codereview.chromium.org/804533005

Cr-Commit-Position: refs/heads/master@{#309527}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 23, 2014
1 parent 34fead5 commit 8aef376
Show file tree
Hide file tree
Showing 44 changed files with 76 additions and 116 deletions.
3 changes: 1 addition & 2 deletions base/callback_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class CallbackTest : public ::testing::Test {
callback_b_(new FakeBindState2()) {
}

virtual ~CallbackTest() {
}
~CallbackTest() override {}

protected:
Callback<void(void)> callback_a_;
Expand Down
4 changes: 2 additions & 2 deletions base/debug/crash_logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ std::map<std::string, std::string>* key_values_ = NULL;

class CrashLoggingTest : public testing::Test {
public:
virtual void SetUp() {
void SetUp() override {
key_values_ = new std::map<std::string, std::string>;
base::debug::SetCrashKeyReportingFunctions(
&CrashLoggingTest::SetKeyValue,
&CrashLoggingTest::ClearKeyValue);
}

virtual void TearDown() {
void TearDown() override {
base::debug::ResetCrashLoggingForTesting();

delete key_values_;
Expand Down
2 changes: 1 addition & 1 deletion base/debug/trace_event_memory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace debug {
class TraceMemoryTest : public testing::Test {
public:
TraceMemoryTest() {}
virtual ~TraceMemoryTest() {}
~TraceMemoryTest() override {}

private:
DISALLOW_COPY_AND_ASSIGN(TraceMemoryTest);
Expand Down
4 changes: 1 addition & 3 deletions base/debug/trace_event_synthetic_delay_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class TraceEventSyntheticDelayTest : public testing::Test,
public TraceEventSyntheticDelayClock {
public:
TraceEventSyntheticDelayTest() {}
virtual ~TraceEventSyntheticDelayTest() {
ResetTraceEventSyntheticDelays();
}
~TraceEventSyntheticDelayTest() override { ResetTraceEventSyntheticDelays(); }

// TraceEventSyntheticDelayClock implementation.
base::TimeTicks Now() override {
Expand Down
2 changes: 1 addition & 1 deletion base/debug/trace_event_system_stats_monitor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace debug {
class TraceSystemStatsMonitorTest : public testing::Test {
public:
TraceSystemStatsMonitorTest() {}
virtual ~TraceSystemStatsMonitorTest() {}
~TraceSystemStatsMonitorTest() override {}

private:
DISALLOW_COPY_AND_ASSIGN(TraceSystemStatsMonitorTest);
Expand Down
8 changes: 4 additions & 4 deletions base/debug/trace_event_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TraceEventTestFixture : public testing::Test {
base::Unretained(flush_complete_event)));
}

virtual void SetUp() override {
void SetUp() override {
const char* name = PlatformThread::GetName();
old_thread_name_ = name ? strdup(name) : NULL;

Expand All @@ -136,7 +136,7 @@ class TraceEventTestFixture : public testing::Test {
trace_buffer_.SetOutputCallback(json_output_.GetCallback());
event_watch_notification_ = 0;
}
virtual void TearDown() override {
void TearDown() override {
if (TraceLog::GetInstance())
EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled());
PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : "");
Expand Down Expand Up @@ -2215,12 +2215,12 @@ TEST_F(TraceEventTestFixture, PrimitiveArgs) {

class TraceEventCallbackTest : public TraceEventTestFixture {
public:
virtual void SetUp() override {
void SetUp() override {
TraceEventTestFixture::SetUp();
ASSERT_EQ(NULL, s_instance);
s_instance = this;
}
virtual void TearDown() override {
void TearDown() override {
TraceLog::GetInstance()->SetDisabled();
ASSERT_TRUE(!!s_instance);
s_instance = NULL;
Expand Down
10 changes: 1 addition & 9 deletions base/files/file_path_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ struct UTF8TestData {

// file_util winds up using autoreleased objects on the Mac, so this needs
// to be a PlatformTest
class FilePathTest : public PlatformTest {
protected:
virtual void SetUp() override {
PlatformTest::SetUp();
}
virtual void TearDown() override {
PlatformTest::TearDown();
}
};
typedef PlatformTest FilePathTest;

TEST_F(FilePathTest, DirName) {
const struct UnaryTestData cases[] = {
Expand Down
8 changes: 3 additions & 5 deletions base/files/file_path_watcher_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,18 @@ class FilePathWatcherTest : public testing::Test {
FilePathWatcherTest()
: file_thread_("FilePathWatcherTest") {}

virtual ~FilePathWatcherTest() {}
~FilePathWatcherTest() override {}

protected:
virtual void SetUp() override {
void SetUp() override {
// Create a separate file thread in order to test proper thread usage.
base::Thread::Options options(MessageLoop::TYPE_IO, 0);
ASSERT_TRUE(file_thread_.StartWithOptions(options));
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
collector_ = new NotificationCollector();
}

virtual void TearDown() override {
RunLoop().RunUntilIdle();
}
void TearDown() override { RunLoop().RunUntilIdle(); }

void DeleteDelegateOnFileThread(TestDelegate* delegate) {
file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate);
Expand Down
2 changes: 1 addition & 1 deletion base/files/file_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FileProxyTest : public testing::Test {
bytes_written_(-1),
weak_factory_(this) {}

virtual void SetUp() override {
void SetUp() override {
ASSERT_TRUE(dir_.CreateUniqueTempDir());
ASSERT_TRUE(file_thread_.Start());
}
Expand Down
2 changes: 1 addition & 1 deletion base/files/file_util_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FileUtilProxyTest : public testing::Test {
bytes_written_(-1),
weak_factory_(this) {}

virtual void SetUp() override {
void SetUp() override {
ASSERT_TRUE(dir_.CreateUniqueTempDir());
ASSERT_TRUE(file_thread_.Start());
}
Expand Down
4 changes: 2 additions & 2 deletions base/files/file_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const int FILES_AND_DIRECTORIES =
// to be a PlatformTest
class FileUtilTest : public PlatformTest {
protected:
virtual void SetUp() override {
void SetUp() override {
PlatformTest::SetUp();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
Expand Down Expand Up @@ -2170,7 +2170,7 @@ TEST_F(FileUtilTest, IsDirectoryEmpty) {
// with a common SetUp() method.
class VerifyPathControlledByUserTest : public FileUtilTest {
protected:
virtual void SetUp() override {
void SetUp() override {
FileUtilTest::SetUp();

// Create a basic structure used by each test.
Expand Down
2 changes: 1 addition & 1 deletion base/files/important_file_writer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool SuccessfulWriteObserver::GetAndResetObservationState() {
class ImportantFileWriterTest : public testing::Test {
public:
ImportantFileWriterTest() { }
virtual void SetUp() {
void SetUp() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
file_ = temp_dir_.path().AppendASCII("test-file");
}
Expand Down
4 changes: 2 additions & 2 deletions base/files/memory_mapped_file_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ bool CheckBufferContents(const uint8* data, size_t size, size_t offset) {

class MemoryMappedFileTest : public PlatformTest {
protected:
virtual void SetUp() override {
void SetUp() override {
PlatformTest::SetUp();
CreateTemporaryFile(&temp_file_path_);
}

virtual void TearDown() { EXPECT_TRUE(DeleteFile(temp_file_path_, false)); }
void TearDown() override { EXPECT_TRUE(DeleteFile(temp_file_path_, false)); }

void CreateTemporaryTestFile(size_t size) {
File file(temp_file_path_,
Expand Down
4 changes: 1 addition & 3 deletions base/json/json_value_serializer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ TEST(JSONValueSerializerTest, JSONReaderComments) {

class JSONFileValueSerializerTest : public testing::Test {
protected:
virtual void SetUp() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); }

base::ScopedTempDir temp_dir_;
};
Expand Down
6 changes: 3 additions & 3 deletions base/memory/discardable_memory_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestAllocationImpl : public internal::DiscardableMemoryManagerAllocation {
DCHECK(is_allocated_);
is_allocated_ = false;
}
virtual bool IsMemoryResident() const override {
bool IsMemoryResident() const override {
DCHECK(is_allocated_);
return true;
}
Expand Down Expand Up @@ -460,9 +460,9 @@ class ThreadedDiscardableMemoryManagerTest
: memory_usage_thread_("memory_usage_thread"),
thread_sync_(true, false) {}

virtual void SetUp() override { memory_usage_thread_.Start(); }
void SetUp() override { memory_usage_thread_.Start(); }

virtual void TearDown() override { memory_usage_thread_.Stop(); }
void TearDown() override { memory_usage_thread_.Stop(); }

void UseMemoryHelper() {
size_t size = 1024;
Expand Down
16 changes: 8 additions & 8 deletions base/memory/discardable_memory_shmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DiscardableMemoryShmem
public internal::DiscardableMemoryManagerAllocation {
public:
explicit DiscardableMemoryShmem(size_t bytes);
virtual ~DiscardableMemoryShmem();
~DiscardableMemoryShmem() override;

static void ReleaseFreeMemory();

Expand All @@ -28,15 +28,15 @@ class DiscardableMemoryShmem
bool Initialize();

// Overridden from DiscardableMemory:
virtual DiscardableMemoryLockStatus Lock() override;
virtual void Unlock() override;
virtual void* Memory() const override;
DiscardableMemoryLockStatus Lock() override;
void Unlock() override;
void* Memory() const override;

// Overridden from internal::DiscardableMemoryManagerAllocation:
virtual bool AllocateAndAcquireLock() override;
virtual void ReleaseLock() override;
virtual void Purge() override;
virtual bool IsMemoryResident() const override;
bool AllocateAndAcquireLock() override;
void ReleaseLock() override;
void Purge() override;
bool IsMemoryResident() const override;

private:
const size_t bytes_;
Expand Down
4 changes: 2 additions & 2 deletions base/memory/discardable_memory_shmem_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DiscardableMemoryShmemAllocatorImpl
: public DiscardableMemoryShmemAllocator {
public:
// Overridden from DiscardableMemoryShmemAllocator:
virtual scoped_ptr<DiscardableSharedMemory>
AllocateLockedDiscardableSharedMemory(size_t size) override {
scoped_ptr<DiscardableSharedMemory> AllocateLockedDiscardableSharedMemory(
size_t size) override {
scoped_ptr<DiscardableSharedMemory> memory(new DiscardableSharedMemory);
if (!memory->CreateAndMap(size))
return scoped_ptr<DiscardableSharedMemory>();
Expand Down
2 changes: 1 addition & 1 deletion base/memory/singleton_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class SingletonTest : public testing::Test {
public:
SingletonTest() {}

virtual void SetUp() override {
void SetUp() override {
non_leak_called_ = false;
leaky_called_ = false;
static_called_ = false;
Expand Down
4 changes: 2 additions & 2 deletions base/message_loop/message_loop_proxy_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class MessageLoopProxyImplTest : public testing::Test {
}

protected:
virtual void SetUp() override {
void SetUp() override {
io_thread_.reset(new Thread("MessageLoopProxyImplTest_IO"));
file_thread_.reset(new Thread("MessageLoopProxyImplTest_File"));
io_thread_->Start();
file_thread_->Start();
}

virtual void TearDown() override {
void TearDown() override {
io_thread_->Stop();
file_thread_->Stop();
}
Expand Down
4 changes: 2 additions & 2 deletions base/message_loop/message_loop_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MessageLoopProxyTest : public testing::Test {
}

protected:
virtual void SetUp() override {
void SetUp() override {
// Use SetUp() instead of the constructor to avoid posting a task to a
// partialy constructed object.
task_thread_.Start();
Expand All @@ -42,7 +42,7 @@ class MessageLoopProxyTest : public testing::Test {
Bind(&MessageLoopProxyTest::BlockTaskThreadHelper, Unretained(this)));
}

virtual void TearDown() override {
void TearDown() override {
// Make sure the |task_thread_| is not blocked, and stop the thread
// fully before destuction because its tasks may still depend on the
// |thread_sync_| event.
Expand Down
4 changes: 2 additions & 2 deletions base/message_loop/message_pump_glib_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class MessagePumpGLibTest : public testing::Test {
MessagePumpGLibTest() : loop_(NULL), injector_(NULL) { }

// Overridden from testing::Test:
virtual void SetUp() override {
void SetUp() override {
loop_ = new MessageLoop(MessageLoop::TYPE_UI);
injector_ = new EventInjector();
}
virtual void TearDown() override {
void TearDown() override {
delete injector_;
injector_ = NULL;
delete loop_;
Expand Down
6 changes: 3 additions & 3 deletions base/message_loop/message_pump_libevent_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class MessagePumpLibeventTest : public testing::Test {
MessagePumpLibeventTest()
: ui_loop_(MessageLoop::TYPE_UI),
io_thread_("MessagePumpLibeventTestIOThread") {}
virtual ~MessagePumpLibeventTest() {}
~MessagePumpLibeventTest() override {}

virtual void SetUp() override {
void SetUp() override {
Thread::Options options(MessageLoop::TYPE_IO, 0);
ASSERT_TRUE(io_thread_.StartWithOptions(options));
ASSERT_EQ(MessageLoop::TYPE_IO, io_thread_.message_loop()->type());
int ret = pipe(pipefds_);
ASSERT_EQ(0, ret);
}

virtual void TearDown() override {
void TearDown() override {
if (IGNORE_EINTR(close(pipefds_[0])) < 0)
PLOG(ERROR) << "close";
if (IGNORE_EINTR(close(pipefds_[1])) < 0)
Expand Down
4 changes: 1 addition & 3 deletions base/metrics/histogram_base_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class HistogramBaseTest : public testing::Test {
ResetStatisticsRecorder();
}

virtual ~HistogramBaseTest() {
delete statistics_recorder_;
}
~HistogramBaseTest() override { delete statistics_recorder_; }

void ResetStatisticsRecorder() {
delete statistics_recorder_;
Expand Down
2 changes: 1 addition & 1 deletion base/metrics/histogram_snapshot_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HistogramSnapshotManagerTest : public testing::Test {
HistogramSnapshotManagerTest()
: histogram_snapshot_manager_(&histogram_flattener_delta_recorder_) {}

virtual ~HistogramSnapshotManagerTest() {}
~HistogramSnapshotManagerTest() override {}

StatisticsRecorder statistics_recorder_;
HistogramFlattenerDeltaRecorder histogram_flattener_delta_recorder_;
Expand Down
6 changes: 2 additions & 4 deletions base/metrics/histogram_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ namespace base {

class HistogramTest : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
// Each test will have a clean state (no Histogram / BucketRanges
// registered).
InitializeStatisticsRecorder();
}

virtual void TearDown() {
UninitializeStatisticsRecorder();
}
void TearDown() override { UninitializeStatisticsRecorder(); }

void InitializeStatisticsRecorder() {
statistics_recorder_ = new StatisticsRecorder();
Expand Down
6 changes: 2 additions & 4 deletions base/metrics/sparse_histogram_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ namespace base {

class SparseHistogramTest : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
// Each test will have a clean state (no Histogram / BucketRanges
// registered).
InitializeStatisticsRecorder();
}

virtual void TearDown() {
UninitializeStatisticsRecorder();
}
void TearDown() override { UninitializeStatisticsRecorder(); }

void InitializeStatisticsRecorder() {
statistics_recorder_ = new StatisticsRecorder();
Expand Down
Loading

0 comments on commit 8aef376

Please sign in to comment.