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

Unified Diff: mojo/edk/test/scoped_ipc_support.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: convert remaining MP tests and simplify RawChannel destruction Created 5 years, 3 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
Index: mojo/edk/test/scoped_ipc_support.cc
diff --git a/mojo/edk/test/scoped_ipc_support.cc b/mojo/edk/test/scoped_ipc_support.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ffc721ca46ffb6ac57cb947b94e4f38848b095ee
--- /dev/null
+++ b/mojo/edk/test/scoped_ipc_support.cc
@@ -0,0 +1,63 @@
+// Copyright 2015 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 "mojo/edk/test/scoped_ipc_support.h"
+
+#include "base/message_loop/message_loop.h"
+#include "mojo/edk/embedder/embedder.h"
+
+namespace mojo {
+namespace test {
+
+namespace internal {
+
+ScopedIPCSupportHelper::ScopedIPCSupportHelper()
+ : event_(true, false) { // Manual reset.
+}
+
+ScopedIPCSupportHelper::~ScopedIPCSupportHelper() {
+ if (base::MessageLoop::current() &&
+ base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
+ embedder::ShutdownIPCSupportOnIOThread();
+ } else {
+ embedder::ShutdownIPCSupportAndWaitForNoChannels();
+ event_.Wait();
+ }
+}
+
+void ScopedIPCSupportHelper::Init(
+ embedder::ProcessType process_type,
+ embedder::ProcessDelegate* process_delegate,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle) {
+ io_thread_task_runner_ = io_thread_task_runner;
+ // Note: Run delegate methods on the I/O thread.
+ embedder::InitIPCSupport(process_type, io_thread_task_runner_,
+ process_delegate, io_thread_task_runner_,
+ platform_handle.Pass());
+}
+
+void ScopedIPCSupportHelper::OnShutdownCompleteImpl() {
+ event_.Signal();
+}
+
+} // namespace internal
+
+ScopedIPCSupport::ScopedIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner) {
+ helper_.Init(embedder::ProcessType::NONE,
+ this,
+ io_thread_task_runner.Pass(),
+ embedder::ScopedPlatformHandle());
+}
+
+ScopedIPCSupport::~ScopedIPCSupport() {
+}
+
+void ScopedIPCSupport::OnShutdownComplete() {
+ helper_.OnShutdownCompleteImpl();
+}
+
+} // namespace test
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698