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

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

Issue 2576233002: Consolidating the mojo NativeRunner functionality. (Closed)
Patch Set: Merged mojo_runner_host_unittests in service_manager_unittests Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERVICE_MANAGER_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_
6 #define SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_ 6 #define SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/public/cpp/bindings/binding_set.h" 14 #include "mojo/public/cpp/bindings/binding_set.h"
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
16 #include "services/service_manager/connect_params.h" 16 #include "services/service_manager/connect_params.h"
17 #include "services/service_manager/native_runner.h"
18 #include "services/service_manager/public/cpp/identity.h" 17 #include "services/service_manager/public/cpp/identity.h"
19 #include "services/service_manager/public/cpp/interface_factory.h" 18 #include "services/service_manager/public/cpp/interface_factory.h"
20 #include "services/service_manager/public/cpp/interface_provider_spec.h" 19 #include "services/service_manager/public/cpp/interface_provider_spec.h"
21 #include "services/service_manager/public/interfaces/connector.mojom.h" 20 #include "services/service_manager/public/interfaces/connector.mojom.h"
22 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" 21 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
23 #include "services/service_manager/public/interfaces/resolver.mojom.h" 22 #include "services/service_manager/public/interfaces/resolver.mojom.h"
24 #include "services/service_manager/public/interfaces/service.mojom.h" 23 #include "services/service_manager/public/interfaces/service.mojom.h"
25 #include "services/service_manager/public/interfaces/service_factory.mojom.h" 24 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
26 #include "services/service_manager/public/interfaces/service_manager.mojom.h" 25 #include "services/service_manager/public/interfaces/service_manager.mojom.h"
26 #include "services/service_manager/runner/host/service_process_launcher.h"
27 #include "services/service_manager/service_overrides.h" 27 #include "services/service_manager/service_overrides.h"
28 28
29 namespace service_manager { 29 namespace service_manager {
30 30
31 class ServiceContext; 31 class ServiceContext;
32 32
33 // Creates an identity for the Service Manager, used when the Service Manager 33 // Creates an identity for the Service Manager, used when the Service Manager
34 // connects to services. 34 // connects to services.
35 Identity CreateServiceManagerIdentity(); 35 Identity CreateServiceManagerIdentity();
36 36
37 class ServiceManager { 37 class ServiceManager {
38 public: 38 public:
39 // API for testing. 39 // API for testing.
40 class TestAPI { 40 class TestAPI {
41 public: 41 public:
42 explicit TestAPI(ServiceManager* service_manager); 42 explicit TestAPI(ServiceManager* service_manager);
43 ~TestAPI(); 43 ~TestAPI();
44 44
45 // Returns true if there is a Instance for this name. 45 // Returns true if there is a Instance for this name.
46 bool HasRunningInstanceForName(const std::string& name) const; 46 bool HasRunningInstanceForName(const std::string& name) const;
47 private: 47 private:
48 ServiceManager* service_manager_; 48 ServiceManager* service_manager_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(TestAPI); 50 DISALLOW_COPY_AND_ASSIGN(TestAPI);
51 }; 51 };
52 52
53 // |native_runner_factory| is an instance of an object capable of vending 53 // |service_process_launcher_factory| is an instance of an object capable of
54 // implementations of NativeRunner, e.g. for in or out-of-process execution. 54 // vending implementations of ServiceProcessLauncher, e.g. for out-of-process
55 // See native_runner.h and RunNativeApplication(). 55 // execution.
56 // |file_task_runner| provides access to a thread to perform file copy 56 ServiceManager(std::unique_ptr<ServiceProcessLauncherFactory>
57 // operations on. 57 service_process_launcher_factory,
58 ServiceManager(std::unique_ptr<NativeRunnerFactory> native_runner_factory,
59 mojom::ServicePtr catalog); 58 mojom::ServicePtr catalog);
60 ~ServiceManager(); 59 ~ServiceManager();
61 60
62 // Sets overrides for service executable and package resolution. Must be 61 // Sets overrides for service executable and package resolution. Must be
63 // called before any services are launched. 62 // called before any services are launched.
64 void SetServiceOverrides(std::unique_ptr<ServiceOverrides> overrides); 63 void SetServiceOverrides(std::unique_ptr<ServiceOverrides> overrides);
65 64
66 // Provide a callback to be notified whenever an instance is destroyed. 65 // Provide a callback to be notified whenever an instance is destroyed.
67 // Typically the creator of the Service Manager will use this to determine 66 // Typically the creator of the Service Manager will use this to determine
68 // when some set of services it created are destroyed, so it can shut down. 67 // when some set of services it created are destroyed, so it can shut down.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 Instance* service_manager_instance_; 174 Instance* service_manager_instance_;
176 175
177 // Tracks the names of instances that are allowed to field connection requests 176 // Tracks the names of instances that are allowed to field connection requests
178 // from all users. 177 // from all users.
179 std::set<std::string> singletons_; 178 std::set<std::string> singletons_;
180 179
181 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_; 180 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_;
182 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_; 181 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_;
183 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_; 182 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_;
184 base::Callback<void(const Identity&)> instance_quit_callback_; 183 base::Callback<void(const Identity&)> instance_quit_callback_;
185 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; 184 std::unique_ptr<ServiceProcessLauncherFactory>
185 service_process_launcher_factory_;
186 std::unique_ptr<ServiceContext> service_context_; 186 std::unique_ptr<ServiceContext> service_context_;
187 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; 187 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_;
188 188
189 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 189 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
190 }; 190 };
191 191
192 mojom::Connector::ConnectCallback EmptyConnectCallback(); 192 mojom::Connector::ConnectCallback EmptyConnectCallback();
193 193
194 } // namespace service_manager 194 } // namespace service_manager
195 195
196 #endif // SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_ 196 #endif // SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « services/service_manager/runner/host/service_process_launcher_unittest.cc ('k') | services/service_manager/service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698