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

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

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.cc
diff --git a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
index 9f3b97d7579a3b2fa8dd3db435f6bb80bc1a2aca..ce4a4a30d96606aae9d6608c103c1ebc011657fe 100644
--- a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
+++ b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
@@ -10,17 +10,22 @@
namespace mojo {
namespace test {
-ScopedIPCSupport::ScopedIPCSupport(
- scoped_refptr<base::TaskRunner> io_thread_task_runner)
- : io_thread_task_runner_(io_thread_task_runner),
+namespace internal {
+
+ScopedIPCSupportBase::ScopedIPCSupportBase(
+ 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.Pass()),
event_(true, false) { // Manual reset.
// Note: Run delegate methods on the I/O thread.
- embedder::InitIPCSupport(embedder::ProcessType::NONE, io_thread_task_runner,
- this, io_thread_task_runner,
- embedder::ScopedPlatformHandle());
+ embedder::InitIPCSupport(process_type, io_thread_task_runner_,
+ process_delegate, io_thread_task_runner_,
+ platform_handle.Pass());
}
-ScopedIPCSupport::~ScopedIPCSupport() {
+ScopedIPCSupportBase::~ScopedIPCSupportBase() {
if (base::MessageLoop::current() &&
base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
embedder::ShutdownIPCSupportOnIOThread();
@@ -30,9 +35,88 @@ ScopedIPCSupport::~ScopedIPCSupport() {
}
}
-void ScopedIPCSupport::OnShutdownComplete() {
+void ScopedIPCSupportBase::OnShutdownCompleteImpl() {
event_.Signal();
}
+} // namespace internal
+
+ScopedIPCSupport::ScopedIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner)
+ : ScopedIPCSupportBase(embedder::ProcessType::NONE,
+ this,
+ io_thread_task_runner.Pass(),
+ embedder::ScopedPlatformHandle()) {
+}
+
+ScopedIPCSupport::~ScopedIPCSupport() {
+}
+
+void ScopedIPCSupport::OnShutdownComplete() {
+ OnShutdownCompleteImpl();
+}
+
+ScopedMasterIPCSupport::ScopedMasterIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner)
+ : ScopedIPCSupportBase(embedder::ProcessType::MASTER,
+ this,
+ io_thread_task_runner.Pass(),
+ embedder::ScopedPlatformHandle()) {
+}
+
+ScopedMasterIPCSupport::ScopedMasterIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect)
+ : ScopedIPCSupportBase(embedder::ProcessType::MASTER,
+ this,
+ io_thread_task_runner.Pass(),
+ embedder::ScopedPlatformHandle()),
+ on_slave_disconnect_(on_slave_disconnect) {
+}
+
+ScopedMasterIPCSupport::~ScopedMasterIPCSupport() {
+}
+
+void ScopedMasterIPCSupport::OnShutdownComplete() {
+ OnShutdownCompleteImpl();
+}
+
+void ScopedMasterIPCSupport::OnSlaveDisconnect(embedder::SlaveInfo slave_info) {
+ if (!on_slave_disconnect_.is_null())
+ on_slave_disconnect_.Run(slave_info);
+}
+
+ScopedSlaveIPCSupport::ScopedSlaveIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle)
+ : ScopedIPCSupportBase(embedder::ProcessType::SLAVE,
+ this,
+ io_thread_task_runner.Pass(),
+ platform_handle.Pass()) {
+}
+
+ScopedSlaveIPCSupport::ScopedSlaveIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner,
+ embedder::ScopedPlatformHandle platform_handle,
+ base::Closure on_master_disconnect)
+ : ScopedIPCSupportBase(embedder::ProcessType::SLAVE,
+ this,
+ io_thread_task_runner.Pass(),
+ platform_handle.Pass()),
+ on_master_disconnect_(on_master_disconnect) {
+}
+
+ScopedSlaveIPCSupport::~ScopedSlaveIPCSupport() {
+}
+
+void ScopedSlaveIPCSupport::OnShutdownComplete() {
+ OnShutdownCompleteImpl();
+}
+
+void ScopedSlaveIPCSupport::OnMasterDisconnect() {
+ if (!on_master_disconnect_.is_null())
+ on_master_disconnect_.Run();
+}
+
} // namespace test
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698