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

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

Issue 1344933002: Clean up some unused methods from ApplicationManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 3 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
« no previous file with comments | « mojo/runner/switches.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // API for testing. 42 // API for testing.
43 class TestAPI { 43 class TestAPI {
44 public: 44 public:
45 explicit TestAPI(ApplicationManager* manager); 45 explicit TestAPI(ApplicationManager* manager);
46 ~TestAPI(); 46 ~TestAPI();
47 47
48 // Returns true if the shared instance has been created. 48 // Returns true if the shared instance has been created.
49 static bool HasCreatedInstance(); 49 static bool HasCreatedInstance();
50 // Returns true if there is a ApplicationInstance for this URL. 50 // Returns true if there is a ApplicationInstance for this URL.
51 bool HasRunningInstanceForURL(const GURL& url) const; 51 bool HasRunningInstanceForURL(const GURL& url) const;
52
53 private: 52 private:
54 ApplicationManager* manager_; 53 ApplicationManager* manager_;
55 54
56 DISALLOW_COPY_AND_ASSIGN(TestAPI); 55 DISALLOW_COPY_AND_ASSIGN(TestAPI);
57 }; 56 };
58 57
59 explicit ApplicationManager(scoped_ptr<ApplicationFetcher> fetcher); 58 explicit ApplicationManager(scoped_ptr<ApplicationFetcher> fetcher);
60 ~ApplicationManager(); 59 ~ApplicationManager();
61 60
62 // Loads a service if necessary and establishes a new client connection. 61 // Loads a service if necessary and establishes a new client connection.
(...skipping 30 matching lines...) Expand all
93 // Registers a package alias. When attempting to load |alias|, it will 92 // Registers a package alias. When attempting to load |alias|, it will
94 // instead redirect to |content_handler_package|, which is a content handler 93 // instead redirect to |content_handler_package|, which is a content handler
95 // which will be passed the |alias| as the URLResponse::url. Different values 94 // which will be passed the |alias| as the URLResponse::url. Different values
96 // of |alias| with the same |qualifier| that are in the same 95 // of |alias| with the same |qualifier| that are in the same
97 // |content_handler_package| will run in the same process in multi-process 96 // |content_handler_package| will run in the same process in multi-process
98 // mode. 97 // mode.
99 void RegisterApplicationPackageAlias(const GURL& alias, 98 void RegisterApplicationPackageAlias(const GURL& alias,
100 const GURL& content_handler_package, 99 const GURL& content_handler_package,
101 const std::string& qualifier); 100 const std::string& qualifier);
102 101
103 // Sets the default Loader to be used if not overridden by SetLoaderForURL() 102 // Sets the default Loader to be used if not overridden by SetLoaderForURL().
104 // or SetLoaderForScheme().
105 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { 103 void set_default_loader(scoped_ptr<ApplicationLoader> loader) {
106 default_loader_ = loader.Pass(); 104 default_loader_ = loader.Pass();
107 } 105 }
108 void set_native_runner_factory( 106 void set_native_runner_factory(
109 scoped_ptr<NativeRunnerFactory> runner_factory) { 107 scoped_ptr<NativeRunnerFactory> runner_factory) {
110 native_runner_factory_ = runner_factory.Pass(); 108 native_runner_factory_ = runner_factory.Pass();
111 } 109 }
112 void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) { 110 void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) {
113 blocking_pool_ = blocking_pool; 111 blocking_pool_ = blocking_pool;
114 } 112 }
115 // Sets a Loader to be used for a specific url. 113 // Sets a Loader to be used for a specific url.
116 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); 114 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url);
117 // Sets a Loader to be used for a specific url scheme.
118 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader,
119 const std::string& scheme);
120 // These options will be used in running any native application at |url|
121 // (which shouldn't contain a query string). (|url| will be mapped and
122 // resolved, and any application whose base resolved URL matches it will have
123 // |options| applied.)
124 // TODO(vtl): This may not do what's desired if the resolved URL results in an
125 // HTTP redirect. Really, we want options to be identified with a particular
126 // implementation, maybe via a signed manifest or something like that.
127 void SetNativeOptionsForURL(const NativeRunnerFactory::Options& options,
128 const GURL& url);
129 115
130 // Destroys all Shell-ends of connections established with Applications. 116 // Destroys all Shell-ends of connections established with Applications.
131 // Applications connected by this ApplicationManager will observe pipe errors 117 // Applications connected by this ApplicationManager will observe pipe errors
132 // and have a chance to shutdown. 118 // and have a chance to shutdown.
133 void TerminateShellConnections(); 119 void TerminateShellConnections();
134 120
135 // Removes a ApplicationInstance when it encounters an error. 121 // Removes a ApplicationInstance when it encounters an error.
136 void OnApplicationInstanceError(ApplicationInstance* instance); 122 void OnApplicationInstanceError(ApplicationInstance* instance);
137 123
138 // Removes a ContentHandler when its connection is closed. 124 // Removes a ContentHandler when its connection is closed.
139 void OnContentHandlerConnectionClosed( 125 void OnContentHandlerConnectionClosed(
140 ContentHandlerConnection* content_handler); 126 ContentHandlerConnection* content_handler);
141 127
142 ApplicationInstance* GetApplicationInstance(const Identity& identity) const; 128 ApplicationInstance* GetApplicationInstance(const Identity& identity) const;
143 129
144 private: 130 private:
145 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; 131 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>;
146 using IdentityToApplicationInstanceMap = 132 using IdentityToApplicationInstanceMap =
147 std::map<Identity, ApplicationInstance*>; 133 std::map<Identity, ApplicationInstance*>;
148 using MimeTypeToURLMap = std::map<std::string, GURL>; 134 using MimeTypeToURLMap = std::map<std::string, GURL>;
149 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>;
150 using URLToContentHandlerMap = 135 using URLToContentHandlerMap =
151 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; 136 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>;
152 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; 137 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
153 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>;
154 138
155 // Takes the contents of |params| only when it returns true. 139 // Takes the contents of |params| only when it returns true.
156 bool ConnectToRunningApplication( 140 bool ConnectToRunningApplication(
157 scoped_ptr<ConnectToApplicationParams>* params); 141 scoped_ptr<ConnectToApplicationParams>* params);
158 // |resolved_url| is the URL to load by |loader| (if loader is not null). It 142 // |resolved_url| is the URL to load by |loader| (if loader is not null). It
159 // may be different from |(*params)->app_url()| because of mappings and 143 // may be different from |(*params)->app_url()| because of mappings and
160 // resolution rules. 144 // resolution rules.
161 // Takes the contents of |params| only when it returns true. 145 // Takes the contents of |params| only when it returns true.
162 void ConnectToApplicationWithLoader( 146 void ConnectToApplicationWithLoader(
163 scoped_ptr<ConnectToApplicationParams>* params, 147 scoped_ptr<ConnectToApplicationParams>* params,
164 const GURL& resolved_url, 148 const GURL& resolved_url,
165 ApplicationLoader* loader); 149 ApplicationLoader* loader);
166 150
167 InterfaceRequest<Application> RegisterInstance( 151 InterfaceRequest<Application> RegisterInstance(
168 scoped_ptr<ConnectToApplicationParams> params, 152 scoped_ptr<ConnectToApplicationParams> params,
169 ApplicationInstance** resulting_instance); 153 ApplicationInstance** resulting_instance);
170 154
171 // Called once |fetcher| has found app. |params->app_url()| is the url of 155 // Called once |fetcher| has found app. |params->app_url()| is the url of
172 // the requested application before any mappings/resolution have been applied. 156 // the requested application before any mappings/resolution have been applied.
173 // The corresponding URLRequest struct in |params| has been taken. 157 // The corresponding URLRequest struct in |params| has been taken.
174 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params, 158 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params,
175 scoped_ptr<Fetcher> fetcher); 159 scoped_ptr<Fetcher> fetcher);
176 160
177 void RunNativeApplication(InterfaceRequest<Application> application_request, 161 void RunNativeApplication(InterfaceRequest<Application> application_request,
178 bool start_sandboxed, 162 bool start_sandboxed,
179 const NativeRunnerFactory::Options& options,
180 scoped_ptr<Fetcher> fetcher, 163 scoped_ptr<Fetcher> fetcher,
181 const base::FilePath& file_path, 164 const base::FilePath& file_path,
182 bool path_exists); 165 bool path_exists);
183 166
184 void LoadWithContentHandler( 167 void LoadWithContentHandler(
185 const Identity& originator_identity, 168 const Identity& originator_identity,
186 const CapabilityFilter& originator_filter, 169 const CapabilityFilter& originator_filter,
187 const GURL& content_handler_url, 170 const GURL& content_handler_url,
188 const std::string& qualifier, 171 const std::string& qualifier,
189 const CapabilityFilter& filter, 172 const CapabilityFilter& filter,
190 const Shell::ConnectToApplicationCallback& connect_callback, 173 const Shell::ConnectToApplicationCallback& connect_callback,
191 ApplicationInstance* app, 174 ApplicationInstance* app,
192 InterfaceRequest<Application> application_request, 175 InterfaceRequest<Application> application_request,
193 URLResponsePtr url_response); 176 URLResponsePtr url_response);
194 177
195 // Returns the appropriate loader for |url|, or the default loader if there is 178 // Returns the appropriate loader for |url|, or the default loader if there is
196 // no loader configured for the URL. 179 // no loader configured for the URL.
197 ApplicationLoader* GetLoaderForURL(const GURL& url); 180 ApplicationLoader* GetLoaderForURL(const GURL& url);
198 181
199 void CleanupRunner(NativeRunner* runner); 182 void CleanupRunner(NativeRunner* runner);
200 183
201 ScopedMessagePipeHandle ConnectToServiceByName( 184 ScopedMessagePipeHandle ConnectToServiceByName(
202 const GURL& application_url, 185 const GURL& application_url,
203 const std::string& interface_name); 186 const std::string& interface_name);
204 187
205 scoped_ptr<ApplicationFetcher> const fetcher_; 188 scoped_ptr<ApplicationFetcher> const fetcher_;
206 // Loader management. 189 // Loader management.
207 // Loaders are chosen in the order they are listed here. 190 // Loaders are chosen in the order they are listed here.
208 URLToLoaderMap url_to_loader_; 191 URLToLoaderMap url_to_loader_;
209 SchemeToLoaderMap scheme_to_loader_;
210 scoped_ptr<ApplicationLoader> default_loader_; 192 scoped_ptr<ApplicationLoader> default_loader_;
211 scoped_ptr<NativeRunnerFactory> native_runner_factory_; 193 scoped_ptr<NativeRunnerFactory> native_runner_factory_;
212 194
213 ApplicationPackagedAlias application_package_alias_; 195 ApplicationPackagedAlias application_package_alias_;
214 IdentityToApplicationInstanceMap identity_to_instance_; 196 IdentityToApplicationInstanceMap identity_to_instance_;
215 URLToContentHandlerMap url_to_content_handler_; 197 URLToContentHandlerMap url_to_content_handler_;
216 // Note: The keys are URLs after mapping and resolving.
217 URLToNativeOptionsMap url_to_native_options_;
218 198
219 base::SequencedWorkerPool* blocking_pool_; 199 base::SequencedWorkerPool* blocking_pool_;
220 updater::UpdaterPtr updater_; 200 updater::UpdaterPtr updater_;
221 MimeTypeToURLMap mime_type_to_url_; 201 MimeTypeToURLMap mime_type_to_url_;
222 ScopedVector<NativeRunner> native_runners_; 202 ScopedVector<NativeRunner> native_runners_;
223 // Counter used to assign ids to content_handlers. 203 // Counter used to assign ids to content_handlers.
224 uint32_t content_handler_id_counter_; 204 uint32_t content_handler_id_counter_;
225 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 205 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
226 206
227 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 207 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
228 }; 208 };
229 209
230 Shell::ConnectToApplicationCallback EmptyConnectCallback(); 210 Shell::ConnectToApplicationCallback EmptyConnectCallback();
231 211
232 } // namespace shell 212 } // namespace shell
233 } // namespace mojo 213 } // namespace mojo
234 214
235 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ 215 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/runner/switches.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698