| 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 MOJO_SHELL_SHELL_H_ | 5 #ifndef MOJO_SHELL_SHELL_H_ |
| 6 #define MOJO_SHELL_SHELL_H_ | 6 #define MOJO_SHELL_SHELL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.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 "mojo/services/package_manager/package_manager.h" | 16 #include "mojo/services/catalog/catalog.h" |
| 17 #include "mojo/shell/connect_params.h" | 17 #include "mojo/shell/connect_params.h" |
| 18 #include "mojo/shell/loader.h" | 18 #include "mojo/shell/loader.h" |
| 19 #include "mojo/shell/native_runner.h" | 19 #include "mojo/shell/native_runner.h" |
| 20 #include "mojo/shell/public/cpp/identity.h" | 20 #include "mojo/shell/public/cpp/identity.h" |
| 21 #include "mojo/shell/public/cpp/interface_factory.h" | 21 #include "mojo/shell/public/cpp/interface_factory.h" |
| 22 #include "mojo/shell/public/cpp/shell_client.h" | 22 #include "mojo/shell/public/cpp/shell_client.h" |
| 23 #include "mojo/shell/public/interfaces/connector.mojom.h" | 23 #include "mojo/shell/public/interfaces/connector.mojom.h" |
| 24 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" | 24 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" |
| 25 #include "mojo/shell/public/interfaces/shell.mojom.h" | 25 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| 26 #include "mojo/shell/public/interfaces/shell_client.mojom.h" | 26 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // |native_runner_factory| is an instance of an object capable of vending | 74 // |native_runner_factory| is an instance of an object capable of vending |
| 75 // implementations of NativeRunner, e.g. for in or out-of-process execution. | 75 // implementations of NativeRunner, e.g. for in or out-of-process execution. |
| 76 // See native_runner.h and RunNativeApplication(). | 76 // See native_runner.h and RunNativeApplication(). |
| 77 // |file_task_runner| provides access to a thread to perform file copy | 77 // |file_task_runner| provides access to a thread to perform file copy |
| 78 // operations on. This may be null only in testing environments where | 78 // operations on. This may be null only in testing environments where |
| 79 // applications are loaded via Loader implementations. | 79 // applications are loaded via Loader implementations. |
| 80 Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory, | 80 Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory, |
| 81 base::TaskRunner* file_task_runner, | 81 base::TaskRunner* file_task_runner, |
| 82 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog); | 82 scoped_ptr<catalog::Store> catalog_store); |
| 83 ~Shell() override; | 83 ~Shell() override; |
| 84 | 84 |
| 85 // Provide a callback to be notified whenever an instance is destroyed. | 85 // Provide a callback to be notified whenever an instance is destroyed. |
| 86 // Typically the creator of the Shell will use this to determine when some set | 86 // Typically the creator of the Shell will use this to determine when some set |
| 87 // of instances it created are destroyed, so it can shut down. | 87 // of instances it created are destroyed, so it can shut down. |
| 88 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); | 88 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); |
| 89 | 89 |
| 90 // Completes a connection between a source and target application as defined | 90 // Completes a connection between a source and target application as defined |
| 91 // by |params|, exchanging InterfaceProviders between them. If no existing | 91 // by |params|, exchanging InterfaceProviders between them. If no existing |
| 92 // instance of the target application is running, one will be loaded. | 92 // instance of the target application is running, one will be loaded. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 110 class Instance; | 110 class Instance; |
| 111 | 111 |
| 112 using IdentityToInstanceMap = std::map<Identity, Instance*>; | 112 using IdentityToInstanceMap = std::map<Identity, Instance*>; |
| 113 using NameToLoaderMap = std::map<std::string, Loader*>; | 113 using NameToLoaderMap = std::map<std::string, Loader*>; |
| 114 using IdentityToShellClientFactoryMap = | 114 using IdentityToShellClientFactoryMap = |
| 115 std::map<Identity, mojom::ShellClientFactoryPtr>; | 115 std::map<Identity, mojom::ShellClientFactoryPtr>; |
| 116 | 116 |
| 117 // ShellClient: | 117 // ShellClient: |
| 118 bool AcceptConnection(Connection* connection) override; | 118 bool AcceptConnection(Connection* connection) override; |
| 119 | 119 |
| 120 void InitPackageManager( | 120 void InitCatalog(scoped_ptr<catalog::Store> store); |
| 121 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog); | |
| 122 | 121 |
| 123 // Destroys all Shell-ends of connections established with Applications. | 122 // Destroys all Shell-ends of connections established with Applications. |
| 124 // Applications connected by this Shell will observe pipe errors and have a | 123 // Applications connected by this Shell will observe pipe errors and have a |
| 125 // chance to shutdown. | 124 // chance to shutdown. |
| 126 void TerminateShellConnections(); | 125 void TerminateShellConnections(); |
| 127 | 126 |
| 128 // Removes a Instance when it encounters an error. | 127 // Removes a Instance when it encounters an error. |
| 129 void OnInstanceError(Instance* instance); | 128 void OnInstanceError(Instance* instance); |
| 130 | 129 |
| 131 // Returns a running instance matching |identity|. | 130 // Returns a running instance matching |identity|. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 160 const Identity& shell_client_factory, | 159 const Identity& shell_client_factory, |
| 161 const std::string& name, | 160 const std::string& name, |
| 162 mojom::ShellClientRequest request); | 161 mojom::ShellClientRequest request); |
| 163 // Returns a running ShellClientFactory for |shell_client_factory_identity|, | 162 // Returns a running ShellClientFactory for |shell_client_factory_identity|, |
| 164 // if there is not one running one is started for |source_identity|. | 163 // if there is not one running one is started for |source_identity|. |
| 165 mojom::ShellClientFactory* GetShellClientFactory( | 164 mojom::ShellClientFactory* GetShellClientFactory( |
| 166 const Identity& shell_client_factory_identity, | 165 const Identity& shell_client_factory_identity, |
| 167 const Identity& source_identity); | 166 const Identity& source_identity); |
| 168 void OnShellClientFactoryLost(const Identity& which);; | 167 void OnShellClientFactoryLost(const Identity& which);; |
| 169 | 168 |
| 170 // Callback when remote PackageManager resolves mojo:foo to mojo:bar. | 169 // Callback when remote Catalog resolves mojo:foo to mojo:bar. |
| 171 // |params| are the params passed to Connect(). | 170 // |params| are the params passed to Connect(). |
| 172 // |resolved_name| is the mojo: name identifying the physical package | 171 // |resolved_name| is the mojo: name identifying the physical package |
| 173 // application. | 172 // application. |
| 174 // |file_url| is the resolved file:// URL of the physical package. | 173 // |file_url| is the resolved file:// URL of the physical package. |
| 175 // |base_filter| is the CapabilityFilter the requested application should be | 174 // |base_filter| is the CapabilityFilter the requested application should be |
| 176 // run with, from its manifest. | 175 // run with, from its manifest. |
| 177 void OnGotResolvedName(scoped_ptr<ConnectParams> params, | 176 void OnGotResolvedName(scoped_ptr<ConnectParams> params, |
| 178 const String& resolved_name, | 177 const String& resolved_name, |
| 179 const String& resolved_instance, | 178 const String& resolved_instance, |
| 180 mojom::CapabilityFilterPtr base_filter, | 179 mojom::CapabilityFilterPtr base_filter, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 217 |
| 219 DISALLOW_COPY_AND_ASSIGN(Shell); | 218 DISALLOW_COPY_AND_ASSIGN(Shell); |
| 220 }; | 219 }; |
| 221 | 220 |
| 222 mojom::Connector::ConnectCallback EmptyConnectCallback(); | 221 mojom::Connector::ConnectCallback EmptyConnectCallback(); |
| 223 | 222 |
| 224 } // namespace shell | 223 } // namespace shell |
| 225 } // namespace mojo | 224 } // namespace mojo |
| 226 | 225 |
| 227 #endif // MOJO_SHELL_SHELL_H_ | 226 #endif // MOJO_SHELL_SHELL_H_ |
| OLD | NEW |