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

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

Issue 1307273004: Group ConnectToApplication-related info into a params struct. (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/shell/application_instance.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 SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 5 #ifndef MOJO_SHELL_APPLICATION_MANAGER_H_
6 #define SHELL_APPLICATION_MANAGER_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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/application/public/interfaces/application.mojom.h" 14 #include "mojo/application/public/interfaces/application.mojom.h"
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" 15 #include "mojo/application/public/interfaces/service_provider.mojom.h"
16 #include "mojo/application/public/interfaces/shell.mojom.h" 16 #include "mojo/application/public/interfaces/shell.mojom.h"
17 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 17 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
18 #include "mojo/public/cpp/bindings/interface_request.h" 18 #include "mojo/public/cpp/bindings/interface_request.h"
19 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
20 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" 20 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
21 #include "mojo/services/updater/updater.mojom.h" 21 #include "mojo/services/updater/updater.mojom.h"
22 #include "mojo/shell/application_loader.h" 22 #include "mojo/shell/application_loader.h"
23 #include "mojo/shell/capability_filter.h" 23 #include "mojo/shell/capability_filter.h"
24 #include "mojo/shell/connect_to_application_params.h"
24 #include "mojo/shell/fetcher.h" 25 #include "mojo/shell/fetcher.h"
25 #include "mojo/shell/identity.h" 26 #include "mojo/shell/identity.h"
26 #include "mojo/shell/native_runner.h" 27 #include "mojo/shell/native_runner.h"
27 #include "url/gurl.h" 28 #include "url/gurl.h"
28 29
29 namespace base { 30 namespace base {
30 class FilePath; 31 class FilePath;
31 class SequencedWorkerPool; 32 class SequencedWorkerPool;
32 } 33 }
33 34
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DISALLOW_COPY_AND_ASSIGN(TestAPI); 77 DISALLOW_COPY_AND_ASSIGN(TestAPI);
77 }; 78 };
78 79
79 explicit ApplicationManager(Delegate* delegate); 80 explicit ApplicationManager(Delegate* delegate);
80 ~ApplicationManager(); 81 ~ApplicationManager();
81 82
82 // Loads a service if necessary and establishes a new client connection. 83 // Loads a service if necessary and establishes a new client connection.
83 // |originator| can be NULL (e.g. for the first application or in tests), but 84 // |originator| can be NULL (e.g. for the first application or in tests), but
84 // typically is non-NULL and identifies the instance initiating the 85 // typically is non-NULL and identifies the instance initiating the
85 // connection. 86 // connection.
87 // TODO(yzshen): Remove |requestor_url|.
86 void ConnectToApplication( 88 void ConnectToApplication(
87 ApplicationInstance* originator, 89 ApplicationInstance* originator,
88 URLRequestPtr requested_url, 90 URLRequestPtr requested_url,
89 const std::string& qualifier, 91 const std::string& qualifier,
90 const GURL& requestor_url, 92 const GURL& requestor_url,
91 InterfaceRequest<ServiceProvider> services, 93 InterfaceRequest<ServiceProvider> services,
92 ServiceProviderPtr exposed_services, 94 ServiceProviderPtr exposed_services,
93 const CapabilityFilter& capability_filter, 95 const CapabilityFilter& capability_filter,
94 const base::Closure& on_application_end, 96 const base::Closure& on_application_end,
95 const Shell::ConnectToApplicationCallback& connect_callback); 97 const Shell::ConnectToApplicationCallback& connect_callback);
96 98
99 void ConnectToApplication(scoped_ptr<ConnectToApplicationParams> params);
100
97 // Must only be used by shell internals and test code as it does not forward 101 // Must only be used by shell internals and test code as it does not forward
98 // capability filters. 102 // capability filters.
99 template <typename Interface> 103 template <typename Interface>
100 inline void ConnectToService(const GURL& application_url, 104 inline void ConnectToService(const GURL& application_url,
101 InterfacePtr<Interface>* ptr) { 105 InterfacePtr<Interface>* ptr) {
102 ScopedMessagePipeHandle service_handle = 106 ScopedMessagePipeHandle service_handle =
103 ConnectToServiceByName(application_url, Interface::Name_); 107 ConnectToServiceByName(application_url, Interface::Name_);
104 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); 108 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u));
105 } 109 }
106 110
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; 167 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>;
164 using IdentityToApplicationInstanceMap = 168 using IdentityToApplicationInstanceMap =
165 std::map<Identity, ApplicationInstance*>; 169 std::map<Identity, ApplicationInstance*>;
166 using MimeTypeToURLMap = std::map<std::string, GURL>; 170 using MimeTypeToURLMap = std::map<std::string, GURL>;
167 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; 171 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>;
168 using URLToContentHandlerMap = 172 using URLToContentHandlerMap =
169 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; 173 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>;
170 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; 174 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
171 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; 175 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>;
172 176
177 // Takes the contents of |params| only when it returns true.
173 bool ConnectToRunningApplication( 178 bool ConnectToRunningApplication(
174 ApplicationInstance* originator, 179 scoped_ptr<ConnectToApplicationParams>* params);
180 // |resolved_url| is the URL to load by |loader| (if loader is not null). It
181 // may be different from |(*params)->app_url()| because of mappings and
182 // resolution rules.
183 // Takes the contents of |params| only when it returns true.
184 bool ConnectToApplicationWithLoader(
185 scoped_ptr<ConnectToApplicationParams>* params,
175 const GURL& resolved_url, 186 const GURL& resolved_url,
176 const std::string& qualifier,
177 const GURL& requestor_url,
178 InterfaceRequest<ServiceProvider>* services,
179 ServiceProviderPtr* exposed_services,
180 const CapabilityFilter& filter,
181 const Shell::ConnectToApplicationCallback& connect_callback);
182
183 bool ConnectToApplicationWithLoader(
184 ApplicationInstance* originator,
185 const GURL& requested_url,
186 const std::string& qualifier,
187 const GURL& resolved_url,
188 const GURL& requestor_url,
189 InterfaceRequest<ServiceProvider>* services,
190 ServiceProviderPtr* exposed_services,
191 const CapabilityFilter& filter,
192 const base::Closure& on_application_end,
193 const Shell::ConnectToApplicationCallback& connect_callback,
194 ApplicationLoader* loader); 187 ApplicationLoader* loader);
195 188
196 InterfaceRequest<Application> RegisterInstance( 189 InterfaceRequest<Application> RegisterInstance(
197 ApplicationInstance* originator, 190 scoped_ptr<ConnectToApplicationParams> params,
198 const GURL& app_url,
199 const std::string& qualifier,
200 const GURL& requestor_url,
201 InterfaceRequest<ServiceProvider> services,
202 ServiceProviderPtr exposed_services,
203 const CapabilityFilter& filter,
204 const base::Closure& on_application_end,
205 const Shell::ConnectToApplicationCallback& connect_callback,
206 ApplicationInstance** resulting_instance); 191 ApplicationInstance** resulting_instance);
207 192
208 // Called once |fetcher| has found app. |requested_url| is the url of the 193 // Called once |fetcher| has found app. |params->app_url()| is the url of
209 // requested application before any mappings/resolution have been applied. 194 // the requested application before any mappings/resolution have been applied.
210 void HandleFetchCallback( 195 // The corresponding URLRequest struct in |params| has been taken.
211 ApplicationInstance* originator, 196 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params,
212 const GURL& requested_url, 197 NativeApplicationCleanup cleanup,
213 const std::string& qualifier, 198 scoped_ptr<Fetcher> fetcher);
214 const GURL& requestor_url,
215 InterfaceRequest<ServiceProvider> services,
216 ServiceProviderPtr exposed_services,
217 const CapabilityFilter& filter,
218 const base::Closure& on_application_end,
219 const Shell::ConnectToApplicationCallback& connect_callback,
220 NativeApplicationCleanup cleanup,
221 scoped_ptr<Fetcher> fetcher);
222 199
223 void RunNativeApplication(InterfaceRequest<Application> application_request, 200 void RunNativeApplication(InterfaceRequest<Application> application_request,
224 bool start_sandboxed, 201 bool start_sandboxed,
225 const NativeRunnerFactory::Options& options, 202 const NativeRunnerFactory::Options& options,
226 NativeApplicationCleanup cleanup, 203 NativeApplicationCleanup cleanup,
227 scoped_ptr<Fetcher> fetcher, 204 scoped_ptr<Fetcher> fetcher,
228 const base::FilePath& file_path, 205 const base::FilePath& file_path,
229 bool path_exists); 206 bool path_exists);
230 207
231 void LoadWithContentHandler( 208 void LoadWithContentHandler(
232 ApplicationInstance* originator, 209 const Identity& originator_identity,
210 const CapabilityFilter& originator_filter,
233 const GURL& content_handler_url, 211 const GURL& content_handler_url,
234 const GURL& requestor_url,
235 const std::string& qualifier, 212 const std::string& qualifier,
236 const CapabilityFilter& filter, 213 const CapabilityFilter& filter,
237 const Shell::ConnectToApplicationCallback& connect_callback, 214 const Shell::ConnectToApplicationCallback& connect_callback,
238 ApplicationInstance* app, 215 ApplicationInstance* app,
239 InterfaceRequest<Application> application_request, 216 InterfaceRequest<Application> application_request,
240 URLResponsePtr url_response); 217 URLResponsePtr url_response);
241 218
242 // Returns the appropriate loader for |url|, or null if there is no loader 219 // Returns the appropriate loader for |url|, or null if there is no loader
243 // configured for the URL. 220 // configured for the URL.
244 ApplicationLoader* GetLoaderForURL(const GURL& url); 221 ApplicationLoader* GetLoaderForURL(const GURL& url);
(...skipping 30 matching lines...) Expand all
275 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; 252 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_;
276 253
277 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); 254 DISALLOW_COPY_AND_ASSIGN(ApplicationManager);
278 }; 255 };
279 256
280 Shell::ConnectToApplicationCallback EmptyConnectCallback(); 257 Shell::ConnectToApplicationCallback EmptyConnectCallback();
281 258
282 } // namespace shell 259 } // namespace shell
283 } // namespace mojo 260 } // namespace mojo
284 261
285 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ 262 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/shell/application_instance.cc ('k') | mojo/shell/application_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698