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

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

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: more cleanup Created 5 years, 2 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.h
diff --git a/mojo/edk/test/scoped_ipc_support.h b/mojo/edk/test/scoped_ipc_support.h
new file mode 100644
index 0000000000000000000000000000000000000000..cff0da7690e0310ecacf22df397ad846aa2599a7
--- /dev/null
+++ b/mojo/edk/test/scoped_ipc_support.h
@@ -0,0 +1,66 @@
+// 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.
+
+#ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
+#define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/task_runner.h"
+#include "mojo/edk/embedder/process_delegate.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/public/cpp/system/macros.h"
+
+namespace mojo {
+namespace edk {
+namespace test {
+
+namespace internal {
+
+class ScopedIPCSupportHelper {
+ public:
+ ScopedIPCSupportHelper();
+ ~ScopedIPCSupportHelper();
+
+ void Init(ProcessDelegate* process_delegate,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
+
+ void OnShutdownCompleteImpl();
+
+ private:
+ scoped_refptr<base::TaskRunner> io_thread_task_runner_;
+
+ // Set after shut down.
+ base::WaitableEvent event_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper);
+};
+
+} // namespace internal
+
+// A simple class that calls |InitIPCSupport()| on construction and
+// |ShutdownIPCSupport()| on destruction (or |ShutdownIPCSupportOnIOThread()|
+// if destroyed on the I/O thread).
+class ScopedIPCSupport : public ProcessDelegate {
+ public:
+ explicit ScopedIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
+ ~ScopedIPCSupport() override;
+
+ private:
+ // |ProcessDelegate| implementation:
+ // Note: Executed on the I/O thread.
+ void OnShutdownComplete() override;
+
+ internal::ScopedIPCSupportHelper helper_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
+};
+
+} // namespace test
+} // namespace edk
+} // namespace mojo
+
+#endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_

Powered by Google App Engine
This is Rietveld 408576698