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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class FilePath; | 28 class FilePath; |
29 class SequencedWorkerPool; | 29 class SequencedWorkerPool; |
30 } | 30 } |
31 | 31 |
32 namespace mojo { | 32 namespace mojo { |
33 namespace shell { | 33 namespace shell { |
34 | 34 |
35 class ApplicationInstance; | 35 class ApplicationInstance; |
36 class ContentHandlerConnection; | 36 class ShellClientFactoryConnection; |
37 | 37 |
38 class ApplicationManager { | 38 class ApplicationManager { |
39 public: | 39 public: |
40 // API for testing. | 40 // API for testing. |
41 class TestAPI { | 41 class TestAPI { |
42 public: | 42 public: |
43 explicit TestAPI(ApplicationManager* manager); | 43 explicit TestAPI(ApplicationManager* manager); |
44 ~TestAPI(); | 44 ~TestAPI(); |
45 | 45 |
46 // Returns true if the shared instance has been created. | 46 // Returns true if the shared instance has been created. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const GURL& url, | 96 const GURL& url, |
97 mojom::CapabilityFilterPtr filter, | 97 mojom::CapabilityFilterPtr filter, |
98 InterfaceRequest<mojom::PIDReceiver> pid_receiver); | 98 InterfaceRequest<mojom::PIDReceiver> pid_receiver); |
99 void AddListener(mojom::ApplicationManagerListenerPtr listener); | 99 void AddListener(mojom::ApplicationManagerListenerPtr listener); |
100 | 100 |
101 void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid); | 101 void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid); |
102 | 102 |
103 private: | 103 private: |
104 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>; | 104 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>; |
105 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; | 105 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; |
106 using IdentityToContentHandlerMap = | 106 using IdentityToShellClientFactoryMap = |
107 std::map<Identity, ContentHandlerConnection*>; | 107 std::map<Identity, ShellClientFactoryConnection*>; |
108 | 108 |
109 // Takes the contents of |params| only when it returns true. | 109 // Takes the contents of |params| only when it returns true. |
110 bool ConnectToRunningApplication( | 110 bool ConnectToRunningApplication( |
111 scoped_ptr<ConnectToApplicationParams>* params); | 111 scoped_ptr<ConnectToApplicationParams>* params); |
112 | 112 |
113 ApplicationInstance* CreateAndConnectToInstance( | 113 ApplicationInstance* CreateAndConnectToInstance( |
114 scoped_ptr<ConnectToApplicationParams> params, | 114 scoped_ptr<ConnectToApplicationParams> params, |
115 Identity* source, | 115 Identity* source, |
116 Identity* target, | 116 Identity* target, |
117 const std::string& application_name, | 117 const std::string& application_name, |
118 mojom::ShellClientRequest* request); | 118 mojom::ShellClientRequest* request); |
119 ApplicationInstance* CreateInstance( | 119 ApplicationInstance* CreateInstance( |
120 const Identity& target_id, | 120 const Identity& target_id, |
121 const mojom::Shell::ConnectToApplicationCallback& connect_callback, | 121 const mojom::Shell::ConnectToApplicationCallback& connect_callback, |
122 const base::Closure& on_application_end, | 122 const base::Closure& on_application_end, |
123 const String& application_name, | 123 const String& application_name, |
124 mojom::ShellClientRequest* request); | 124 mojom::ShellClientRequest* request); |
125 | 125 |
126 uint32_t StartContentHandler(const Identity& source, | 126 uint32_t StartShellClientFactory(const Identity& source, |
127 const Identity& content_handler, | 127 const Identity& shell_client_factory, |
128 const GURL& url, | 128 const GURL& url, |
129 mojom::ShellClientRequest request); | 129 mojom::ShellClientRequest request); |
130 // Returns a running ContentHandler for |content_handler_identity|, if there | 130 // Returns a running ShellClientFactory for |shell_client_factory_identity|, |
131 // is not one running one is started for |source_identity|. | 131 // if there is not one running one is started for |source_identity|. |
132 ContentHandlerConnection* GetContentHandler( | 132 ShellClientFactoryConnection* GetShellClientFactory( |
133 const Identity& content_handler_identity, | 133 const Identity& shell_client_factory_identity, |
134 const Identity& source_identity); | 134 const Identity& source_identity); |
135 void OnContentHandlerConnectionClosed( | 135 void OnShellClientFactoryConnectionClosed( |
136 ContentHandlerConnection* content_handler); | 136 ShellClientFactoryConnection* shell_client_factory); |
137 | 137 |
138 // Callback when remote PackageManager resolves mojo:foo to mojo:bar. | 138 // Callback when remote PackageManager resolves mojo:foo to mojo:bar. |
139 // |params| are the params passed to Connect(). | 139 // |params| are the params passed to Connect(). |
140 // |resolved_url| is the mojo: url identifying the physical package | 140 // |resolved_url| is the mojo: url identifying the physical package |
141 // application. | 141 // application. |
142 // |file_url| is the resolved file:// URL of the physical package. | 142 // |file_url| is the resolved file:// URL of the physical package. |
143 // |application_name| is the requested application's pretty name, from its | 143 // |application_name| is the requested application's pretty name, from its |
144 // manifest. | 144 // manifest. |
145 // |base_filter| is the CapabilityFilter the requested application should be | 145 // |base_filter| is the CapabilityFilter the requested application should be |
146 // run with, from its manifest. | 146 // run with, from its manifest. |
(...skipping 26 matching lines...) Expand all Loading... |
173 | 173 |
174 package_manager::mojom::ShellResolverPtr shell_resolver_; | 174 package_manager::mojom::ShellResolverPtr shell_resolver_; |
175 | 175 |
176 // Loader management. | 176 // Loader management. |
177 // Loaders are chosen in the order they are listed here. | 177 // Loaders are chosen in the order they are listed here. |
178 URLToLoaderMap url_to_loader_; | 178 URLToLoaderMap url_to_loader_; |
179 scoped_ptr<ApplicationLoader> default_loader_; | 179 scoped_ptr<ApplicationLoader> default_loader_; |
180 | 180 |
181 IdentityToInstanceMap identity_to_instance_; | 181 IdentityToInstanceMap identity_to_instance_; |
182 | 182 |
183 IdentityToContentHandlerMap identity_to_content_handler_; | 183 IdentityToShellClientFactoryMap identity_to_shell_client_factory_; |
184 // Counter used to assign ids to content handlers. | 184 // Counter used to assign ids to content handlers. |
185 uint32_t content_handler_id_counter_; | 185 uint32_t shell_client_factory_id_counter_; |
186 | 186 |
187 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; | 187 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; |
188 | 188 |
189 base::TaskRunner* task_runner_; | 189 base::TaskRunner* task_runner_; |
190 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 190 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
191 std::vector<scoped_ptr<NativeRunner>> native_runners_; | 191 std::vector<scoped_ptr<NativeRunner>> native_runners_; |
192 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 192 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
193 | 193 |
194 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 194 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
195 }; | 195 }; |
196 | 196 |
197 mojom::Shell::ConnectToApplicationCallback EmptyConnectCallback(); | 197 mojom::Shell::ConnectToApplicationCallback EmptyConnectCallback(); |
198 | 198 |
199 } // namespace shell | 199 } // namespace shell |
200 } // namespace mojo | 200 } // namespace mojo |
201 | 201 |
202 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ | 202 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ |
OLD | NEW |