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 SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class FilePath; | 27 class FilePath; |
28 class SequencedWorkerPool; | 28 class SequencedWorkerPool; |
29 } | 29 } |
30 | 30 |
31 namespace mojo { | 31 namespace mojo { |
32 namespace shell { | 32 namespace shell { |
33 | 33 |
| 34 class ContentHandlerConnection; |
34 class ShellImpl; | 35 class ShellImpl; |
35 | 36 |
36 class ApplicationManager { | 37 class ApplicationManager { |
37 public: | 38 public: |
38 class Delegate { | 39 class Delegate { |
39 public: | 40 public: |
40 // Gives the delegate a chance to apply any mappings for the specified url. | 41 // Gives the delegate a chance to apply any mappings for the specified url. |
41 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). | 42 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). |
42 virtual GURL ResolveMappings(const GURL& url) = 0; | 43 virtual GURL ResolveMappings(const GURL& url) = 0; |
43 | 44 |
(...skipping 25 matching lines...) Expand all Loading... |
69 private: | 70 private: |
70 ApplicationManager* manager_; | 71 ApplicationManager* manager_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(TestAPI); | 73 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
73 }; | 74 }; |
74 | 75 |
75 explicit ApplicationManager(Delegate* delegate); | 76 explicit ApplicationManager(Delegate* delegate); |
76 ~ApplicationManager(); | 77 ~ApplicationManager(); |
77 | 78 |
78 // Loads a service if necessary and establishes a new client connection. | 79 // Loads a service if necessary and establishes a new client connection. |
79 void ConnectToApplication(mojo::URLRequestPtr application_url, | 80 void ConnectToApplication( |
80 const GURL& requestor_url, | 81 mojo::URLRequestPtr requested_url, |
81 InterfaceRequest<ServiceProvider> services, | 82 const std::string& qualifier, |
82 ServiceProviderPtr exposed_services, | 83 const GURL& requestor_url, |
83 const base::Closure& on_application_end); | 84 InterfaceRequest<ServiceProvider> services, |
| 85 ServiceProviderPtr exposed_services, |
| 86 const base::Closure& on_application_end); |
| 87 |
84 | 88 |
85 template <typename Interface> | 89 template <typename Interface> |
86 inline void ConnectToService(const GURL& application_url, | 90 inline void ConnectToService(const GURL& application_url, |
87 InterfacePtr<Interface>* ptr) { | 91 InterfacePtr<Interface>* ptr) { |
88 ScopedMessagePipeHandle service_handle = | 92 ScopedMessagePipeHandle service_handle = |
89 ConnectToServiceByName(application_url, Interface::Name_); | 93 ConnectToServiceByName(application_url, Interface::Name_); |
90 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); | 94 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); |
91 } | 95 } |
92 | 96 |
93 ScopedMessagePipeHandle ConnectToServiceByName( | 97 ScopedMessagePipeHandle ConnectToServiceByName( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 const GURL& url); | 140 const GURL& url); |
137 | 141 |
138 // Destroys all Shell-ends of connections established with Applications. | 142 // Destroys all Shell-ends of connections established with Applications. |
139 // Applications connected by this ApplicationManager will observe pipe errors | 143 // Applications connected by this ApplicationManager will observe pipe errors |
140 // and have a chance to shutdown. | 144 // and have a chance to shutdown. |
141 void TerminateShellConnections(); | 145 void TerminateShellConnections(); |
142 | 146 |
143 // Removes a ShellImpl when it encounters an error. | 147 // Removes a ShellImpl when it encounters an error. |
144 void OnShellImplError(ShellImpl* shell_impl); | 148 void OnShellImplError(ShellImpl* shell_impl); |
145 | 149 |
| 150 // Removes a ContentHandler when its connection is closed. |
| 151 void OnContentHandlerConnectionClosed( |
| 152 ContentHandlerConnection* content_handler); |
| 153 |
146 private: | 154 private: |
147 class ContentHandlerConnection; | |
148 | |
149 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; | 155 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; |
150 using IdentityToShellImplMap = std::map<Identity, ShellImpl*>; | 156 using IdentityToShellImplMap = std::map<Identity, ShellImpl*>; |
151 using MimeTypeToURLMap = std::map<std::string, GURL>; | 157 using MimeTypeToURLMap = std::map<std::string, GURL>; |
152 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; | 158 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; |
153 using URLToContentHandlerMap = | 159 using URLToContentHandlerMap = |
154 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; | 160 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; |
155 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; | 161 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; |
156 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; | 162 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; |
157 | 163 |
158 void ConnectToApplicationInternal( | |
159 mojo::URLRequestPtr requested_url, | |
160 const std::string& qualifier, | |
161 const GURL& requestor_url, | |
162 InterfaceRequest<ServiceProvider> services, | |
163 ServiceProviderPtr exposed_services, | |
164 const base::Closure& on_application_end); | |
165 | |
166 bool ConnectToRunningApplication(const GURL& resolved_url, | 164 bool ConnectToRunningApplication(const GURL& resolved_url, |
167 const std::string& qualifier, | 165 const std::string& qualifier, |
168 const GURL& requestor_url, | 166 const GURL& requestor_url, |
169 InterfaceRequest<ServiceProvider>* services, | 167 InterfaceRequest<ServiceProvider>* services, |
170 ServiceProviderPtr* exposed_services); | 168 ServiceProviderPtr* exposed_services); |
171 | 169 |
172 bool ConnectToApplicationWithLoader( | 170 bool ConnectToApplicationWithLoader( |
173 const GURL& requested_url, | 171 const GURL& requested_url, |
174 const std::string& qualifier, | 172 const std::string& qualifier, |
175 const GURL& resolved_url, | 173 const GURL& resolved_url, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 void LoadWithContentHandler(const GURL& content_handler_url, | 214 void LoadWithContentHandler(const GURL& content_handler_url, |
217 const GURL& requestor_url, | 215 const GURL& requestor_url, |
218 const std::string& qualifier, | 216 const std::string& qualifier, |
219 InterfaceRequest<Application> application_request, | 217 InterfaceRequest<Application> application_request, |
220 URLResponsePtr url_response); | 218 URLResponsePtr url_response); |
221 | 219 |
222 // Returns the appropriate loader for |url|, or null if there is no loader | 220 // Returns the appropriate loader for |url|, or null if there is no loader |
223 // configured for the URL. | 221 // configured for the URL. |
224 ApplicationLoader* GetLoaderForURL(const GURL& url); | 222 ApplicationLoader* GetLoaderForURL(const GURL& url); |
225 | 223 |
226 // Removes a ContentHandler when it encounters an error. | |
227 void OnContentHandlerError(ContentHandlerConnection* content_handler); | |
228 | |
229 void CleanupRunner(NativeRunner* runner); | 224 void CleanupRunner(NativeRunner* runner); |
230 | 225 |
231 Delegate* const delegate_; | 226 Delegate* const delegate_; |
232 // Loader management. | 227 // Loader management. |
233 // Loaders are chosen in the order they are listed here. | 228 // Loaders are chosen in the order they are listed here. |
234 URLToLoaderMap url_to_loader_; | 229 URLToLoaderMap url_to_loader_; |
235 SchemeToLoaderMap scheme_to_loader_; | 230 SchemeToLoaderMap scheme_to_loader_; |
236 scoped_ptr<ApplicationLoader> default_loader_; | 231 scoped_ptr<ApplicationLoader> default_loader_; |
237 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 232 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
238 | 233 |
(...skipping 11 matching lines...) Expand all Loading... |
250 bool disable_cache_; | 245 bool disable_cache_; |
251 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 246 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
252 | 247 |
253 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 248 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
254 }; | 249 }; |
255 | 250 |
256 } // namespace shell | 251 } // namespace shell |
257 } // namespace mojo | 252 } // namespace mojo |
258 | 253 |
259 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 254 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
OLD | NEW |