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

Side by Side Diff: services/service_manager/background/background_service_manager.h

Issue 2646033002: mash: Exit the root process if the window manager service crashes (Closed)
Patch Set: review comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_
6 #define SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_ 6 #define SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
12 #include "services/service_manager/public/cpp/identity.h" 13 #include "services/service_manager/public/cpp/identity.h"
13 #include "services/service_manager/public/interfaces/connector.mojom.h" 14 #include "services/service_manager/public/interfaces/connector.mojom.h"
14 #include "services/service_manager/public/interfaces/service.mojom.h" 15 #include "services/service_manager/public/interfaces/service.mojom.h"
15 #include "services/service_manager/runner/host/service_process_launcher.h" 16 #include "services/service_manager/runner/host/service_process_launcher.h"
16 17
17 namespace base { 18 namespace base {
19 class SingleThreadTaskRunner;
18 class Value; 20 class Value;
19 class WaitableEvent; 21 class WaitableEvent;
20 } 22 }
21 23
22 namespace service_manager { 24 namespace service_manager {
23 25
24 class Context; 26 class Context;
27 class Identity;
25 class ServiceManager; 28 class ServiceManager;
26 29
27 // BackgroundServiceManager runs a Service Manager on a dedicated background 30 // BackgroundServiceManager runs a Service Manager on a dedicated background
28 // thread. 31 // thread.
29 class BackgroundServiceManager { 32 class BackgroundServiceManager {
30 public: 33 public:
31 BackgroundServiceManager( 34 BackgroundServiceManager(
32 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate, 35 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
33 std::unique_ptr<base::Value> catalog_contents); 36 std::unique_ptr<base::Value> catalog_contents);
34 ~BackgroundServiceManager(); 37 ~BackgroundServiceManager();
35 38
36 // Creates a service instance for |identity|. This is intended for use by the 39 // Creates a service instance for |identity|. This is intended for use by the
37 // Service Manager's embedder to register instances directly, without 40 // Service Manager's embedder to register instances directly, without
38 // requiring a Connector. 41 // requiring a Connector.
39 // 42 //
40 // |pid_receiver_request| may be null, in which case the service manager 43 // |pid_receiver_request| may be null, in which case the service manager
41 // assumes the new service is running in this process. 44 // assumes the new service is running in this process.
42 void RegisterService(const Identity& identity, 45 void RegisterService(const Identity& identity,
43 mojom::ServicePtr service, 46 mojom::ServicePtr service,
44 mojom::PIDReceiverRequest pid_receiver_request); 47 mojom::PIDReceiverRequest pid_receiver_request);
45 48
49 // Provide a callback to be notified whenever a service is destroyed.
50 // Typically the creator of BackgroundServiceManager will use this to shut
51 // down when some set of services it created is destroyed. The |callback| is
52 // called on whichever thread called this function.
53 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback);
54
46 private: 55 private:
47 void InitializeOnBackgroundThread( 56 void InitializeOnBackgroundThread(
48 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate, 57 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
49 std::unique_ptr<base::Value> catalog_contents); 58 std::unique_ptr<base::Value> catalog_contents);
50 void ShutDownOnBackgroundThread(base::WaitableEvent* done_event); 59 void ShutDownOnBackgroundThread(base::WaitableEvent* done_event);
51 void RegisterServiceOnBackgroundThread( 60 void RegisterServiceOnBackgroundThread(
52 const Identity& identity, 61 const Identity& identity,
53 mojom::ServicePtrInfo service_info, 62 mojom::ServicePtrInfo service_info,
54 mojom::PIDReceiverRequest pid_receiver_request); 63 mojom::PIDReceiverRequest pid_receiver_request);
64 void SetInstanceQuitCallbackOnBackgroundThread(
65 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
66 const base::Callback<void(const Identity&)>& callback);
67 void OnInstanceQuitOnBackgroundThread(const Identity& identity);
55 68
56 base::Thread background_thread_; 69 base::Thread background_thread_;
57 70
58 // The ServiceManager context. Must only be used on the background thread. 71 // The ServiceManager context. Must only be used on the background thread.
59 std::unique_ptr<Context> context_; 72 std::unique_ptr<Context> context_;
60 73
61 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager); 74 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager);
62 }; 75 };
63 76
64 } // namespace service_manager 77 } // namespace service_manager
65 78
66 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_ 79 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698