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

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

Issue 2613653003: Move some basic early process init into Service Manager (Closed)
Patch Set: . 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..465fddcefbb021dc5183aeb55659fe359c868561
--- /dev/null
+++ b/services/service_manager/embedder/main_delegate.h
@@ -0,0 +1,51 @@
+// 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 SERVICE_MANAGER_EMBEDDER_EXPORT MainDelegate {
jam 2017/03/20 15:06:16 nit: the export thing isn't needed for non-copyabl
Ken Rockot(use gerrit already) 2017/03/20 17:27:05 Done
+ 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. Should return |true| if
+ // initialization is successful, in which case |*exit_code| is ignored. If
+ // this returns |false|, the process exits immediately with |*exit_code| as
+ // the exit code.
+ virtual bool Initialize(const InitializeParams& params, int* exit_code) = 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_

Powered by Google App Engine
This is Rietveld 408576698