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

Unified Diff: ipc/mojo_event.cc

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/mojo_event.h ('k') | ipc/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo_event.cc
diff --git a/ipc/mojo_event.cc b/ipc/mojo_event.cc
new file mode 100644
index 0000000000000000000000000000000000000000..623b473c9f38c684a117c544c0d4466376c24a0b
--- /dev/null
+++ b/ipc/mojo_event.cc
@@ -0,0 +1,39 @@
+// 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.
+
+#include "ipc/mojo_event.h"
+
+namespace IPC {
+
+MojoEvent::MojoEvent() {
+ mojo::MessagePipe pipe;
+ signal_handle_ = std::move(pipe.handle0);
+ wait_handle_ = std::move(pipe.handle1);
+}
+
+MojoEvent::~MojoEvent() {}
+
+void MojoEvent::Signal() {
+ base::AutoLock lock(lock_);
+ if (is_signaled_)
+ return;
+ is_signaled_ = true;
+ MojoResult rv = mojo::WriteMessageRaw(
+ signal_handle_.get(), nullptr, 0, nullptr, 0,
+ MOJO_WRITE_MESSAGE_FLAG_NONE);
+ DCHECK_EQ(rv, MOJO_RESULT_OK);
+}
+
+void MojoEvent::Reset() {
+ base::AutoLock lock(lock_);
+ if (!is_signaled_)
+ return;
+ is_signaled_ = false;
+ MojoResult rv = mojo::ReadMessageRaw(
+ wait_handle_.get(), nullptr, nullptr, nullptr, nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE);
+ DCHECK_EQ(rv, MOJO_RESULT_OK);
+}
+
+} // namespace IPC
« no previous file with comments | « ipc/mojo_event.h ('k') | ipc/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698