| 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 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void set_default_loader(scoped_ptr<Loader> loader) { | 80 void set_default_loader(scoped_ptr<Loader> loader) { |
| 81 default_loader_ = std::move(loader); | 81 default_loader_ = std::move(loader); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Sets a Loader to be used for a specific name. | 84 // Sets a Loader to be used for a specific name. |
| 85 void SetLoaderForName(scoped_ptr<Loader> loader, const std::string& name); | 85 void SetLoaderForName(scoped_ptr<Loader> loader, const std::string& name); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 class Instance; | 88 class Instance; |
| 89 | 89 |
| 90 using IdentityToInstanceMap = std::map<Identity, Instance*>; | |
| 91 using NameToLoaderMap = std::map<std::string, Loader*>; | |
| 92 using IdentityToShellClientFactoryMap = | |
| 93 std::map<Identity, mojom::ShellClientFactoryPtr>; | |
| 94 | |
| 95 // ShellClient: | 90 // ShellClient: |
| 96 bool AcceptConnection(Connection* connection) override; | 91 bool AcceptConnection(Connection* connection) override; |
| 97 | 92 |
| 98 void InitCatalog(mojom::ShellClientPtr catalog); | 93 void InitCatalog(mojom::ShellClientPtr catalog); |
| 99 | 94 |
| 100 // Destroys all Shell-ends of connections established with Applications. | 95 // Destroys all Shell-ends of connections established with Applications. |
| 101 // Applications connected by this Shell will observe pipe errors and have a | 96 // Applications connected by this Shell will observe pipe errors and have a |
| 102 // chance to shutdown. | 97 // chance to shutdown. |
| 103 void TerminateShellConnections(); | 98 void TerminateShellConnections(); |
| 104 | 99 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 118 // running as a different user if one is available that services all users. | 113 // running as a different user if one is available that services all users. |
| 119 Instance* GetExistingInstance(const Identity& identity) const; | 114 Instance* GetExistingInstance(const Identity& identity) const; |
| 120 | 115 |
| 121 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); | 116 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); |
| 122 | 117 |
| 123 // Attempt to complete the connection requested by |params| by connecting to | 118 // Attempt to complete the connection requested by |params| by connecting to |
| 124 // an existing instance. If there is an existing instance, |params| is taken, | 119 // an existing instance. If there is an existing instance, |params| is taken, |
| 125 // and this function returns true. | 120 // and this function returns true. |
| 126 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); | 121 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); |
| 127 | 122 |
| 128 Instance* CreateInstance(const Identity& target, | 123 Instance* CreateInstance(const Identity& source, |
| 124 const Identity& target, |
| 129 const CapabilitySpec& spec); | 125 const CapabilitySpec& spec); |
| 130 | 126 |
| 131 // Called from the instance implementing mojom::Shell. | 127 // Called from the instance implementing mojom::Shell. |
| 132 void AddInstanceListener(mojom::InstanceListenerPtr listener); | 128 void AddInstanceListener(mojom::InstanceListenerPtr listener); |
| 133 | 129 |
| 134 void CreateShellClientWithFactory(const Identity& source, | 130 void CreateShellClientWithFactory(const Identity& source, |
| 135 const Identity& shell_client_factory, | 131 const Identity& shell_client_factory, |
| 136 const std::string& name, | 132 const std::string& name, |
| 137 mojom::ShellClientRequest request); | 133 mojom::ShellClientRequest request); |
| 138 // Returns a running ShellClientFactory for |shell_client_factory_identity|. | 134 // Returns a running ShellClientFactory for |shell_client_factory_identity|. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 165 mojom::ShellClientRequest* request); | 161 mojom::ShellClientRequest* request); |
| 166 | 162 |
| 167 // Returns the appropriate loader for |name|, or the default loader if there | 163 // Returns the appropriate loader for |name|, or the default loader if there |
| 168 // is no loader configured for the name. | 164 // is no loader configured for the name. |
| 169 Loader* GetLoaderForName(const std::string& name); | 165 Loader* GetLoaderForName(const std::string& name); |
| 170 | 166 |
| 171 void CleanupRunner(NativeRunner* runner); | 167 void CleanupRunner(NativeRunner* runner); |
| 172 | 168 |
| 173 // Loader management. | 169 // Loader management. |
| 174 // Loaders are chosen in the order they are listed here. | 170 // Loaders are chosen in the order they are listed here. |
| 175 NameToLoaderMap name_to_loader_; | 171 std::map<std::string, Loader*> name_to_loader_; |
| 176 scoped_ptr<Loader> default_loader_; | 172 scoped_ptr<Loader> default_loader_; |
| 177 | 173 |
| 178 IdentityToInstanceMap identity_to_instance_; | 174 std::map<Identity, Instance*> identity_to_instance_; |
| 179 | 175 |
| 180 // Tracks the names of instances that are allowed to field connection requests | 176 // Tracks the names of instances that are allowed to field connection requests |
| 181 // from all users. | 177 // from all users. |
| 182 std::set<std::string> singletons_; | 178 std::set<std::string> singletons_; |
| 183 | 179 |
| 184 IdentityToShellClientFactoryMap shell_client_factories_; | 180 std::map<Identity, mojom::ShellClientFactoryPtr> shell_client_factories_; |
| 185 // Counter used to assign ids to client factories. | 181 // Counter used to assign ids to client factories. |
| 186 uint32_t shell_client_factory_id_counter_; | 182 uint32_t shell_client_factory_id_counter_; |
| 187 | 183 |
| 188 InterfacePtrSet<mojom::InstanceListener> instance_listeners_; | 184 InterfacePtrSet<mojom::InstanceListener> instance_listeners_; |
| 189 | 185 |
| 190 base::Callback<void(const Identity&)> instance_quit_callback_; | 186 base::Callback<void(const Identity&)> instance_quit_callback_; |
| 191 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 187 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
| 192 std::vector<scoped_ptr<NativeRunner>> native_runners_; | 188 std::vector<scoped_ptr<NativeRunner>> native_runners_; |
| 193 scoped_ptr<ShellConnection> shell_connection_; | 189 scoped_ptr<ShellConnection> shell_connection_; |
| 194 base::WeakPtrFactory<Shell> weak_ptr_factory_; | 190 base::WeakPtrFactory<Shell> weak_ptr_factory_; |
| 195 | 191 |
| 196 DISALLOW_COPY_AND_ASSIGN(Shell); | 192 DISALLOW_COPY_AND_ASSIGN(Shell); |
| 197 }; | 193 }; |
| 198 | 194 |
| 199 mojom::Connector::ConnectCallback EmptyConnectCallback(); | 195 mojom::Connector::ConnectCallback EmptyConnectCallback(); |
| 200 | 196 |
| 201 } // namespace shell | 197 } // namespace shell |
| 202 } // namespace mojo | 198 } // namespace mojo |
| 203 | 199 |
| 204 #endif // MOJO_SHELL_SHELL_H_ | 200 #endif // MOJO_SHELL_SHELL_H_ |
| OLD | NEW |