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

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

Issue 2651953002: Revert of [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>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/threading/thread.h" 12 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "services/service_manager/public/cpp/identity.h" 13 #include "services/catalog/store.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
22 namespace service_manager { 17 namespace service_manager {
23 18
24 class Context;
25 class ServiceManager; 19 class ServiceManager;
26 20
27 // BackgroundServiceManager runs a Service Manager on a dedicated background 21 // BackgroundServiceManager starts up a Service Manager on a background thread,
28 // thread. 22 // and
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.
29 class BackgroundServiceManager { 26 class BackgroundServiceManager {
30 public: 27 public:
31 BackgroundServiceManager( 28 struct InitParams {
32 service_manager::ServiceProcessLauncher::Delegate* launcher_delegate, 29 InitParams();
33 std::unique_ptr<base::Value> catalog_contents); 30 ~InitParams();
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();
34 ~BackgroundServiceManager(); 40 ~BackgroundServiceManager();
35 41
36 // Creates a service instance for |identity|. This is intended for use by the 42 // Starts the background service manager. |command_line_switches| are
37 // Service Manager's embedder to register instances directly, without 43 // additional
38 // requiring a Connector. 44 // switches applied to any processes spawned by this call.
39 // 45 void Init(std::unique_ptr<InitParams> init_params);
40 // |pid_receiver_request| may be null, in which case the service manager 46
41 // assumes the new service is running in this process. 47 // Obtains an InterfaceRequest for the specified name.
42 void RegisterService(const Identity& identity, 48 mojom::ServiceRequest CreateServiceRequest(const std::string& name);
43 mojom::ServicePtr service, 49
44 mojom::PIDReceiverRequest pid_receiver_request); 50 // Use to do processing on the thread running the Service Manager. The
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);
45 56
46 private: 57 private:
47 void InitializeOnBackgroundThread( 58 class MojoThread;
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);
55 59
56 base::Thread background_thread_; 60 std::unique_ptr<MojoThread> thread_;
57
58 // The ServiceManager context. Must only be used on the background thread.
59 std::unique_ptr<Context> context_;
60 61
61 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager); 62 DISALLOW_COPY_AND_ASSIGN(BackgroundServiceManager);
62 }; 63 };
63 64
64 } // namespace service_manager 65 } // namespace service_manager
65 66
66 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_ 67 #endif // SERVICES_SERVICE_MANAGER_BACKGROUND_BACKGROUND_SERVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « services/catalog/reader.cc ('k') | services/service_manager/background/background_service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698