OLD | NEW |
| (Empty) |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ | |
6 #define SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ | |
7 | |
8 #include "services/service_manager/embedder/service_manager_embedder_export.h" | |
9 | |
10 namespace base { | |
11 namespace mac { | |
12 class ScopedNSAutoreleasePool; | |
13 } | |
14 } | |
15 | |
16 namespace service_manager { | |
17 | |
18 // An interface which must be implemented by Service Manager embedders to | |
19 // control basic process initialization and shutdown, as well as early branching | |
20 // to run specific types of subprocesses. | |
21 class MainDelegate { | |
22 public: | |
23 // Extra parameters passed to MainDelegate::Initialize. | |
24 struct InitializeParams { | |
25 #if defined(OS_MACOSX) | |
26 // The outermost autorelease pool, allocated by internal service manager | |
27 // logic. This is guaranteed to live throughout the extent of Run(). | |
28 base::mac::ScopedNSAutoreleasePool* autorelease_pool = nullptr; | |
29 #endif | |
30 }; | |
31 | |
32 virtual ~MainDelegate() {} | |
33 | |
34 // Perform early process initialization. Returns -1 if successful, or the exit | |
35 // code with which the process should be terminated due to initialization | |
36 // failure. | |
37 virtual int Initialize(const InitializeParams& params) = 0; | |
38 | |
39 // Runs the main process logic. Called exactly once, and only after a | |
40 // successful call to Initialize(). Returns the exit code to use when | |
41 // terminating the process after Run() (and then ShutDown()) completes. | |
42 virtual int Run() = 0; | |
43 | |
44 // Called after Run() returns, before exiting the process. | |
45 virtual void ShutDown() = 0; | |
46 }; | |
47 | |
48 } // namespace service_manager | |
49 | |
50 #endif // SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ | |
OLD | NEW |