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

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

Issue 1157843002: 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
« no previous file with comments | « third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h ('k') | third_party/mojo/src/mojo/public/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fad9c82c6d296bd88df7fdf81da90a8c961e9588 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,13 @@
namespace mojo {
namespace test {
-ScopedIPCSupport::ScopedIPCSupport(
- scoped_refptr<base::TaskRunner> io_thread_task_runner)
- : io_thread_task_runner_(io_thread_task_runner),
- 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());
+namespace internal {
+
+ScopedIPCSupportHelper::ScopedIPCSupportHelper()
+ : event_(true, false) { // Manual reset.
}
-ScopedIPCSupport::~ScopedIPCSupport() {
+ScopedIPCSupportHelper::~ScopedIPCSupportHelper() {
if (base::MessageLoop::current() &&
base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
embedder::ShutdownIPCSupportOnIOThread();
@@ -30,9 +26,90 @@ ScopedIPCSupport::~ScopedIPCSupport() {
}
}
-void ScopedIPCSupport::OnShutdownComplete() {
+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();
+}
+
+ScopedMasterIPCSupport::ScopedMasterIPCSupport(
+ scoped_refptr<base::TaskRunner> io_thread_task_runner) {
+ helper_.Init(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)
+ : on_slave_disconnect_(on_slave_disconnect) {
+ helper_.Init(embedder::ProcessType::MASTER, this,
+ io_thread_task_runner.Pass(), embedder::ScopedPlatformHandle());
+}
+
+ScopedMasterIPCSupport::~ScopedMasterIPCSupport() {
+}
+
+void ScopedMasterIPCSupport::OnShutdownComplete() {
+ helper_.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) {
+ helper_.Init(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)
+ : on_master_disconnect_(on_master_disconnect) {
+ helper_.Init(embedder::ProcessType::SLAVE, this, io_thread_task_runner.Pass(),
+ platform_handle.Pass());
+}
+
+ScopedSlaveIPCSupport::~ScopedSlaveIPCSupport() {
+}
+
+void ScopedSlaveIPCSupport::OnShutdownComplete() {
+ helper_.OnShutdownCompleteImpl();
+}
+
+void ScopedSlaveIPCSupport::OnMasterDisconnect() {
+ if (!on_master_disconnect_.is_null())
+ on_master_disconnect_.Run();
+}
+
} // namespace test
} // namespace mojo
« no previous file with comments | « third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h ('k') | third_party/mojo/src/mojo/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698