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

Unified Diff: services/service_manager/embedder/main_delegate.h

Issue 2613653003: Move some basic early process init into Service Manager (Closed)
Patch Set: fix mac shutdown order Created 3 years, 9 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/embedder/main_delegate.h
diff --git a/services/service_manager/embedder/main_delegate.h b/services/service_manager/embedder/main_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..f9222959ecef93345514e28847d171b8384f27e5
--- /dev/null
+++ b/services/service_manager/embedder/main_delegate.h
@@ -0,0 +1,50 @@
+// Copyright 2017 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 SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
+#define SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
+
+#include "services/service_manager/embedder/service_manager_embedder_export.h"
+
+namespace base {
+namespace mac {
+class ScopedNSAutoreleasePool;
+}
+}
+
+namespace service_manager {
+
+// An interface which must be implemented by Service Manager embedders to
+// control basic process initialization and shutdown, as well as early branching
+// to run specific types of subprocesses.
+class MainDelegate {
+ public:
+ // Extra parameters passed to MainDelegate::Initialize.
+ struct InitializeParams {
+#if defined(OS_MACOSX)
+ // The outermost autorelease pool, allocated by internal service manager
+ // logic. This is guaranteed to live throughout the extent of Run().
+ base::mac::ScopedNSAutoreleasePool* autorelease_pool = nullptr;
+#endif
+ };
+
+ virtual ~MainDelegate() {}
+
+ // Perform early process initialization. Returns -1 if successful, or the exit
+ // code with which the process should be terminated due to initialization
+ // failure.
+ virtual int Initialize(const InitializeParams& params) = 0;
+
+ // Runs the main process logic. Called exactly once, and only after a
+ // successful call to Initialize(). Returns the exit code to use when
+ // terminating the process after Run() (and then ShutDown()) completes.
+ virtual int Run() = 0;
+
+ // Called after Run() returns, before exiting the process.
+ virtual void ShutDown() = 0;
+};
+
+} // namespace service_manager
+
+#endif // SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
« no previous file with comments | « services/service_manager/embedder/main.cc ('k') | services/service_manager/embedder/service_manager_embedder_export.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698