Skip to content

Commit

Permalink
Standardize usage of virtual/override/final in ipc/
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
R=agl@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#300623}
  • Loading branch information
zetafunction authored and Commit bot committed Oct 22, 2014
1 parent ffe2c7a commit fe61fca
Show file tree
Hide file tree
Showing 30 changed files with 197 additions and 208 deletions.
3 changes: 1 addition & 2 deletions ipc/ipc_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ class IPC_EXPORT Channel : public Sender {
static scoped_ptr<Channel> CreateServer(
const IPC::ChannelHandle &channel_handle, Listener* listener);


virtual ~Channel();
~Channel() override;

// Connect the pipe. On the server side, this will initiate
// waiting for connections. On the client, it attempts to
Expand Down
5 changes: 2 additions & 3 deletions ipc/ipc_channel_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ class PlatformChannelFactory : public ChannelFactory {
: handle_(handle), mode_(mode) {
}

virtual std::string GetName() const override {
std::string GetName() const override {
return handle_.name;
}

virtual scoped_ptr<Channel> BuildChannel(
Listener* listener) override {
scoped_ptr<Channel> BuildChannel(Listener* listener) override {
return Channel::Create(handle_, mode_, listener);
}

Expand Down
30 changes: 14 additions & 16 deletions ipc/ipc_channel_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ class IPC_EXPORT ChannelPosix : public Channel,
public:
ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode,
Listener* listener);
virtual ~ChannelPosix();
~ChannelPosix() override;

// Channel implementation
virtual bool Connect() override;
virtual void Close() override;
virtual bool Send(Message* message) override;
virtual base::ProcessId GetPeerPID() const override;
virtual base::ProcessId GetSelfPID() const override;
virtual int GetClientFileDescriptor() const override;
virtual base::ScopedFD TakeClientFileDescriptor() override;
bool Connect() override;
void Close() override;
bool Send(Message* message) override;
base::ProcessId GetPeerPID() const override;
base::ProcessId GetSelfPID() const override;
int GetClientFileDescriptor() const override;
base::ScopedFD TakeClientFileDescriptor() override;

// Returns true if the channel supports listening for connections.
bool AcceptsConnections() const;
Expand Down Expand Up @@ -102,12 +102,10 @@ class IPC_EXPORT ChannelPosix : public Channel,
void QueueCloseFDMessage(int fd, int hops);

// ChannelReader implementation.
virtual ReadState ReadData(char* buffer,
int buffer_len,
int* bytes_read) override;
virtual bool WillDispatchInputMessage(Message* msg) override;
virtual bool DidEmptyInputBuffers() override;
virtual void HandleInternalMessage(const Message& msg) override;
ReadState ReadData(char* buffer, int buffer_len, int* bytes_read) override;
bool WillDispatchInputMessage(Message* msg) override;
bool DidEmptyInputBuffers() override;
void HandleInternalMessage(const Message& msg) override;

#if defined(IPC_USES_READWRITE)
// Reads the next message from the fd_pipe_ and appends them to the
Expand All @@ -129,8 +127,8 @@ class IPC_EXPORT ChannelPosix : public Channel,
void ClearInputFDs();

// MessageLoopForIO::Watcher implementation.
virtual void OnFileCanReadWithoutBlocking(int fd) override;
virtual void OnFileCanWriteWithoutBlocking(int fd) override;
void OnFileCanReadWithoutBlocking(int fd) override;
void OnFileCanWriteWithoutBlocking(int fd) override;

Mode mode_;

Expand Down
12 changes: 6 additions & 6 deletions ipc/ipc_channel_posix_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,35 @@ class IPCChannelPosixTestListener : public IPC::Listener {
quit_only_on_message_(quit_only_on_message) {
}

virtual ~IPCChannelPosixTestListener() {}
~IPCChannelPosixTestListener() override {}

virtual bool OnMessageReceived(const IPC::Message& message) override {
bool OnMessageReceived(const IPC::Message& message) override {
EXPECT_EQ(message.type(), kQuitMessage);
status_ = MESSAGE_RECEIVED;
QuitRunLoop();
return true;
}

virtual void OnChannelConnected(int32 peer_pid) override {
void OnChannelConnected(int32 peer_pid) override {
status_ = CONNECTED;
if (!quit_only_on_message_) {
QuitRunLoop();
}
}

virtual void OnChannelError() override {
void OnChannelError() override {
status_ = CHANNEL_ERROR;
QuitRunLoop();
}

virtual void OnChannelDenied() override {
void OnChannelDenied() override {
status_ = DENIED;
if (!quit_only_on_message_) {
QuitRunLoop();
}
}

virtual void OnChannelListenError() override {
void OnChannelListenError() override {
status_ = LISTEN_ERROR;
if (!quit_only_on_message_) {
QuitRunLoop();
Expand Down
12 changes: 6 additions & 6 deletions ipc/ipc_channel_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);

virtual ~ChannelProxy();
~ChannelProxy() override;

// Initializes the channel proxy. Only call this once to initialize a channel
// proxy that was not initialized in its constructor. If create_pipe_now is
Expand All @@ -98,7 +98,7 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {

// Send a message asynchronously. The message is routed to the background
// thread where it is passed to the IPC::Channel's Send method.
virtual bool Send(Message* message) override;
bool Send(Message* message) override;

// Used to intercept messages as they are received on the background thread.
//
Expand Down Expand Up @@ -152,12 +152,12 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {

protected:
friend class base::RefCountedThreadSafe<Context>;
virtual ~Context();
~Context() override;

// IPC::Listener methods:
virtual bool OnMessageReceived(const Message& message) override;
virtual void OnChannelConnected(int32 peer_pid) override;
virtual void OnChannelError() override;
bool OnMessageReceived(const Message& message) override;
void OnChannelConnected(int32 peer_pid) override;
void OnChannelError() override;

// Like OnMessageReceived but doesn't try the filters.
bool OnMessageReceivedNoFilter(const Message& message);
Expand Down
26 changes: 13 additions & 13 deletions ipc/ipc_channel_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ namespace {
class QuitListener : public IPC::Listener {
public:
QuitListener() : bad_message_received_(false) {}
virtual ~QuitListener() {}
~QuitListener() override {}

virtual bool OnMessageReceived(const IPC::Message& message) override {
bool OnMessageReceived(const IPC::Message& message) override {
IPC_BEGIN_MESSAGE_MAP(QuitListener, message)
IPC_MESSAGE_HANDLER(WorkerMsg_Quit, OnQuit)
IPC_MESSAGE_HANDLER(TestMsg_BadMessage, OnBadMessage)
IPC_END_MESSAGE_MAP()
return true;
}

virtual void OnBadMessageReceived(const IPC::Message& message) override {
void OnBadMessageReceived(const IPC::Message& message) override {
bad_message_received_ = true;
}

Expand All @@ -76,14 +76,14 @@ class QuitListener : public IPC::Listener {
class ChannelReflectorListener : public IPC::Listener {
public:
ChannelReflectorListener() : channel_(NULL) {}
virtual ~ChannelReflectorListener() {}
~ChannelReflectorListener() override {}

void Init(IPC::Channel* channel) {
DCHECK(!channel_);
channel_ = channel;
}

virtual bool OnMessageReceived(const IPC::Message& message) override {
bool OnMessageReceived(const IPC::Message& message) override {
IPC_BEGIN_MESSAGE_MAP(ChannelReflectorListener, message)
IPC_MESSAGE_HANDLER(TestMsg_Bounce, OnTestBounce)
IPC_MESSAGE_HANDLER(TestMsg_SendBadMessage, OnSendBadMessage)
Expand Down Expand Up @@ -143,32 +143,32 @@ class MessageCountFilter : public IPC::MessageFilter {
last_filter_event_(NONE),
message_filtering_enabled_(false) {}

virtual void OnFilterAdded(IPC::Sender* sender) override {
void OnFilterAdded(IPC::Sender* sender) override {
EXPECT_TRUE(sender);
EXPECT_EQ(NONE, last_filter_event_);
last_filter_event_ = FILTER_ADDED;
}

virtual void OnChannelConnected(int32_t peer_pid) override {
void OnChannelConnected(int32_t peer_pid) override {
EXPECT_EQ(FILTER_ADDED, last_filter_event_);
EXPECT_NE(static_cast<int32_t>(base::kNullProcessId), peer_pid);
last_filter_event_ = CHANNEL_CONNECTED;
}

virtual void OnChannelError() override {
void OnChannelError() override {
EXPECT_EQ(CHANNEL_CONNECTED, last_filter_event_);
last_filter_event_ = CHANNEL_ERROR;
}

virtual void OnChannelClosing() override {
void OnChannelClosing() override {
// We may or may not have gotten OnChannelError; if not, the last event has
// to be OnChannelConnected.
if (last_filter_event_ != CHANNEL_ERROR)
EXPECT_EQ(CHANNEL_CONNECTED, last_filter_event_);
last_filter_event_ = CHANNEL_CLOSING;
}

virtual void OnFilterRemoved() override {
void OnFilterRemoved() override {
// If the channel didn't get a chance to connect, we might see the
// OnFilterRemoved event with no other events preceding it. We still want
// OnFilterRemoved to be called to allow for deleting the Filter.
Expand All @@ -177,7 +177,7 @@ class MessageCountFilter : public IPC::MessageFilter {
last_filter_event_ = FILTER_REMOVED;
}

virtual bool OnMessageReceived(const IPC::Message& message) override {
bool OnMessageReceived(const IPC::Message& message) override {
// We should always get the OnFilterAdded and OnChannelConnected events
// prior to any messages.
EXPECT_EQ(CHANNEL_CONNECTED, last_filter_event_);
Expand All @@ -203,7 +203,7 @@ class MessageCountFilter : public IPC::MessageFilter {
CHECK(false);
}

virtual bool GetSupportedMessageClasses(
bool GetSupportedMessageClasses(
std::vector<uint32>* supported_message_classes) const override {
if (is_global_filter_)
return false;
Expand All @@ -219,7 +219,7 @@ class MessageCountFilter : public IPC::MessageFilter {
FilterEvent last_filter_event() const { return last_filter_event_; }

private:
virtual ~MessageCountFilter() {}
~MessageCountFilter() override {}

size_t messages_received_;
uint32 supported_message_class_;
Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_channel_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
class ChannelListenerWithOnConnectedSend : public IPC::TestChannelListener {
public:
ChannelListenerWithOnConnectedSend() {}
virtual ~ChannelListenerWithOnConnectedSend() {}
~ChannelListenerWithOnConnectedSend() override {}

virtual void OnChannelConnected(int32 peer_pid) override {
void OnChannelConnected(int32 peer_pid) override {
SendNextMessage();
}
};
Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_forwarding_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class IPC_EXPORT ForwardingMessageFilter : public MessageFilter {
void RemoveRoute(int routing_id);

// MessageFilter methods:
virtual bool OnMessageReceived(const Message& message) override;
bool OnMessageReceived(const Message& message) override;

private:
virtual ~ForwardingMessageFilter();
~ForwardingMessageFilter() override;

std::set<int> message_ids_to_filter_;

Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_fuzzing_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FuzzerServerListener : public SimpleListener {
public:
FuzzerServerListener() : message_count_(2), pending_messages_(0) {
}
virtual bool OnMessageReceived(const IPC::Message& msg) override {
bool OnMessageReceived(const IPC::Message& msg) override {
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
++pending_messages_;
IPC_BEGIN_MESSAGE_MAP(FuzzerServerListener, msg)
Expand Down Expand Up @@ -199,7 +199,7 @@ class FuzzerClientListener : public SimpleListener {
FuzzerClientListener() : last_msg_(NULL) {
}

virtual bool OnMessageReceived(const IPC::Message& msg) override {
bool OnMessageReceived(const IPC::Message& msg) override {
last_msg_ = new IPC::Message(msg);
base::MessageLoop::current()->Quit();
return true;
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class IPC_EXPORT Message : public Pickle {
HAS_SENT_TIME_BIT = 0x80,
};

virtual ~Message();
~Message() override;

Message();

Expand Down
8 changes: 4 additions & 4 deletions ipc/ipc_message_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@
typedef Schema::Param Param; \
enum { ID = IPC_MESSAGE_ID() }; \
msg_class(IPC_TYPE_IN_##in_cnt in_list); \
virtual ~msg_class(); \
~msg_class() override; \
static bool Read(const Message* msg, Schema::Param* p); \
static void Log(std::string* name, const Message* msg, std::string* l); \
IPC_ASYNC_MESSAGE_METHODS_##in_cnt \
Expand All @@ -614,7 +614,7 @@
enum { ID = IPC_MESSAGE_ID() }; \
msg_class(int32 routing_id IPC_COMMA_##in_cnt \
IPC_TYPE_IN_##in_cnt in_list); \
virtual ~msg_class(); \
~msg_class() override; \
static bool Read(const Message* msg, Schema::Param* p); \
static void Log(std::string* name, const Message* msg, std::string* l); \
IPC_ASYNC_MESSAGE_METHODS_##in_cnt \
Expand All @@ -631,7 +631,7 @@
msg_class(IPC_TYPE_IN_##in_cnt in_list \
IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
IPC_TYPE_OUT_##out_cnt out_list); \
virtual ~msg_class(); \
~msg_class() override; \
static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \
static bool ReadReplyParam( \
const Message* msg, \
Expand All @@ -653,7 +653,7 @@
IPC_TYPE_IN_##in_cnt in_list \
IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
IPC_TYPE_OUT_##out_cnt out_list); \
virtual ~msg_class(); \
~msg_class() override; \
static bool ReadSendParam(const Message* msg, Schema::SendParam* p); \
static bool ReadReplyParam( \
const Message* msg, \
Expand Down
8 changes: 4 additions & 4 deletions ipc/ipc_perftest_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ChannelReflectorListener : public Listener {
VLOG(1) << "Client listener up";
}

virtual ~ChannelReflectorListener() {
~ChannelReflectorListener() override {
VLOG(1) << "Client listener down";
latency_tracker_.ShowResults();
}
Expand All @@ -91,7 +91,7 @@ class ChannelReflectorListener : public Listener {
channel_ = channel;
}

virtual bool OnMessageReceived(const Message& message) override {
bool OnMessageReceived(const Message& message) override {
CHECK(channel_);

PickleIterator iter(message);
Expand Down Expand Up @@ -142,7 +142,7 @@ class PerformanceChannelListener : public Listener {
VLOG(1) << "Server listener up";
}

virtual ~PerformanceChannelListener() {
~PerformanceChannelListener() override {
VLOG(1) << "Server listener down";
}

Expand All @@ -160,7 +160,7 @@ class PerformanceChannelListener : public Listener {
payload_ = std::string(msg_size_, 'a');
}

virtual bool OnMessageReceived(const Message& message) override {
bool OnMessageReceived(const Message& message) override {
CHECK(sender_);

PickleIterator iter(message);
Expand Down
Loading

0 comments on commit fe61fca

Please sign in to comment.