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

Unified Diff: services/service_manager/public/cpp/standalone_service/standalone_service.cc

Issue 2620633004: Remove mojo::edk::test::ScopedIPCSupport (Closed)
Patch Set: . Created 3 years, 11 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: services/service_manager/public/cpp/standalone_service/standalone_service.cc
diff --git a/services/service_manager/public/cpp/standalone_service/standalone_service.cc b/services/service_manager/public/cpp/standalone_service/standalone_service.cc
index 2e49b73bb4058ee65501cefc042373f46269aec3..bd26da071156c7b37eea5e52a3587d6c663f71dc 100644
--- a/services/service_manager/public/cpp/standalone_service/standalone_service.cc
+++ b/services/service_manager/public/cpp/standalone_service/standalone_service.cc
@@ -11,7 +11,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/process_delegate.h"
+#include "mojo/edk/embedder/scoped_ipc_support.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/runner/common/client_util.h"
@@ -54,41 +54,6 @@ std::unique_ptr<LinuxSandbox> InitializeSandbox() {
}
#endif
-// Should be created and initialized on the main thread and kept alive as long
-// a Service is running in the current process.
-class ScopedAppContext : public mojo::edk::ProcessDelegate {
- public:
- ScopedAppContext()
- : io_thread_("io_thread"),
- wait_for_shutdown_event_(
- base::WaitableEvent::ResetPolicy::MANUAL,
- base::WaitableEvent::InitialState::NOT_SIGNALED) {
- mojo::edk::Init();
- io_thread_.StartWithOptions(
- base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
- mojo::edk::InitIPCSupport(this, io_thread_.task_runner());
- mojo::edk::SetParentPipeHandleFromCommandLine();
- }
-
- ~ScopedAppContext() override {
- mojo::edk::ShutdownIPCSupport();
- wait_for_shutdown_event_.Wait();
- }
-
- private:
- // ProcessDelegate implementation.
- void OnShutdownComplete() override {
- wait_for_shutdown_event_.Signal();
- }
-
- base::Thread io_thread_;
-
- // Used to unblock the main thread on shutdown.
- base::WaitableEvent wait_for_shutdown_event_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedAppContext);
-};
-
} // namespace
void RunStandaloneService(const StandaloneServiceCallback& callback) {
@@ -112,7 +77,17 @@ void RunStandaloneService(const StandaloneServiceCallback& callback) {
sandbox = InitializeSandbox();
#endif
- ScopedAppContext app_context;
+ mojo::edk::Init();
+
+ base::Thread io_thread("io_thread");
+ io_thread.StartWithOptions(
+ base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+
+ mojo::edk::ScopedIPCSupport ipc_support(
+ io_thread.task_runner(),
+ mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN);
+ mojo::edk::SetParentPipeHandleFromCommandLine();
+
callback.Run(GetServiceRequestFromCommandLine());
}

Powered by Google App Engine
This is Rietveld 408576698