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

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

Issue 2645973006: [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: . 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 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "base/threading/thread.h"
13 #include "services/catalog/store.h" 12 #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/service.mojom.h" 14 #include "services/service_manager/public/interfaces/service.mojom.h"
15 #include "services/service_manager/runner/host/service_process_launcher.h" 15 #include "services/service_manager/runner/host/service_process_launcher.h"
16 16
17 namespace base {
18 class Value;
19 class WaitableEvent;
20 }
21
17 namespace service_manager { 22 namespace service_manager {
18 23
24 class Context;
19 class ServiceManager; 25 class ServiceManager;
20 26
21 // BackgroundServiceManager starts up a Service Manager on a background thread, 27 // BackgroundServiceManager runs a Service Manager on a dedicated background
22 // and 28 // thread.
23 // destroys the thread in the destructor. Once created use CreateApplication()
24 // to obtain an InterfaceRequest for the Application. The InterfaceRequest can
25 // then be bound to an ApplicationImpl.
26 class BackgroundServiceManager { 29 class BackgroundServiceManager {
27 public: 30 public:
28 struct InitParams { 31 BackgroundServiceManager(
29 InitParams(); 32 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
30 ~InitParams(); 33 std::unique_ptr<base::Value> catalog_contents);
31
32 ServiceProcessLauncher::Delegate*
33 service_process_launcher_delegate = nullptr;
34
35 // If true the edk is initialized.
36 bool init_edk = true;
37 };
38
39 BackgroundServiceManager();
40 ~BackgroundServiceManager(); 34 ~BackgroundServiceManager();
41 35
42 // Starts the background service manager. |command_line_switches| are 36 // Creates a service instance for |identity|. This is intended for use by the
43 // additional 37 // Service Manager's embedder to register instances directly, without
44 // switches applied to any processes spawned by this call. 38 // requiring a Connector.
45 void Init(std::unique_ptr<InitParams> init_params); 39 //
46 40 // |pid_receiver_request| may be null, in which case the service manager
47 // Obtains an InterfaceRequest for the specified name. 41 // assumes the new service is running in this process.
48 mojom::ServiceRequest CreateServiceRequest(const std::string& name); 42 void RegisterService(const Identity& identity,
49 43 mojom::ServicePtr service,
50 // Use to do processing on the thread running the Service Manager. The 44 mojom::PIDReceiverRequest pid_receiver_request);
51 // callback is supplied a pointer to the Service Manager. The callback does
52 // *not* own the Service Manager.
53 using ServiceManagerThreadCallback = base::Callback<void(ServiceManager*)>;
54 void ExecuteOnServiceManagerThread(
55 const ServiceManagerThreadCallback& callback);
56 45
57 private: 46 private:
58 class MojoThread; 47 void InitializeOnBackgroundThread(
48 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
49 std::unique_ptr<base::Value> catalog_contents);
50 void ShutDownOnBackgroundThread(base::WaitableEvent* done_event);
51 void RegisterServiceOnBackgroundThread(
52 const Identity& identity,
53 mojom::ServicePtrInfo service_info,
54 mojom::PIDReceiverRequest pid_receiver_request);
59 55
60 std::unique_ptr<MojoThread> thread_; 56 base::Thread background_thread_;
57
58 // The ServiceManager context. Must only be used on the background thread.
59 std::unique_ptr<Context> context_;
61 60
62 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager); 61 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager);
63 }; 62 };
64 63
65 } // namespace service_manager 64 } // namespace service_manager
66 65
67 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_ 66 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « services/service_manager/BUILD.gn ('k') | services/service_manager/background/background_service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698