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

Side by Side Diff: services/service_manager/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 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>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Provide a callback to be notified whenever an instance is destroyed. 65 // Provide a callback to be notified whenever an instance is destroyed.
66 // 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
67 // 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.
68 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); 68 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback);
69 69
70 // Completes a connection between a source and target application as defined 70 // Completes a connection between a source and target application as defined
71 // by |params|, exchanging InterfaceProviders between them. If no existing 71 // by |params|, exchanging InterfaceProviders between them. If no existing
72 // instance of the target application is running, one will be loaded. 72 // instance of the target application is running, one will be loaded.
73 void Connect(std::unique_ptr<ConnectParams> params); 73 void Connect(std::unique_ptr<ConnectParams> params);
74 74
75 // Creates a new Instance identified as |name|. This is intended for use by 75 // Creates a service instance for |identity|. This is intended for use by the
76 // the Service Manager's embedder to register itself. This must only be called 76 // Service Manager's embedder to register instances directly, without
77 // once. 77 // requiring a Connector.
78 mojom::ServiceRequest StartEmbedderService(const std::string& name); 78 //
79 // |pid_receiver_request| may be null, in which case the service manager
80 // assumes the new service is running in this process.
81 void RegisterService(const Identity& identity,
82 mojom::ServicePtr service,
83 mojom::PIDReceiverRequest pid_receiver_request);
79 84
80 private: 85 private:
81 class Instance; 86 class Instance;
82 class ServiceImpl; 87 class ServiceImpl;
83 88
84 void InitCatalog(mojom::ServicePtr catalog); 89 void InitCatalog(mojom::ServicePtr catalog);
85 90
86 // Returns the resolver to use for the specified identity. 91 // Returns the resolver to use for the specified identity.
87 // NOTE: Resolvers are cached to ensure we service requests in order. If 92 // NOTE: Resolvers are cached to ensure we service requests in order. If
88 // we use a separate Resolver for each request ordering is not 93 // we use a separate Resolver for each request ordering is not
89 // guaranteed and can lead to random flake. 94 // guaranteed and can lead to random flake.
90 mojom::Resolver* GetResolver(const Identity& identity); 95 mojom::Resolver* GetResolver(const Identity& identity);
91 96
92 // Called when |instance| encounters an error. Deletes |instance|. 97 // Called when |instance| encounters an error. Deletes |instance|.
93 void OnInstanceError(Instance* instance); 98 void OnInstanceError(Instance* instance);
94 99
95 // Called when |instance| becomes unreachable to new connections because it 100 // Called when |instance| becomes unreachable to new connections because it
96 // no longer has any pipes to the ServiceManager. 101 // no longer has any pipes to the ServiceManager.
97 void OnInstanceUnreachable(Instance* instance); 102 void OnInstanceUnreachable(Instance* instance);
98 103
99 // Called by an Instance as it's being destroyed. 104 // Called by an Instance as it's being destroyed.
100 void OnInstanceStopped(const Identity& identity); 105 void OnInstanceStopped(const Identity& identity);
101 106
102 // Completes a connection between a source and target application as defined 107 // Completes a connection between a source and target application as defined
103 // by |params|, exchanging InterfaceProviders between them. If no existing 108 // by |params|, exchanging InterfaceProviders between them. If no existing
104 // instance of the target application is running, one will be loaded. 109 // instance of the target application is running, one will be loaded.
105 // 110 //
106 // If |service| is not null, there must not be an instance of the target
107 // application already running. The Service Manager will create a new instance
108 // and use |service| to control it.
109 //
110 // If |instance| is not null, the lifetime of the connection request is 111 // If |instance| is not null, the lifetime of the connection request is
111 // bounded by that of |instance|. The connection will be cancelled dropped if 112 // bounded by that of |instance|. The connection will be cancelled dropped if
112 // |instance| is destroyed. 113 // |instance| is destroyed.
113 void Connect(std::unique_ptr<ConnectParams> params, 114 void Connect(std::unique_ptr<ConnectParams> params,
114 mojom::ServicePtr service,
115 base::WeakPtr<Instance> source_instance); 115 base::WeakPtr<Instance> source_instance);
116 116
117 // Returns a running instance matching |identity|. This might be an instance 117 // Returns a running instance matching |identity|. This might be an instance
118 // running as a different user if one is available that services all users. 118 // running as a different user if one is available that services all users.
119 Instance* GetExistingInstance(const Identity& identity) const; 119 Instance* GetExistingInstance(const Identity& identity) const;
120 120
121 // Erases any identities mapping to |instance|. Following this call it is 121 // Erases any identities mapping to |instance|. Following this call it is
122 // impossible for any call to GetExistingInstance() to return |instance|. 122 // impossible for any call to GetExistingInstance() to return |instance|.
123 void EraseInstanceIdentity(Instance* instance); 123 void EraseInstanceIdentity(Instance* instance);
124 124
(...skipping 20 matching lines...) Expand all
145 mojom::ServiceFactory* GetServiceFactory( 145 mojom::ServiceFactory* GetServiceFactory(
146 const Identity& service_factory_identity); 146 const Identity& service_factory_identity);
147 void OnServiceFactoryLost(const Identity& which); 147 void OnServiceFactoryLost(const Identity& which);
148 148
149 // Callback when remote Catalog resolves mojo:foo to mojo:bar. 149 // Callback when remote Catalog resolves mojo:foo to mojo:bar.
150 // |params| are the params passed to Connect(). 150 // |params| are the params passed to Connect().
151 // |service| if provided is a ServicePtr which should be used to manage the 151 // |service| if provided is a ServicePtr which should be used to manage the
152 // new application instance. This may be null. 152 // new application instance. This may be null.
153 // |result| contains the result of the resolve operation. 153 // |result| contains the result of the resolve operation.
154 void OnGotResolvedName(std::unique_ptr<ConnectParams> params, 154 void OnGotResolvedName(std::unique_ptr<ConnectParams> params,
155 mojom::ServicePtr service,
156 bool has_source_instance, 155 bool has_source_instance,
157 base::WeakPtr<Instance> source_instance, 156 base::WeakPtr<Instance> source_instance,
158 mojom::ResolveResultPtr result, 157 mojom::ResolveResultPtr result,
159 mojom::ResolveResultPtr parent); 158 mojom::ResolveResultPtr parent);
160 159
161 base::WeakPtr<ServiceManager> GetWeakPtr(); 160 base::WeakPtr<ServiceManager> GetWeakPtr();
162 161
163 std::unique_ptr<ServiceOverrides> service_overrides_; 162 std::unique_ptr<ServiceOverrides> service_overrides_;
164 163
165 // Ownership of all Instances. 164 // Ownership of all Instances.
(...skipping 22 matching lines...) Expand all
188 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; 187 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_;
189 188
190 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 189 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
191 }; 190 };
192 191
193 mojom::Connector::ConnectCallback EmptyConnectCallback(); 192 mojom::Connector::ConnectCallback EmptyConnectCallback();
194 193
195 } // namespace service_manager 194 } // namespace service_manager
196 195
197 #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