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_APPLICATION_MANAGER_H_ | 5 #ifndef MOJO_SHELL_APPLICATION_MANAGER_H_ |
6 #define MOJO_SHELL_APPLICATION_MANAGER_H_ | 6 #define MOJO_SHELL_APPLICATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // |task_runner| provides access to a thread to perform file copy operations | 64 // |task_runner| provides access to a thread to perform file copy operations |
65 // on. This may be null only in testing environments where applications are | 65 // on. This may be null only in testing environments where applications are |
66 // loaded via ApplicationLoader implementations. | 66 // loaded via ApplicationLoader implementations. |
67 // When |register_mojo_url_schemes| is true, mojo: and exe: URL schems are | 67 // When |register_mojo_url_schemes| is true, mojo: and exe: URL schems are |
68 // registered as "standard" which faciliates resolving. | 68 // registered as "standard" which faciliates resolving. |
69 ApplicationManager(scoped_ptr<NativeRunnerFactory> native_runner_factory, | 69 ApplicationManager(scoped_ptr<NativeRunnerFactory> native_runner_factory, |
70 base::TaskRunner* task_runner, | 70 base::TaskRunner* task_runner, |
71 bool register_mojo_url_schemes); | 71 bool register_mojo_url_schemes); |
72 ~ApplicationManager() override; | 72 ~ApplicationManager() override; |
73 | 73 |
| 74 // Provide a callback to be notified whenever an instance is destroyed. |
| 75 // Typically the creator of the ApplicationManager will use this to determine |
| 76 // when some set of instances it created are destroyed, so it can shut down. |
| 77 void SetInstanceQuitCallback(base::Callback<void(const Identity&)> callback); |
| 78 |
74 // Completes a connection between a source and target application as defined | 79 // Completes a connection between a source and target application as defined |
75 // by |params|, exchanging InterfaceProviders between them. If no existing | 80 // by |params|, exchanging InterfaceProviders between them. If no existing |
76 // instance of the target application is running, one will be loaded. | 81 // instance of the target application is running, one will be loaded. |
77 void Connect(scoped_ptr<ConnectParams> params); | 82 void Connect(scoped_ptr<ConnectParams> params); |
78 | 83 |
79 // Sets the default Loader to be used if not overridden by SetLoaderForURL(). | 84 // Sets the default Loader to be used if not overridden by SetLoaderForURL(). |
80 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { | 85 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { |
81 default_loader_ = std::move(loader); | 86 default_loader_ = std::move(loader); |
82 } | 87 } |
83 | 88 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 123 |
119 void InitPackageManager(bool register_mojo_url_schemes); | 124 void InitPackageManager(bool register_mojo_url_schemes); |
120 | 125 |
121 // Attempt to complete the connection requested by |params| by connecting to | 126 // Attempt to complete the connection requested by |params| by connecting to |
122 // an existing instance. If there is an existing instance, |params| is taken, | 127 // an existing instance. If there is an existing instance, |params| is taken, |
123 // and this function returns true. | 128 // and this function returns true. |
124 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); | 129 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); |
125 | 130 |
126 ApplicationInstance* CreateInstance( | 131 ApplicationInstance* CreateInstance( |
127 const Identity& target_id, | 132 const Identity& target_id, |
128 const base::Closure& on_application_end, | |
129 const String& application_name, | 133 const String& application_name, |
130 mojom::ShellClientRequest* request); | 134 mojom::ShellClientRequest* request); |
131 | 135 |
132 void CreateShellClient(const Identity& source, | 136 void CreateShellClient(const Identity& source, |
133 const Identity& shell_client_factory, | 137 const Identity& shell_client_factory, |
134 const GURL& url, | 138 const GURL& url, |
135 mojom::ShellClientRequest request); | 139 mojom::ShellClientRequest request); |
136 // Returns a running ShellClientFactory for |shell_client_factory_identity|, | 140 // Returns a running ShellClientFactory for |shell_client_factory_identity|, |
137 // if there is not one running one is started for |source_identity|. | 141 // if there is not one running one is started for |source_identity|. |
138 mojom::ShellClientFactory* GetShellClientFactory( | 142 mojom::ShellClientFactory* GetShellClientFactory( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 scoped_ptr<ApplicationLoader> default_loader_; | 182 scoped_ptr<ApplicationLoader> default_loader_; |
179 | 183 |
180 IdentityToInstanceMap identity_to_instance_; | 184 IdentityToInstanceMap identity_to_instance_; |
181 | 185 |
182 IdentityToShellClientFactoryMap shell_client_factories_; | 186 IdentityToShellClientFactoryMap shell_client_factories_; |
183 // Counter used to assign ids to content handlers. | 187 // Counter used to assign ids to content handlers. |
184 uint32_t shell_client_factory_id_counter_; | 188 uint32_t shell_client_factory_id_counter_; |
185 | 189 |
186 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; | 190 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; |
187 | 191 |
| 192 base::Callback<void(const Identity&)> instance_quit_callback_; |
188 base::TaskRunner* task_runner_; | 193 base::TaskRunner* task_runner_; |
189 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 194 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
190 std::vector<scoped_ptr<NativeRunner>> native_runners_; | 195 std::vector<scoped_ptr<NativeRunner>> native_runners_; |
191 WeakBindingSet<mojom::ApplicationManager> bindings_; | 196 WeakBindingSet<mojom::ApplicationManager> bindings_; |
192 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 197 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
193 | 198 |
194 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 199 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
195 }; | 200 }; |
196 | 201 |
197 mojom::Shell::ConnectCallback EmptyConnectCallback(); | 202 mojom::Shell::ConnectCallback EmptyConnectCallback(); |
198 | 203 |
199 } // namespace shell | 204 } // namespace shell |
200 } // namespace mojo | 205 } // namespace mojo |
201 | 206 |
202 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ | 207 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ |
OLD | NEW |