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

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

Issue 2389133008: Mash: Replaces "exe:chrome" with "service:content_browser" (Closed)
Patch Set: Created 4 years, 2 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 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_SHELL_SERVICE_MANAGER_H_ 5 #ifndef SERVICES_SHELL_SERVICE_MANAGER_H_
6 #define SERVICES_SHELL_SERVICE_MANAGER_H_ 6 #define SERVICES_SHELL_SERVICE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
13 #include "base/files/file_path.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "mojo/public/cpp/bindings/binding_set.h" 16 #include "mojo/public/cpp/bindings/binding_set.h"
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 17 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
16 #include "services/shell/connect_params.h" 18 #include "services/shell/connect_params.h"
17 #include "services/shell/native_runner.h" 19 #include "services/shell/native_runner.h"
18 #include "services/shell/public/cpp/capabilities.h" 20 #include "services/shell/public/cpp/capabilities.h"
19 #include "services/shell/public/cpp/identity.h" 21 #include "services/shell/public/cpp/identity.h"
20 #include "services/shell/public/cpp/interface_factory.h" 22 #include "services/shell/public/cpp/interface_factory.h"
21 #include "services/shell/public/cpp/service.h" 23 #include "services/shell/public/cpp/service.h"
22 #include "services/shell/public/interfaces/connector.mojom.h" 24 #include "services/shell/public/interfaces/connector.mojom.h"
23 #include "services/shell/public/interfaces/interface_provider.mojom.h" 25 #include "services/shell/public/interfaces/interface_provider.mojom.h"
24 #include "services/shell/public/interfaces/resolver.mojom.h" 26 #include "services/shell/public/interfaces/resolver.mojom.h"
25 #include "services/shell/public/interfaces/service.mojom.h" 27 #include "services/shell/public/interfaces/service.mojom.h"
26 #include "services/shell/public/interfaces/service_factory.mojom.h" 28 #include "services/shell/public/interfaces/service_factory.mojom.h"
27 #include "services/shell/public/interfaces/service_manager.mojom.h" 29 #include "services/shell/public/interfaces/service_manager.mojom.h"
28 30
29 namespace shell { 31 namespace shell {
30 class ServiceContext; 32 class ServiceContext;
31 33
32 // Creates an identity for the Service Manager, used when the Service Manager 34 // Creates an identity for the Service Manager, used when the Service Manager
33 // connects to services. 35 // connects to services.
34 Identity CreateServiceManagerIdentity(); 36 Identity CreateServiceManagerIdentity();
35 37
36 class ServiceManager : public Service { 38 class ServiceManager : public Service,
39 public InterfaceFactory<mojom::ServiceManagerControl>,
40 public mojom::ServiceManagerControl {
37 public: 41 public:
38 // API for testing. 42 // API for testing.
39 class TestAPI { 43 class TestAPI {
40 public: 44 public:
41 explicit TestAPI(ServiceManager* service_manager); 45 explicit TestAPI(ServiceManager* service_manager);
42 ~TestAPI(); 46 ~TestAPI();
43 47
44 // Returns true if there is a Instance for this name. 48 // Returns true if there is a Instance for this name.
45 bool HasRunningInstanceForName(const std::string& name) const; 49 bool HasRunningInstanceForName(const std::string& name) const;
46 private: 50 private:
(...skipping 26 matching lines...) Expand all
73 // once. 77 // once.
74 mojom::ServiceRequest StartEmbedderService(const std::string& name); 78 mojom::ServiceRequest StartEmbedderService(const std::string& name);
75 79
76 private: 80 private:
77 class Instance; 81 class Instance;
78 82
79 // Service: 83 // Service:
80 bool OnConnect(const Identity& remote_identity, 84 bool OnConnect(const Identity& remote_identity,
81 InterfaceRegistry* registry) override; 85 InterfaceRegistry* registry) override;
82 86
87 // InterfaceFactory<mojom::ServiceManagerControl>:
88 void Create(const Identity& remote_identity,
89 mojom::ServiceManagerControlRequest request) override;
90
91 // mojom::ServiceManagerControl:
92 void OverridePackagePath(
93 const std::string& service_name,
94 const base::FilePath& path,
95 const OverridePackagePathCallback& callback) override;
96
83 void InitCatalog(mojom::ServicePtr catalog); 97 void InitCatalog(mojom::ServicePtr catalog);
84 98
85 // Returns the resolver to use for the specified identity. 99 // Returns the resolver to use for the specified identity.
86 // NOTE: Resolvers are cached to ensure we service requests in order. If 100 // NOTE: Resolvers are cached to ensure we service requests in order. If
87 // we use a separate Resolver for each request ordering is not 101 // we use a separate Resolver for each request ordering is not
88 // guaranteed and can lead to random flake. 102 // guaranteed and can lead to random flake.
89 mojom::Resolver* GetResolver(const Identity& identity); 103 mojom::Resolver* GetResolver(const Identity& identity);
90 104
91 // Called when |instance| encounters an error. Deletes |instance|. 105 // Called when |instance| encounters an error. Deletes |instance|.
92 void OnInstanceError(Instance* instance); 106 void OnInstanceError(Instance* instance);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Tracks the names of instances that are allowed to field connection requests 183 // Tracks the names of instances that are allowed to field connection requests
170 // from all users. 184 // from all users.
171 std::set<std::string> singletons_; 185 std::set<std::string> singletons_;
172 186
173 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_; 187 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_;
174 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_; 188 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_;
175 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_; 189 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_;
176 base::Callback<void(const Identity&)> instance_quit_callback_; 190 base::Callback<void(const Identity&)> instance_quit_callback_;
177 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; 191 std::unique_ptr<NativeRunnerFactory> native_runner_factory_;
178 std::unique_ptr<ServiceContext> service_context_; 192 std::unique_ptr<ServiceContext> service_context_;
193 mojo::BindingSet<mojom::ServiceManagerControl> control_bindings_;
194 std::map<std::string, base::FilePath> package_path_overrides_;
179 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; 195 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_;
180 196
181 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 197 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
182 }; 198 };
183 199
184 mojom::Connector::ConnectCallback EmptyConnectCallback(); 200 mojom::Connector::ConnectCallback EmptyConnectCallback();
185 201
186 } // namespace shell 202 } // namespace shell
187 203
188 #endif // SERVICES_SHELL_SERVICE_MANAGER_H_ 204 #endif // SERVICES_SHELL_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698