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

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

Issue 1142043005: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h
diff --git a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h
index 2569c4e1b5244dedff8d5a7c2b11f17ab863bc5b..bdb727eaba6188fd965e082200cd44379a153df3 100644
--- a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h
+++ b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h
@@ -5,36 +5,107 @@
#ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
#define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_
+#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "base/task_runner.h"
+#include "mojo/edk/embedder/master_process_delegate.h"
#include "mojo/edk/embedder/process_delegate.h"
+#include "mojo/edk/embedder/process_type.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/edk/embedder/slave_process_delegate.h"
namespace mojo {
namespace test {
+namespace internal {
+
+class ScopedIPCSupportBase {
+ public:
+ ScopedIPCSupportBase(embedder::ProcessType process_type,
+ embedder::ProcessDelegate* process_delegate,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle);
+ ~ScopedIPCSupportBase();
+
+ protected:
+ void OnShutdownCompleteImpl();
+
+ scoped_refptr<base::TaskRunner> io_thread_task_runner_;
+
+ private:
+ // Set after shut down.
+ base::WaitableEvent event_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportBase);
+};
+
+} // namespace internal
+
// A simple class that calls |mojo::embedder::InitIPCSupport()| (with
// |ProcessType::NONE|) on construction and |ShutdownIPCSupport()| on
// destruction (or |ShutdownIPCSupportOnIOThread()| if destroyed on the I/O
// thread).
-// TODO(vtl): Need master/slave versions.
-class ScopedIPCSupport : public embedder::ProcessDelegate {
+class ScopedIPCSupport : public internal::ScopedIPCSupportBase,
+ public embedder::ProcessDelegate {
public:
- ScopedIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner);
+ explicit ScopedIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
~ScopedIPCSupport() override;
private:
- // ProcessDelegate| implementation:
+ // |ProcessDelegate| implementation:
// Note: Executed on the I/O thread.
void OnShutdownComplete() override;
- scoped_refptr<base::TaskRunner> io_thread_task_runner_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
+};
- // Set after shut down.
- base::WaitableEvent event_;
+// Like |ScopedIPCSupport|, but with |ProcessType::MASTER|. It will (optionally)
+// call a callback (on the I/O thread) on receiving |OnSlaveDisconnect()|.
+class ScopedMasterIPCSupport : public internal::ScopedIPCSupportBase,
+ public embedder::MasterProcessDelegate {
+ public:
+ explicit ScopedMasterIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
+ ScopedMasterIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect);
+ ~ScopedMasterIPCSupport() override;
- DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
+ private:
+ // |MasterProcessDelegate| implementation:
+ // Note: Executed on the I/O thread.
+ void OnShutdownComplete() override;
+ void OnSlaveDisconnect(embedder::SlaveInfo slave_info) override;
+
+ base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedMasterIPCSupport);
+};
+
+// Like |ScopedIPCSupport|, but with |ProcessType::SLAVE|. It will (optionally)
+// call a callback (on the I/O thread) on receiving |OnMasterDisconnect()|.
+class ScopedSlaveIPCSupport : public internal::ScopedIPCSupportBase,
+ public embedder::SlaveProcessDelegate {
+ public:
+ ScopedSlaveIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle);
+ ScopedSlaveIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle,
+ base::Closure on_master_disconnect);
+ ~ScopedSlaveIPCSupport() override;
+
+ private:
+ // |SlaveProcessDelegate| implementation:
+ // Note: Executed on the I/O thread.
+ void OnShutdownComplete() override;
+ void OnMasterDisconnect() override;
+
+ base::Closure on_master_disconnect_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedSlaveIPCSupport);
};
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698