diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 22:37:55 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 22:37:55 +0000 |
commit | 06a07d94f8b33645f18b3bc3d67be6d8aeb158fa (patch) | |
tree | 4352c7d41eda55a73785d4ac9fac1e5d44f49e33 /ipc/ipc_sync_channel.h | |
parent | c462b22f1f644cc17568c4bd6f095bb89e5586a7 (diff) | |
download | chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.zip chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.tar.gz chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.tar.bz2 |
Refactor: Simplify WaitableEventWatcher.
This change uses a callback instead of a delegate for specifying what
should be called when a WaitableEvent occurs.
This simplifies the class and gets rid of a workaround internal to the
class to prevent name collision on "Delegate" inner classes.
Tested (on linux and windows):
ninja -C out/Debug chrome
out/Debug/base_unittests --gtest_filter=*WaitableEventWatcherTest*
BUG=
Review URL: https://chromiumcodereview.appspot.com/11953112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_sync_channel.h')
-rw-r--r-- | ipc/ipc_sync_channel.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ipc/ipc_sync_channel.h b/ipc/ipc_sync_channel.h index 87fc1f4..7b34b72 100644 --- a/ipc/ipc_sync_channel.h +++ b/ipc/ipc_sync_channel.h @@ -58,8 +58,7 @@ class SyncMessage; // is more than this object. If the message loop goes away while this object // is running and it's used to send a message, then it will use the invalid // message loop pointer to proxy it to the ipc thread. -class IPC_EXPORT SyncChannel : public ChannelProxy, - public base::WaitableEventWatcher::Delegate { +class IPC_EXPORT SyncChannel : public ChannelProxy { public: enum RestrictDispatchGroup { kRestrictDispatchGroup_None = 0, @@ -115,8 +114,7 @@ class IPC_EXPORT SyncChannel : public ChannelProxy, // SyncContext holds the per object data for SyncChannel, so that SyncChannel // can be deleted while it's being used in a different thread. See // ChannelProxy::Context for more information. - class SyncContext : public Context, - public base::WaitableEventWatcher::Delegate { + class SyncContext : public Context { public: SyncContext(Listener* listener, base::SingleThreadTaskRunner* ipc_task_runner, @@ -150,6 +148,10 @@ class IPC_EXPORT SyncChannel : public ChannelProxy, void OnSendTimeout(int message_id); base::WaitableEvent* shutdown_event() { return shutdown_event_; } + base::WaitableEventWatcher::EventCallback + shutdown_watcher_callback() const { + return shutdown_watcher_callback_; + } ReceivedSyncMsgQueue* received_sync_msgs() { return received_sync_msgs_; @@ -179,8 +181,7 @@ class IPC_EXPORT SyncChannel : public ChannelProxy, // Cancels all pending Send calls. void CancelPendingSends(); - // WaitableEventWatcher::Delegate implementation. - virtual void OnWaitableEventSignaled(base::WaitableEvent* arg) OVERRIDE; + void OnWaitableEventSignaled(base::WaitableEvent* arg); typedef std::deque<PendingSyncMsg> PendingSyncMessageQueue; PendingSyncMessageQueue deserializers_; @@ -190,12 +191,12 @@ class IPC_EXPORT SyncChannel : public ChannelProxy, base::WaitableEvent* shutdown_event_; base::WaitableEventWatcher shutdown_watcher_; + base::WaitableEventWatcher::EventCallback shutdown_watcher_callback_; int restrict_dispatch_group_; }; private: - // WaitableEventWatcher::Delegate implementation. - virtual void OnWaitableEventSignaled(base::WaitableEvent* arg) OVERRIDE; + void OnWaitableEventSignaled(base::WaitableEvent* arg); SyncContext* sync_context() { return reinterpret_cast<SyncContext*>(context()); @@ -217,6 +218,7 @@ class IPC_EXPORT SyncChannel : public ChannelProxy, // Used to signal events between the IPC and listener threads. base::WaitableEventWatcher dispatch_watcher_; + base::Callback<void(base::WaitableEvent*)> dispatch_watcher_callback_; DISALLOW_COPY_AND_ASSIGN(SyncChannel); }; |