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/package_manager/package_manager.h" |
17 #include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h
" | |
18 #include "mojo/shell/connect_params.h" | 17 #include "mojo/shell/connect_params.h" |
19 #include "mojo/shell/loader.h" | 18 #include "mojo/shell/loader.h" |
20 #include "mojo/shell/native_runner.h" | 19 #include "mojo/shell/native_runner.h" |
21 #include "mojo/shell/public/cpp/identity.h" | 20 #include "mojo/shell/public/cpp/identity.h" |
22 #include "mojo/shell/public/cpp/interface_factory.h" | 21 #include "mojo/shell/public/cpp/interface_factory.h" |
23 #include "mojo/shell/public/cpp/shell_client.h" | 22 #include "mojo/shell/public/cpp/shell_client.h" |
24 #include "mojo/shell/public/interfaces/connector.mojom.h" | 23 #include "mojo/shell/public/interfaces/connector.mojom.h" |
25 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" | 24 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" |
26 #include "mojo/shell/public/interfaces/shell.mojom.h" | 25 #include "mojo/shell/public/interfaces/shell.mojom.h" |
27 #include "mojo/shell/public/interfaces/shell_client.mojom.h" | 26 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
28 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" | 27 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" |
| 28 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h" |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 class FilePath; | 31 class FilePath; |
32 class SequencedWorkerPool; | 32 class SequencedWorkerPool; |
33 } | 33 } |
34 | 34 |
35 namespace mojo { | 35 namespace mojo { |
36 class ShellConnection; | 36 class ShellConnection; |
37 namespace shell { | 37 namespace shell { |
38 | 38 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog); | 121 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog); |
122 | 122 |
123 // Destroys all Shell-ends of connections established with Applications. | 123 // Destroys all Shell-ends of connections established with Applications. |
124 // Applications connected by this Shell will observe pipe errors and have a | 124 // Applications connected by this Shell will observe pipe errors and have a |
125 // chance to shutdown. | 125 // chance to shutdown. |
126 void TerminateShellConnections(); | 126 void TerminateShellConnections(); |
127 | 127 |
128 // Removes a Instance when it encounters an error. | 128 // Removes a Instance when it encounters an error. |
129 void OnInstanceError(Instance* instance); | 129 void OnInstanceError(Instance* instance); |
130 | 130 |
| 131 // Returns a running instance matching |identity|. |
131 Instance* GetExistingInstance(const Identity& identity) const; | 132 Instance* GetExistingInstance(const Identity& identity) const; |
| 133 // Like GetExistingInstance, but if no instance for |identity.user_id()| is |
| 134 // found, looks for kRootUserID too. |
| 135 Instance* GetExistingOrRootInstance(const Identity& identity) const; |
132 | 136 |
133 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); | 137 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); |
134 | 138 |
135 // Attempt to complete the connection requested by |params| by connecting to | 139 // Attempt to complete the connection requested by |params| by connecting to |
136 // an existing instance. If there is an existing instance, |params| is taken, | 140 // an existing instance. If there is an existing instance, |params| is taken, |
137 // and this function returns true. | 141 // and this function returns true. |
138 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); | 142 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); |
139 | 143 |
140 Instance* CreateInstance(const Identity& target_id, | 144 Instance* CreateInstance(const Identity& target_id, |
141 const CapabilityFilter& filter, | 145 const CapabilityFilter& filter, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // and it was loaded, in which case |request| is taken. | 184 // and it was loaded, in which case |request| is taken. |
181 bool LoadWithLoader(const Identity& target, | 185 bool LoadWithLoader(const Identity& target, |
182 mojom::ShellClientRequest* request); | 186 mojom::ShellClientRequest* request); |
183 | 187 |
184 // Returns the appropriate loader for |name|, or the default loader if there | 188 // Returns the appropriate loader for |name|, or the default loader if there |
185 // is no loader configured for the name. | 189 // is no loader configured for the name. |
186 Loader* GetLoaderForName(const std::string& name); | 190 Loader* GetLoaderForName(const std::string& name); |
187 | 191 |
188 void CleanupRunner(NativeRunner* runner); | 192 void CleanupRunner(NativeRunner* runner); |
189 | 193 |
190 package_manager::mojom::ShellResolverPtr shell_resolver_; | 194 mojom::ShellResolverPtr shell_resolver_; |
191 | 195 |
192 // Loader management. | 196 // Loader management. |
193 // Loaders are chosen in the order they are listed here. | 197 // Loaders are chosen in the order they are listed here. |
194 NameToLoaderMap name_to_loader_; | 198 NameToLoaderMap name_to_loader_; |
195 scoped_ptr<Loader> default_loader_; | 199 scoped_ptr<Loader> default_loader_; |
196 | 200 |
197 IdentityToInstanceMap identity_to_instance_; | 201 IdentityToInstanceMap identity_to_instance_; |
198 | 202 |
199 IdentityToShellClientFactoryMap shell_client_factories_; | 203 IdentityToShellClientFactoryMap shell_client_factories_; |
200 // Counter used to assign ids to content handlers. | 204 // Counter used to assign ids to content handlers. |
(...skipping 13 matching lines...) Expand all Loading... |
214 | 218 |
215 DISALLOW_COPY_AND_ASSIGN(Shell); | 219 DISALLOW_COPY_AND_ASSIGN(Shell); |
216 }; | 220 }; |
217 | 221 |
218 mojom::Connector::ConnectCallback EmptyConnectCallback(); | 222 mojom::Connector::ConnectCallback EmptyConnectCallback(); |
219 | 223 |
220 } // namespace shell | 224 } // namespace shell |
221 } // namespace mojo | 225 } // namespace mojo |
222 | 226 |
223 #endif // MOJO_SHELL_SHELL_H_ | 227 #endif // MOJO_SHELL_SHELL_H_ |
OLD | NEW |