Skip to content

Commit

Permalink
Standardize usage of virtual/override/final specifiers in sync/.
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/792343004

Cr-Commit-Position: refs/heads/master@{#309474}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 22, 2014
1 parent df1702e commit 520ae85
Show file tree
Hide file tree
Showing 32 changed files with 65 additions and 93 deletions.
5 changes: 2 additions & 3 deletions sync/api/syncable_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class SYNC_EXPORT SyncableService
// Returns: A default SyncError (IsSet() == false) if no errors were
// encountered, and a filled SyncError (IsSet() == true)
// otherwise.
virtual SyncError ProcessSyncChanges(
const tracked_objects::Location& from_here,
const SyncChangeList& change_list) override = 0;
SyncError ProcessSyncChanges(const tracked_objects::Location& from_here,
const SyncChangeList& change_list) override = 0;

// Returns AttachmentStore used by datatype. Attachment store is used by sync
// when uploading or downloading attachments.
Expand Down
8 changes: 3 additions & 5 deletions sync/engine/apply_control_data_updates_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ class ApplyControlDataUpdatesTest : public ::testing::Test {
public:
protected:
ApplyControlDataUpdatesTest() {}
virtual ~ApplyControlDataUpdatesTest() {}
~ApplyControlDataUpdatesTest() override {}

virtual void SetUp() {
void SetUp() override {
dir_maker_.SetUp();
entry_factory_.reset(new TestEntryFactory(directory()));
}

virtual void TearDown() {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

syncable::Directory* directory() {
return dir_maker_.directory();
Expand Down
6 changes: 2 additions & 4 deletions sync/engine/directory_commit_contribution_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace syncer {

class DirectoryCommitContributionTest : public ::testing::Test {
public:
virtual void SetUp() override {
void SetUp() override {
dir_maker_.SetUp();

syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
Expand All @@ -30,9 +30,7 @@ class DirectoryCommitContributionTest : public ::testing::Test {
CreateTypeRoot(&trans, dir(), BOOKMARKS);
}

virtual void TearDown() override {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

protected:
int64 CreateUnsyncedItemWithAttachments(
Expand Down
16 changes: 5 additions & 11 deletions sync/engine/directory_update_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
: ui_worker_(new FakeModelWorker(GROUP_UI)) {
}

virtual ~DirectoryUpdateHandlerProcessUpdateTest() {}
~DirectoryUpdateHandlerProcessUpdateTest() override {}

virtual void SetUp() override {
dir_maker_.SetUp();
}
void SetUp() override { dir_maker_.SetUp(); }

virtual void TearDown() override {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

syncable::Directory* dir() {
return dir_maker_.directory();
Expand Down Expand Up @@ -486,7 +482,7 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
articles_emitter_(ARTICLES, &type_observers_),
update_handler_map_deleter_(&update_handler_map_) {}

virtual void SetUp() override {
void SetUp() override {
dir_maker_.SetUp();
entry_factory_.reset(new TestEntryFactory(directory()));

Expand All @@ -506,9 +502,7 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
directory(), ARTICLES, ui_worker_, &articles_emitter_)));
}

virtual void TearDown() override {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

const UpdateCounters& GetBookmarksUpdateCounters() {
return bookmarks_emitter_.GetUpdateCounters();
Expand Down
2 changes: 1 addition & 1 deletion sync/engine/entity_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EntityTrackerTest : public ::testing::Test {
specifics.mutable_preference()->set_value("pref.value");
}

virtual ~EntityTrackerTest() {}
~EntityTrackerTest() override {}

const std::string kServerId;
const std::string kClientTag;
Expand Down
8 changes: 4 additions & 4 deletions sync/engine/get_updates_processor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GetUpdatesProcessorTest : public ::testing::Test {
kTestStartTime(base::TimeTicks::Now()),
update_handler_deleter_(&update_handler_map_) {}

virtual void SetUp() {
void SetUp() override {
AddUpdateHandler(AUTOFILL);
AddUpdateHandler(BOOKMARKS);
AddUpdateHandler(PREFERENCES);
Expand Down Expand Up @@ -386,9 +386,9 @@ TEST_F(GetUpdatesProcessorTest, NormalResponseTest) {
class GetUpdatesProcessorApplyUpdatesTest : public GetUpdatesProcessorTest {
public:
GetUpdatesProcessorApplyUpdatesTest() {}
virtual ~GetUpdatesProcessorApplyUpdatesTest() {}
~GetUpdatesProcessorApplyUpdatesTest() override {}

virtual void SetUp() override {
void SetUp() override {
bookmarks_handler_ = AddUpdateHandler(BOOKMARKS);
autofill_handler_ = AddUpdateHandler(AUTOFILL);
}
Expand Down Expand Up @@ -475,7 +475,7 @@ TEST_F(GetUpdatesProcessorApplyUpdatesTest, Poll) {
class DownloadUpdatesDebugInfoTest : public ::testing::Test {
public:
DownloadUpdatesDebugInfoTest() {}
virtual ~DownloadUpdatesDebugInfoTest() {}
~DownloadUpdatesDebugInfoTest() override {}

sessions::StatusController* status() {
return &status_;
Expand Down
2 changes: 1 addition & 1 deletion sync/engine/model_type_sync_proxy_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static const ModelType kModelType = PREFERENCES;
class ModelTypeSyncProxyImplTest : public ::testing::Test {
public:
ModelTypeSyncProxyImplTest();
virtual ~ModelTypeSyncProxyImplTest();
~ModelTypeSyncProxyImplTest() override;

// Initialize with no local state. The type sync proxy will be unable to
// commit until it receives notification that initial sync has completed.
Expand Down
2 changes: 1 addition & 1 deletion sync/engine/model_type_sync_worker_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace syncer {
class ModelTypeSyncWorkerImplTest : public ::testing::Test {
public:
ModelTypeSyncWorkerImplTest();
virtual ~ModelTypeSyncWorkerImplTest();
~ModelTypeSyncWorkerImplTest() override;

// One of these Initialize functions should be called at the beginning of
// each test.
Expand Down
8 changes: 4 additions & 4 deletions sync/engine/sync_scheduler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SyncSchedulerTest : public testing::Test {
MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&));
};

virtual void SetUp() {
void SetUp() override {
dir_maker_.SetUp();
syncer_ = new testing::StrictMock<MockSyncer>();
delay_ = NULL;
Expand Down Expand Up @@ -172,7 +172,7 @@ class SyncSchedulerTest : public testing::Test {
return TestTimeouts::action_timeout();
}

virtual void TearDown() {
void TearDown() override {
PumpLoop();
scheduler_.reset();
PumpLoop();
Expand Down Expand Up @@ -895,14 +895,14 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
}

class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest {
virtual void SetUp() {
void SetUp() override {
SyncSchedulerTest::SetUp();
UseMockDelayProvider();
EXPECT_CALL(*delay(), GetDelay(_))
.WillRepeatedly(Return(TimeDelta::FromMilliseconds(10)));
}

virtual void TearDown() {
void TearDown() override {
StopSyncScheduler();
SyncSchedulerTest::TearDown();
}
Expand Down
8 changes: 2 additions & 6 deletions sync/engine/syncer_proto_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,9 @@ TEST(SyncerProtoUtil, NameExtractionTwoNames) {

class SyncerProtoUtilTest : public testing::Test {
public:
virtual void SetUp() {
dir_maker_.SetUp();
}
void SetUp() override { dir_maker_.SetUp(); }

virtual void TearDown() {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

syncable::Directory* directory() {
return dir_maker_.directory();
Expand Down
4 changes: 2 additions & 2 deletions sync/engine/syncer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class SyncerTest : public testing::Test,
session_.get()));
}

virtual void SetUp() {
void SetUp() override {
dir_maker_.SetUp();
mock_server_.reset(new MockConnectionManager(directory(),
&cancelation_signal_));
Expand Down Expand Up @@ -324,7 +324,7 @@ class SyncerTest : public testing::Test,
mock_server_->SetKeystoreKey("encryption_key");
}

virtual void TearDown() {
void TearDown() override {
model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(
&debug_info_cache_);
mock_server_.reset();
Expand Down
6 changes: 2 additions & 4 deletions sync/engine/syncer_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ namespace syncer {

class GetUpdatePositionTest : public ::testing::Test {
public:
virtual void SetUp() {
void SetUp() override {
dir_maker_.SetUp();
entry_factory_.reset(new TestEntryFactory(directory()));
}

virtual void TearDown() {
dir_maker_.TearDown();
}
void TearDown() override { dir_maker_.TearDown(); }

syncable::Directory* directory() {
return dir_maker_.directory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class AttachmentDownloaderImplTest : public testing::Test {

AttachmentDownloaderImplTest() : num_completed_downloads_(0) {}

virtual void SetUp() override;
virtual void TearDown() override;
void SetUp() override;
void TearDown() override;

AttachmentDownloader* downloader() { return attachment_downloader_.get(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ class AttachmentServiceImplTest : public testing::Test,
protected:
AttachmentServiceImplTest() {}

virtual void SetUp() override {
void SetUp() override {
network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()),
make_scoped_ptr(new MockAttachmentDownloader()),
this);
}

virtual void TearDown() override {
void TearDown() override {
attachment_service_.reset();
ASSERT_FALSE(attachment_store_);
ASSERT_FALSE(attachment_uploader_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AttachmentServiceProxyTest : public testing::Test,
protected:
AttachmentServiceProxyTest() {}

virtual void SetUp() {
void SetUp() override {
CalledOnValidThread();
stub_thread.reset(new base::Thread("attachment service stub thread"));
stub_thread->Start();
Expand All @@ -108,8 +108,7 @@ class AttachmentServiceProxyTest : public testing::Test,
count_callback_drop = 0;
}

virtual void TearDown()
override {
void TearDown() override {
// We must take care to call the stub's destructor on the stub_thread
// because that's the thread to which its WeakPtrs are bound.
if (stub) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class AttachmentStoreHandleTest : public testing::Test {
read_all_metadata_call_count_(0),
dtor_call_count_(0) {}

virtual void SetUp() {
void SetUp() override {
scoped_ptr<AttachmentStoreBase> backend(new MockAttachmentStore(
base::Bind(&AttachmentStoreHandleTest::InitCalled,
base::Unretained(this)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ class AttachmentUploaderImplTest : public testing::Test,

protected:
AttachmentUploaderImplTest();
virtual void SetUp();
virtual void TearDown();
void SetUp() override;
void TearDown() override;

// Run the message loop until UploadDone has been invoked |num_uploads| times.
void RunAndWaitFor(int num_uploads);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class FakeAttachmentDownloaderTest : public testing::Test {
protected:
FakeAttachmentDownloaderTest() {}

virtual void SetUp() override {}
void SetUp() override {}

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

AttachmentDownloader* downloader() {
return &attachment_downloader_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const char kAttachmentData[] = "some data";

class FakeAttachmentUploaderTest : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
upload_callback_count = 0;
upload_callback = base::Bind(&FakeAttachmentUploaderTest::Increment,
base::Unretained(this),
Expand Down
4 changes: 2 additions & 2 deletions sync/internal_api/http_bridge_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class SyncHttpBridgeTest : public testing::Test {
io_thread_("IO thread") {
}

virtual void SetUp() {
void SetUp() override {
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
io_thread_.StartWithOptions(options);
}

virtual void TearDown() {
void TearDown() override {
if (fake_default_request_context_getter_) {
GetIOThreadLoop()->ReleaseSoon(FROM_HERE,
fake_default_request_context_getter_);
Expand Down
2 changes: 1 addition & 1 deletion sync/internal_api/protocol_event_buffer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace syncer {
class ProtocolEventBufferTest : public ::testing::Test {
public:
ProtocolEventBufferTest();
virtual ~ProtocolEventBufferTest();
~ProtocolEventBufferTest() override;

static scoped_ptr<ProtocolEvent> MakeTestEvent(int64 id);
static bool HasId(const ProtocolEvent& event, int64 id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool BlockingTask::WasStarted() {
class CancelationSignalTest : public ::testing::Test {
public:
CancelationSignalTest();
virtual ~CancelationSignalTest();
~CancelationSignalTest() override;

// Starts the blocking task on a background thread. Does not wait for the
// task to start.
Expand Down
2 changes: 1 addition & 1 deletion sync/internal_api/public/util/weak_handle_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Derived : public Base, public base::SupportsWeakPtr<Derived> {};

class WeakHandleTest : public ::testing::Test {
protected:
virtual void TearDown() {
void TearDown() override {
// Process any last-minute posted tasks.
PumpLoop();
}
Expand Down
4 changes: 2 additions & 2 deletions sync/internal_api/sync_context_proxy_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class SyncContextProxyImplTest : public ::testing::Test {
: sync_task_runner_(base::ThreadTaskRunnerHandle::Get()),
type_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}

virtual void SetUp() {
void SetUp() override {
dir_maker_.SetUp();
registry_.reset(new ModelTypeRegistry(
workers_, dir_maker_.directory(), &nudge_handler_));
context_proxy_.reset(
new SyncContextProxyImpl(sync_task_runner_, registry_->AsWeakPtr()));
}

virtual void TearDown() {
void TearDown() override {
context_proxy_.reset();
registry_.reset();
dir_maker_.TearDown();
Expand Down
8 changes: 2 additions & 6 deletions sync/internal_api/sync_manager_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,9 @@ int64 MakeServerNode(UserShare* share, ModelType model_type,

class SyncApiTest : public testing::Test {
public:
virtual void SetUp() {
test_user_share_.SetUp();
}
void SetUp() override { test_user_share_.SetUp(); }

virtual void TearDown() {
test_user_share_.TearDown();
}
void TearDown() override { test_user_share_.TearDown(); }

protected:
// Create an entry with the given |model_type|, |client_tag| and
Expand Down
Loading

0 comments on commit 520ae85

Please sign in to comment.