Skip to content

Commit

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

Cr-Commit-Position: refs/heads/master@{#309710}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 29, 2014
1 parent 4a1efdc commit 3bb7119
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 40 deletions.
8 changes: 3 additions & 5 deletions dbus/bus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class Watch : public base::MessagePumpLibevent::Watcher {
dbus_watch_set_data(raw_watch_, this, NULL);
}

virtual ~Watch() {
dbus_watch_set_data(raw_watch_, NULL, NULL);
}
~Watch() override { dbus_watch_set_data(raw_watch_, NULL, NULL); }

// Returns true if the underlying file descriptor is ready to be watched.
bool IsReadyToBeWatched() {
Expand Down Expand Up @@ -84,13 +82,13 @@ class Watch : public base::MessagePumpLibevent::Watcher {

private:
// Implement MessagePumpLibevent::Watcher.
virtual void OnFileCanReadWithoutBlocking(int file_descriptor) override {
void OnFileCanReadWithoutBlocking(int file_descriptor) override {
const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_READABLE);
CHECK(success) << "Unable to allocate memory";
}

// Implement MessagePumpLibevent::Watcher.
virtual void OnFileCanWriteWithoutBlocking(int file_descriptor) override {
void OnFileCanWriteWithoutBlocking(int file_descriptor) override {
const bool success = dbus_watch_handle(raw_watch_, DBUS_WATCH_WRITABLE);
CHECK(success) << "Unable to allocate memory";
}
Expand Down
8 changes: 2 additions & 6 deletions dbus/dbus_statistics_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ class DBusStatisticsTest : public testing::Test {
DBusStatisticsTest() {
}

virtual void SetUp() override {
statistics::Initialize();
}
void SetUp() override { statistics::Initialize(); }

virtual void TearDown() override {
statistics::Shutdown();
}
void TearDown() override { statistics::Shutdown(); }

protected:
void AddTestMethodCalls() {
Expand Down
6 changes: 3 additions & 3 deletions dbus/end_to_end_async_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const int kHugePayloadSize = 64 << 20; // 64 MB
// ExportedObject.
class EndToEndAsyncTest : public testing::Test {
public:
virtual void SetUp() {
void SetUp() override {
// Make the main thread not to allow IO.
base::ThreadRestrictions::SetIOAllowed(false);

Expand Down Expand Up @@ -112,7 +112,7 @@ class EndToEndAsyncTest : public testing::Test {
run_loop_->Run();
}

virtual void TearDown() {
void TearDown() override {
bus_->ShutdownOnDBusThreadAndBlock();

// Shut down the service.
Expand Down Expand Up @@ -582,7 +582,7 @@ class SignalMultipleHandlerTest : public EndToEndAsyncTest {
SignalMultipleHandlerTest() {
}

virtual void SetUp() {
void SetUp() override {
// Set up base class.
EndToEndAsyncTest::SetUp();

Expand Down
4 changes: 2 additions & 2 deletions dbus/end_to_end_sync_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EndToEndSyncTest : public testing::Test {
EndToEndSyncTest() {
}

virtual void SetUp() {
void SetUp() override {
// Start the test service;
TestService::Options options;
test_service_.reset(new TestService(options));
Expand All @@ -40,7 +40,7 @@ class EndToEndSyncTest : public testing::Test {
ASSERT_FALSE(client_bus_->HasDBusThread());
}

virtual void TearDown() {
void TearDown() override {
test_service_->ShutdownAndBlock();
test_service_->Stop();
client_bus_->ShutdownAndBlock();
Expand Down
6 changes: 2 additions & 4 deletions dbus/mock_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MockTest : public testing::Test {
MockTest() {
}

virtual void SetUp() {
void SetUp() override {
// Create a mock bus.
Bus::Options options;
options.bus_type = Bus::SYSTEM;
Expand Down Expand Up @@ -66,9 +66,7 @@ class MockTest : public testing::Test {
EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
}

virtual void TearDown() {
mock_bus_->ShutdownAndBlock();
}
void TearDown() override { mock_bus_->ShutdownAndBlock(); }

// Called when the response is received.
void OnResponse(Response* response) {
Expand Down
19 changes: 9 additions & 10 deletions dbus/object_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ class ObjectManagerTest
}
};

virtual PropertySet* CreateProperties(
ObjectProxy* object_proxy,
const ObjectPath& object_path,
const std::string& interface_name) override {
PropertySet* CreateProperties(ObjectProxy* object_proxy,
const ObjectPath& object_path,
const std::string& interface_name) override {
Properties* properties = new Properties(
object_proxy, interface_name,
base::Bind(&ObjectManagerTest::OnPropertyChanged,
base::Unretained(this), object_path));
return static_cast<PropertySet*>(properties);
}

virtual void SetUp() {
void SetUp() override {
// Make the main thread not to allow IO.
base::ThreadRestrictions::SetIOAllowed(false);

Expand Down Expand Up @@ -93,7 +92,7 @@ class ObjectManagerTest
WaitForObject();
}

virtual void TearDown() {
void TearDown() override {
bus_->ShutdownOnDBusThreadAndBlock();

// Shut down the service.
Expand Down Expand Up @@ -126,15 +125,15 @@ class ObjectManagerTest

protected:
// Called when an object is added.
virtual void ObjectAdded(const ObjectPath& object_path,
const std::string& interface_name) override {
void ObjectAdded(const ObjectPath& object_path,
const std::string& interface_name) override {
added_objects_.push_back(std::make_pair(object_path, interface_name));
run_loop_->Quit();
}

// Called when an object is removed.
virtual void ObjectRemoved(const ObjectPath& object_path,
const std::string& interface_name) override {
void ObjectRemoved(const ObjectPath& object_path,
const std::string& interface_name) override {
removed_objects_.push_back(std::make_pair(object_path, interface_name));
run_loop_->Quit();
}
Expand Down
6 changes: 2 additions & 4 deletions dbus/object_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace {

class ObjectProxyTest : public testing::Test {
protected:
virtual void SetUp() override {
void SetUp() override {
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
Expand All @@ -25,9 +25,7 @@ class ObjectProxyTest : public testing::Test {
"org.chromium.TestService", ObjectPath("/org/chromium/TestObject"));
}

virtual void TearDown() override {
bus_->ShutdownAndBlock();
}
void TearDown() override { bus_->ShutdownAndBlock(); }

base::MessageLoopForIO message_loop_;
scoped_refptr<Bus> bus_;
Expand Down
4 changes: 2 additions & 2 deletions dbus/property_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PropertyTest : public testing::Test {
}
};

virtual void SetUp() {
void SetUp() override {
// Make the main thread not to allow IO.
base::ThreadRestrictions::SetIOAllowed(false);

Expand Down Expand Up @@ -87,7 +87,7 @@ class PropertyTest : public testing::Test {
properties_->GetAll();
}

virtual void TearDown() {
void TearDown() override {
bus_->ShutdownOnDBusThreadAndBlock();

// Shut down the service.
Expand Down
4 changes: 2 additions & 2 deletions dbus/signal_sender_verification_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SignalSenderVerificationTest : public testing::Test {
on_ownership_called_(false) {
}

virtual void SetUp() {
void SetUp() override {
base::StatisticsRecorder::Initialize();

// Make the main thread not to allow IO.
Expand Down Expand Up @@ -94,7 +94,7 @@ class SignalSenderVerificationTest : public testing::Test {
ASSERT_FALSE(latest_name_owner_.empty());
}

virtual void TearDown() {
void TearDown() override {
bus_->ShutdownOnDBusThreadAndBlock();

// Shut down the service.
Expand Down
4 changes: 2 additions & 2 deletions dbus/test_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TestService : public base::Thread {
static const int kNumMethodsToExport;

explicit TestService(const Options& options);
virtual ~TestService();
~TestService() override;

// Starts the service in a separate thread.
// Returns true if the thread is started successfully.
Expand Down Expand Up @@ -106,7 +106,7 @@ class TestService : public base::Thread {
bool success);

// base::Thread override.
virtual void Run(base::MessageLoop* message_loop) override;
void Run(base::MessageLoop* message_loop) override;

//
// Exported methods.
Expand Down

0 comments on commit 3bb7119

Please sign in to comment.