| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_APP_MASH_MASH_RUNNER_H_ | 5 #ifndef CHROME_APP_MASH_MASH_RUNNER_H_ |
| 6 #define CHROME_APP_MASH_MASH_RUNNER_H_ | 6 #define CHROME_APP_MASH_MASH_RUNNER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "services/service_manager/public/interfaces/service.mojom.h" | 11 #include "services/service_manager/public/interfaces/service.mojom.h" |
| 12 | 12 |
| 13 namespace base { |
| 14 class RunLoop; |
| 15 } |
| 16 |
| 13 namespace service_manager { | 17 namespace service_manager { |
| 18 class Identity; |
| 14 class ServiceContext; | 19 class ServiceContext; |
| 15 } | 20 } |
| 16 | 21 |
| 17 // Responsible for running mash, both child and main processes. | 22 // Responsible for running mash, both child and main processes. |
| 18 class MashRunner { | 23 class MashRunner { |
| 19 public: | 24 public: |
| 20 MashRunner(); | 25 MashRunner(); |
| 21 ~MashRunner(); | 26 ~MashRunner(); |
| 22 | 27 |
| 23 // Returns 0 if the process was initialized correctly, or error code on | 28 // Returns 0 if the process was initialized correctly, or error code on |
| 24 // failure. | 29 // failure. |
| 25 int Run(); | 30 int Run(); |
| 26 | 31 |
| 27 private: | 32 private: |
| 28 void RunMain(); | 33 // Runs the main process, including the service manager. Returns the exit |
| 34 // value for the process. |
| 35 int RunMain(); |
| 36 |
| 37 // Runs a background service manager in the main process. |
| 38 void RunServiceManagerInMain(); |
| 39 |
| 40 // Called when a child service exits. The main process may decide to exit in |
| 41 // response. |
| 42 void OnInstanceQuitInMain(const service_manager::Identity& identity); |
| 29 | 43 |
| 30 // Returns 0 if the child process was initialized correctly, or error code on | 44 // Returns 0 if the child process was initialized correctly, or error code on |
| 31 // failure. | 45 // failure. |
| 32 int RunChild(); | 46 int RunChild(); |
| 33 | 47 |
| 34 void StartChildApp(service_manager::mojom::ServiceRequest service_request); | 48 void StartChildApp(service_manager::mojom::ServiceRequest service_request); |
| 35 | 49 |
| 50 // Context for service manager in the main process. |
| 36 std::unique_ptr<service_manager::ServiceContext> context_; | 51 std::unique_ptr<service_manager::ServiceContext> context_; |
| 37 | 52 |
| 53 // Run loop for the main process. |
| 54 std::unique_ptr<base::RunLoop> main_run_loop_; |
| 55 |
| 56 // Return value for the main process. |
| 57 int main_return_value_ = 0; |
| 58 |
| 38 DISALLOW_COPY_AND_ASSIGN(MashRunner); | 59 DISALLOW_COPY_AND_ASSIGN(MashRunner); |
| 39 }; | 60 }; |
| 40 | 61 |
| 41 // Called during chrome --mash startup instead of ContentMain(). | 62 // Called during chrome --mash startup instead of ContentMain(). |
| 42 int MashMain(); | 63 int MashMain(); |
| 43 | 64 |
| 44 // Called if the command line isn't mash to potentially wait for a debugger | 65 // Called if the command line isn't mash to potentially wait for a debugger |
| 45 // to attach. | 66 // to attach. |
| 46 void WaitForMashDebuggerIfNecessary(); | 67 void WaitForMashDebuggerIfNecessary(); |
| 47 | 68 |
| 48 #endif // CHROME_APP_MASH_MASH_RUNNER_H_ | 69 #endif // CHROME_APP_MASH_MASH_RUNNER_H_ |
| OLD | NEW |