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

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

Issue 2651953002: Revert of [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: Created 3 years, 11 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 service instance for |identity|. This is intended for use by the 75 // Creates a new Instance identified as |name|. This is intended for use by
76 // Service Manager's embedder to register instances directly, without 76 // the Service Manager's embedder to register itself. This must only be called
77 // requiring a Connector. 77 // once.
78 // 78 mojom::ServiceRequest StartEmbedderService(const std::string& name);
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);
84 79
85 private: 80 private:
86 class Instance; 81 class Instance;
87 class ServiceImpl; 82 class ServiceImpl;
88 83
89 void InitCatalog(mojom::ServicePtr catalog); 84 void InitCatalog(mojom::ServicePtr catalog);
90 85
91 // Returns the resolver to use for the specified identity. 86 // Returns the resolver to use for the specified identity.
92 // NOTE: Resolvers are cached to ensure we service requests in order. If 87 // NOTE: Resolvers are cached to ensure we service requests in order. If
93 // we use a separate Resolver for each request ordering is not 88 // we use a separate Resolver for each request ordering is not
94 // guaranteed and can lead to random flake. 89 // guaranteed and can lead to random flake.
95 mojom::Resolver* GetResolver(const Identity& identity); 90 mojom::Resolver* GetResolver(const Identity& identity);
96 91
97 // Called when |instance| encounters an error. Deletes |instance|. 92 // Called when |instance| encounters an error. Deletes |instance|.
98 void OnInstanceError(Instance* instance); 93 void OnInstanceError(Instance* instance);
99 94
100 // Called when |instance| becomes unreachable to new connections because it 95 // Called when |instance| becomes unreachable to new connections because it
101 // no longer has any pipes to the ServiceManager. 96 // no longer has any pipes to the ServiceManager.
102 void OnInstanceUnreachable(Instance* instance); 97 void OnInstanceUnreachable(Instance* instance);
103 98
104 // Called by an Instance as it's being destroyed. 99 // Called by an Instance as it's being destroyed.
105 void OnInstanceStopped(const Identity& identity); 100 void OnInstanceStopped(const Identity& identity);
106 101
107 // Completes a connection between a source and target application as defined 102 // Completes a connection between a source and target application as defined
108 // by |params|, exchanging InterfaceProviders between them. If no existing 103 // by |params|, exchanging InterfaceProviders between them. If no existing
109 // instance of the target application is running, one will be loaded. 104 // instance of the target application is running, one will be loaded.
110 // 105 //
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 //
111 // If |instance| is not null, the lifetime of the connection request is 110 // If |instance| is not null, the lifetime of the connection request is
112 // bounded by that of |instance|. The connection will be cancelled dropped if 111 // bounded by that of |instance|. The connection will be cancelled dropped if
113 // |instance| is destroyed. 112 // |instance| is destroyed.
114 void Connect(std::unique_ptr<ConnectParams> params, 113 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,
155 bool has_source_instance, 156 bool has_source_instance,
156 base::WeakPtr<Instance> source_instance, 157 base::WeakPtr<Instance> source_instance,
157 mojom::ResolveResultPtr result, 158 mojom::ResolveResultPtr result,
158 mojom::ResolveResultPtr parent); 159 mojom::ResolveResultPtr parent);
159 160
160 base::WeakPtr<ServiceManager> GetWeakPtr(); 161 base::WeakPtr<ServiceManager> GetWeakPtr();
161 162
162 std::unique_ptr<ServiceOverrides> service_overrides_; 163 std::unique_ptr<ServiceOverrides> service_overrides_;
163 164
164 // Ownership of all Instances. 165 // Ownership of all Instances.
(...skipping 22 matching lines...) Expand all
187 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; 188 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_;
188 189
189 DISALLOW_COPY_AND_ASSIGN(ServiceManager); 190 DISALLOW_COPY_AND_ASSIGN(ServiceManager);
190 }; 191 };
191 192
192 mojom::Connector::ConnectCallback EmptyConnectCallback(); 193 mojom::Connector::ConnectCallback EmptyConnectCallback();
193 194
194 } // namespace service_manager 195 } // namespace service_manager
195 196
196 #endif // SERVICES_SERVICE_MANAGER_SERVICE_MANAGER_H_ 197 #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