Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: shell/application_manager/application_manager.h

Issue 974403002: Add --force-in-process flag to shell. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 namespace mojo { 29 namespace mojo {
30 30
31 // ApplicationManager requires implementations of NativeRunner and 31 // ApplicationManager requires implementations of NativeRunner and
32 // NativeRunnerFactory to run native applications. 32 // NativeRunnerFactory to run native applications.
33 class NativeRunner { 33 class NativeRunner {
34 public: 34 public:
35 // Parameter for |Start()| to specify its cleanup behavior. 35 // Parameter for |Start()| to specify its cleanup behavior.
36 enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath }; 36 enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath };
37
37 virtual ~NativeRunner() {} 38 virtual ~NativeRunner() {}
38 39
39 // Loads the app in the file at |app_path| and runs it on some other 40 // Loads the app in the file at |app_path| and runs it on some other
40 // thread/process. If |cleanup_behavior| is |true|, takes ownership of the 41 // thread/process. If |cleanup_behavior| is |true|, takes ownership of the
41 // file. |app_completed_callback| is posted (to the thread on which |Start()| 42 // file. |app_completed_callback| is posted (to the thread on which |Start()|
42 // was called) after |MojoMain()| completes. 43 // was called) after |MojoMain()| completes.
44 // TODO(vtl): |app_path| and |cleanup_behavior| should probably be moved to
45 // the factory's Create(). Rationale: The factory may need information from
46 // the file to decide what kind of NativeRunner to make.
43 virtual void Start(const base::FilePath& app_path, 47 virtual void Start(const base::FilePath& app_path,
44 CleanupBehavior cleanup_behavior, 48 CleanupBehavior cleanup_behavior,
45 InterfaceRequest<Application> application_request, 49 InterfaceRequest<Application> application_request,
46 const base::Closure& app_completed_callback) = 0; 50 const base::Closure& app_completed_callback) = 0;
47 }; 51 };
48 52
49 class NativeRunnerFactory { 53 class NativeRunnerFactory {
50 public: 54 public:
55 // Options for running the native app. (This will contain, e.g., information
56 // about the sandbox profile, etc.)
57 struct Options {
58 // Constructs with default options.
59 Options() : force_in_process(false) {}
60
61 bool force_in_process;
62 };
63
51 virtual ~NativeRunnerFactory() {} 64 virtual ~NativeRunnerFactory() {}
52 virtual scoped_ptr<NativeRunner> Create() = 0; 65 virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0;
53 }; 66 };
54 67
55 class ApplicationManager { 68 class ApplicationManager {
56 public: 69 public:
57 class Delegate { 70 class Delegate {
58 public: 71 public:
59 virtual ~Delegate(); 72 virtual ~Delegate();
60 // Send when the Application holding the handle on the other end of the 73 // Send when the Application holding the handle on the other end of the
61 // Shell pipe goes away. 74 // Shell pipe goes away.
62 virtual void OnApplicationError(const GURL& url); 75 virtual void OnApplicationError(const GURL& url);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 136 }
124 void set_disable_cache(bool disable_cache) { disable_cache_ = disable_cache; } 137 void set_disable_cache(bool disable_cache) { disable_cache_ = disable_cache; }
125 // Sets a Loader to be used for a specific url. 138 // Sets a Loader to be used for a specific url.
126 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); 139 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
127 // Sets a Loader to be used for a specific url scheme. 140 // Sets a Loader to be used for a specific url scheme.
128 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader, 141 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader,
129 const std::string& scheme); 142 const std::string& scheme);
130 // These strings will be passed to the Initialize() method when an 143 // These strings will be passed to the Initialize() method when an
131 // Application is instantiated. 144 // Application is instantiated.
132 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url); 145 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url);
146 // These options will be used in running any native application at |url|.
147 void SetNativeOptionsForURL(const NativeRunnerFactory::Options& options,
148 const GURL& url);
133 149
134 // Destroys all Shell-ends of connections established with Applications. 150 // Destroys all Shell-ends of connections established with Applications.
135 // Applications connected by this ApplicationManager will observe pipe errors 151 // Applications connected by this ApplicationManager will observe pipe errors
136 // and have a chance to shutdown. 152 // and have a chance to shutdown.
137 void TerminateShellConnections(); 153 void TerminateShellConnections();
138 154
139 // Removes a ShellImpl when it encounters an error. 155 // Removes a ShellImpl when it encounters an error.
140 void OnShellImplError(ShellImpl* shell_impl); 156 void OnShellImplError(ShellImpl* shell_impl);
141 157
142 private: 158 private:
143 class ContentHandlerConnection; 159 class ContentHandlerConnection;
144 160
145 typedef std::map<std::string, ApplicationLoader*> SchemeToLoaderMap; 161 typedef std::map<std::string, ApplicationLoader*> SchemeToLoaderMap;
146 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap; 162 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap;
147 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; 163 typedef std::map<GURL, ShellImpl*> URLToShellImplMap;
148 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap; 164 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap;
149 typedef std::map<GURL, std::vector<std::string>> URLToArgsMap; 165 typedef std::map<GURL, std::vector<std::string>> URLToArgsMap;
150 typedef std::map<std::string, GURL> MimeTypeToURLMap; 166 typedef std::map<std::string, GURL> MimeTypeToURLMap;
167 typedef std::map<GURL, NativeRunnerFactory::Options> URLToNativeOptionsMap;
151 168
152 bool ConnectToRunningApplication(const GURL& resolved_url, 169 bool ConnectToRunningApplication(const GURL& resolved_url,
153 const GURL& requestor_url, 170 const GURL& requestor_url,
154 InterfaceRequest<ServiceProvider>* services, 171 InterfaceRequest<ServiceProvider>* services,
155 ServiceProviderPtr* exposed_services); 172 ServiceProviderPtr* exposed_services);
156 173
157 bool ConnectToApplicationWithLoader( 174 bool ConnectToApplicationWithLoader(
158 const GURL& requested_url, 175 const GURL& requested_url,
159 const GURL& resolved_url, 176 const GURL& resolved_url,
160 const GURL& requestor_url, 177 const GURL& requestor_url,
(...skipping 21 matching lines...) Expand all
182 ServiceProviderPtr exposed_services); 199 ServiceProviderPtr exposed_services);
183 200
184 void HandleFetchCallback(const GURL& requested_url, 201 void HandleFetchCallback(const GURL& requested_url,
185 const GURL& requestor_url, 202 const GURL& requestor_url,
186 InterfaceRequest<ServiceProvider> services, 203 InterfaceRequest<ServiceProvider> services,
187 ServiceProviderPtr exposed_services, 204 ServiceProviderPtr exposed_services,
188 NativeRunner::CleanupBehavior cleanup_behavior, 205 NativeRunner::CleanupBehavior cleanup_behavior,
189 scoped_ptr<Fetcher> fetcher); 206 scoped_ptr<Fetcher> fetcher);
190 207
191 void RunNativeApplication(InterfaceRequest<Application> application_request, 208 void RunNativeApplication(InterfaceRequest<Application> application_request,
209 const NativeRunnerFactory::Options& options,
192 NativeRunner::CleanupBehavior cleanup_behavior, 210 NativeRunner::CleanupBehavior cleanup_behavior,
193 scoped_ptr<Fetcher> fetcher, 211 scoped_ptr<Fetcher> fetcher,
194 const base::FilePath& file_path, 212 const base::FilePath& file_path,
195 bool path_exists); 213 bool path_exists);
196 214
197 void LoadWithContentHandler(const GURL& content_handler_url, 215 void LoadWithContentHandler(const GURL& content_handler_url,
198 InterfaceRequest<Application> application_request, 216 InterfaceRequest<Application> application_request,
199 URLResponsePtr url_response); 217 URLResponsePtr url_response);
200 218
201 // Return the appropriate loader for |url|. This can return NULL if there is 219 // Return the appropriate loader for |url|. This can return NULL if there is
(...skipping 12 matching lines...) Expand all
214 // Loader management. 232 // Loader management.
215 // Loaders are chosen in the order they are listed here. 233 // Loaders are chosen in the order they are listed here.
216 URLToLoaderMap url_to_loader_; 234 URLToLoaderMap url_to_loader_;
217 SchemeToLoaderMap scheme_to_loader_; 235 SchemeToLoaderMap scheme_to_loader_;
218 scoped_ptr<ApplicationLoader> default_loader_; 236 scoped_ptr<ApplicationLoader> default_loader_;
219 scoped_ptr<NativeRunnerFactory> native_runner_factory_; 237 scoped_ptr<NativeRunnerFactory> native_runner_factory_;
220 238
221 URLToShellImplMap url_to_shell_impl_; 239 URLToShellImplMap url_to_shell_impl_;
222 URLToContentHandlerMap url_to_content_handler_; 240 URLToContentHandlerMap url_to_content_handler_;
223 URLToArgsMap url_to_args_; 241 URLToArgsMap url_to_args_;
242 URLToNativeOptionsMap url_to_native_options_;
224 243
225 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 244 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
226 245
227 base::SequencedWorkerPool* blocking_pool_; 246 base::SequencedWorkerPool* blocking_pool_;
228 NetworkServicePtr network_service_; 247 NetworkServicePtr network_service_;
229 MimeTypeToURLMap mime_type_to_url_; 248 MimeTypeToURLMap mime_type_to_url_;
230 ScopedVector<NativeRunner> native_runners_; 249 ScopedVector<NativeRunner> native_runners_;
231 bool disable_cache_; 250 bool disable_cache_;
232 251
233 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 252 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
234 }; 253 };
235 254
236 } // namespace mojo 255 } // namespace mojo
237 256
238 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 257 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | shell/application_manager/application_manager.cc » ('j') | shell/application_manager/application_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698