Chromium Code Reviews| 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 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
| |
| 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. Should return |true| if | |
| 35 // initialization is successful, in which case |*exit_code| is ignored. If | |
| 36 // this returns |false|, the process exits immediately with |*exit_code| as | |
| 37 // the exit code. | |
| 38 virtual bool Initialize(const InitializeParams& params, int* exit_code) = 0; | |
| 39 | |
| 40 // Runs the main process logic. Called exactly once, and only after a | |
| 41 // successful call to Initialize(). Returns the exit code to use when | |
| 42 // terminating the process after Run() (and then ShutDown()) completes. | |
| 43 virtual int Run() = 0; | |
| 44 | |
| 45 // Called after Run() returns, before exiting the process. | |
| 46 virtual void ShutDown() = 0; | |
| 47 }; | |
| 48 | |
| 49 } // namespace service_manager | |
| 50 | |
| 51 #endif // SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ | |
| OLD | NEW |