Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Unified Diff: ipc/mojo_event.h

Issue 2033243003: Use Mojo pipes to signal sync IPC events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gyp Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_sync_message_filter.cc ('k') | ipc/mojo_event.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo_event.h
diff --git a/ipc/mojo_event.h b/ipc/mojo_event.h
new file mode 100644
index 0000000000000000000000000000000000000000..079de284fc90f29e62b15abd5ca77b9b38bb0e3a
--- /dev/null
+++ b/ipc/mojo_event.h
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_MOJO_EVENT_H_
+#define IPC_MOJO_EVENT_H_
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+
+namespace IPC {
+
+// A MojoEvent is a simple wrapper around a Mojo message pipe which supports
+// common WaitableEvent-like methods of Signal() and Reset(). This class exists
+// to support the transition from legacy IPC to Mojo IPC and is not intended for
+// general use outside of src/ipc. Unlike base::WaitableEvent, all MojoEvents
+// must be manually reset.
+class MojoEvent {
+ public:
+ // Constructs a new MojoEvent that is initially not signaled.
+ MojoEvent();
+
+ ~MojoEvent();
+
+ // Gets a Handle that can be waited on for this MojoEvent. When the Event is
+ // signaled, this handle will have |MOJO_HANDLE_SIGNAL_READABLE| satisfied.
+ const mojo::Handle& GetHandle() const { return wait_handle_.get(); }
+
+ void Signal();
+ void Reset();
+
+ private:
+ mojo::ScopedMessagePipeHandle signal_handle_;
+ mojo::ScopedMessagePipeHandle wait_handle_;
+
+ base::Lock lock_;
+ bool is_signaled_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoEvent);
+};
+
+} // namespace IPC
+
+#endif // IPC_MOJO_EVENT_H_
« no previous file with comments | « ipc/ipc_sync_message_filter.cc ('k') | ipc/mojo_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698