| OLD | NEW |
| 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 <vector> | 10 #include <vector> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Removes a Instance when it encounters an error. | 95 // Removes a Instance when it encounters an error. |
| 96 void OnInstanceError(Instance* instance); | 96 void OnInstanceError(Instance* instance); |
| 97 | 97 |
| 98 // Completes a connection between a source and target application as defined | 98 // Completes a connection between a source and target application as defined |
| 99 // by |params|, exchanging InterfaceProviders between them. If no existing | 99 // by |params|, exchanging InterfaceProviders between them. If no existing |
| 100 // instance of the target application is running, one will be loaded. | 100 // instance of the target application is running, one will be loaded. |
| 101 // | 101 // |
| 102 // If |service| is not null, there must not be an instance of the target | 102 // If |service| is not null, there must not be an instance of the target |
| 103 // application already running. The Service Manager will create a new instance | 103 // application already running. The Service Manager will create a new instance |
| 104 // and use |service| to control it. | 104 // and use |service| to control it. |
| 105 // |
| 106 // If |instance| is not null, the lifetime of the connection request is |
| 107 // bounded by that of |instance|. The connection will be cancelled dropped if |
| 108 // |instance| is destroyed. |
| 105 void Connect(std::unique_ptr<ConnectParams> params, | 109 void Connect(std::unique_ptr<ConnectParams> params, |
| 106 mojom::ServicePtr service); | 110 mojom::ServicePtr service, |
| 111 base::WeakPtr<Instance> source_instance); |
| 107 | 112 |
| 108 // Returns a running instance matching |identity|. This might be an instance | 113 // Returns a running instance matching |identity|. This might be an instance |
| 109 // running as a different user if one is available that services all users. | 114 // running as a different user if one is available that services all users. |
| 110 Instance* GetExistingInstance(const Identity& identity) const; | 115 Instance* GetExistingInstance(const Identity& identity) const; |
| 111 | 116 |
| 112 void NotifyPIDAvailable(const Identity& identity, base::ProcessId pid); | 117 void NotifyPIDAvailable(const Identity& identity, base::ProcessId pid); |
| 113 | 118 |
| 114 // Attempt to complete the connection requested by |params| by connecting to | 119 // Attempt to complete the connection requested by |params| by connecting to |
| 115 // an existing instance. If there is an existing instance, |params| is taken, | 120 // an existing instance. If there is an existing instance, |params| is taken, |
| 116 // and this function returns true. | 121 // and this function returns true. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 132 const Identity& service_factory_identity); | 137 const Identity& service_factory_identity); |
| 133 void OnServiceFactoryLost(const Identity& which); | 138 void OnServiceFactoryLost(const Identity& which); |
| 134 | 139 |
| 135 // Callback when remote Catalog resolves mojo:foo to mojo:bar. | 140 // Callback when remote Catalog resolves mojo:foo to mojo:bar. |
| 136 // |params| are the params passed to Connect(). | 141 // |params| are the params passed to Connect(). |
| 137 // |service| if provided is a ServicePtr which should be used to manage the | 142 // |service| if provided is a ServicePtr which should be used to manage the |
| 138 // new application instance. This may be null. | 143 // new application instance. This may be null. |
| 139 // |result| contains the result of the resolve operation. | 144 // |result| contains the result of the resolve operation. |
| 140 void OnGotResolvedName(std::unique_ptr<ConnectParams> params, | 145 void OnGotResolvedName(std::unique_ptr<ConnectParams> params, |
| 141 mojom::ServicePtr service, | 146 mojom::ServicePtr service, |
| 147 bool has_source_instance, |
| 148 base::WeakPtr<Instance> source_instance, |
| 142 mojom::ResolveResultPtr result); | 149 mojom::ResolveResultPtr result); |
| 143 | 150 |
| 144 base::WeakPtr<ServiceManager> GetWeakPtr(); | 151 base::WeakPtr<ServiceManager> GetWeakPtr(); |
| 145 | 152 |
| 146 std::map<Identity, Instance*> identity_to_instance_; | 153 std::map<Identity, Instance*> identity_to_instance_; |
| 147 | 154 |
| 148 // Tracks the names of instances that are allowed to field connection requests | 155 // Tracks the names of instances that are allowed to field connection requests |
| 149 // from all users. | 156 // from all users. |
| 150 std::set<std::string> singletons_; | 157 std::set<std::string> singletons_; |
| 151 | 158 |
| 152 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_; | 159 std::map<Identity, mojom::ServiceFactoryPtr> service_factories_; |
| 153 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_; | 160 std::map<Identity, mojom::ResolverPtr> identity_to_resolver_; |
| 154 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_; | 161 mojo::InterfacePtrSet<mojom::ServiceManagerListener> listeners_; |
| 155 base::Callback<void(const Identity&)> instance_quit_callback_; | 162 base::Callback<void(const Identity&)> instance_quit_callback_; |
| 156 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; | 163 std::unique_ptr<NativeRunnerFactory> native_runner_factory_; |
| 157 std::unique_ptr<ServiceContext> service_context_; | 164 std::unique_ptr<ServiceContext> service_context_; |
| 158 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; | 165 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; |
| 159 | 166 |
| 160 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 167 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 161 }; | 168 }; |
| 162 | 169 |
| 163 mojom::Connector::ConnectCallback EmptyConnectCallback(); | 170 mojom::Connector::ConnectCallback EmptyConnectCallback(); |
| 164 | 171 |
| 165 } // namespace shell | 172 } // namespace shell |
| 166 | 173 |
| 167 #endif // SERVICES_SHELL_SERVICE_MANAGER_H_ | 174 #endif // SERVICES_SHELL_SERVICE_MANAGER_H_ |
| OLD | NEW |