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

Side by Side Diff: mojo/application_manager/application_manager.cc

Issue 568173003: Add Initialize() method to Application with ability to send args using (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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
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 #include "mojo/application_manager/application_manager.h" 5 #include "mojo/application_manager/application_manager.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ScopedMessagePipeHandle* shell_handle) { 213 ScopedMessagePipeHandle* shell_handle) {
214 ShellImpl* shell_impl = NULL; 214 ShellImpl* shell_impl = NULL;
215 URLToShellImplMap::iterator iter = url_to_shell_impl_.find(url); 215 URLToShellImplMap::iterator iter = url_to_shell_impl_.find(url);
216 if (iter != url_to_shell_impl_.end()) { 216 if (iter != url_to_shell_impl_.end()) {
217 // This can happen because services are loaded asynchronously. So if we get 217 // This can happen because services are loaded asynchronously. So if we get
218 // two requests for the same service close to each other, we might get here 218 // two requests for the same service close to each other, we might get here
219 // and find that we already have it. 219 // and find that we already have it.
220 shell_impl = iter->second; 220 shell_impl = iter->second;
221 } else { 221 } else {
222 MessagePipe pipe; 222 MessagePipe pipe;
223 URLToArgsMap::const_iterator args_it = url_to_args_.find(url);
224 Array<String> args;
225 if (args_it != url_to_args_.end())
226 args = Array<String>::From(args_it->second);
223 shell_impl = WeakBindToPipe(new ShellImpl(this, url), pipe.handle1.Pass()); 227 shell_impl = WeakBindToPipe(new ShellImpl(this, url), pipe.handle1.Pass());
224 url_to_shell_impl_[url] = shell_impl; 228 url_to_shell_impl_[url] = shell_impl;
225 *shell_handle = pipe.handle0.Pass(); 229 *shell_handle = pipe.handle0.Pass();
230 shell_impl->client()->Initialize(args.Pass());
226 } 231 }
227 232
228 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass()); 233 ConnectToClient(shell_impl, url, requestor_url, service_provider.Pass());
229 } 234 }
230 235
231 void ApplicationManager::LoadWithContentHandler( 236 void ApplicationManager::LoadWithContentHandler(
232 const GURL& content_url, 237 const GURL& content_url,
233 const GURL& requestor_url, 238 const GURL& requestor_url,
234 const GURL& content_handler_url, 239 const GURL& content_handler_url,
235 URLResponsePtr url_response, 240 URLResponsePtr url_response,
(...skipping 24 matching lines...) Expand all
260 265
261 void ApplicationManager::SetLoaderForScheme( 266 void ApplicationManager::SetLoaderForScheme(
262 scoped_ptr<ApplicationLoader> loader, 267 scoped_ptr<ApplicationLoader> loader,
263 const std::string& scheme) { 268 const std::string& scheme) {
264 SchemeToLoaderMap::iterator it = scheme_to_loader_.find(scheme); 269 SchemeToLoaderMap::iterator it = scheme_to_loader_.find(scheme);
265 if (it != scheme_to_loader_.end()) 270 if (it != scheme_to_loader_.end())
266 delete it->second; 271 delete it->second;
267 scheme_to_loader_[scheme] = loader.release(); 272 scheme_to_loader_[scheme] = loader.release();
268 } 273 }
269 274
275 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args,
276 const GURL& url) {
277 url_to_args_[url] = args;
278 }
279
270 void ApplicationManager::SetInterceptor(Interceptor* interceptor) { 280 void ApplicationManager::SetInterceptor(Interceptor* interceptor) {
271 interceptor_ = interceptor; 281 interceptor_ = interceptor;
272 } 282 }
273 283
274 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { 284 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) {
275 URLToLoaderMap::const_iterator url_it = url_to_loader_.find(url); 285 URLToLoaderMap::const_iterator url_it = url_to_loader_.find(url);
276 if (url_it != url_to_loader_.end()) 286 if (url_it != url_to_loader_.end())
277 return url_it->second; 287 return url_it->second;
278 SchemeToLoaderMap::const_iterator scheme_it = 288 SchemeToLoaderMap::const_iterator scheme_it =
279 scheme_to_loader_.find(url.scheme()); 289 scheme_to_loader_.find(url.scheme());
(...skipping 22 matching lines...) Expand all
302 StubServiceProvider* stub_sp = new StubServiceProvider; 312 StubServiceProvider* stub_sp = new StubServiceProvider;
303 ServiceProviderPtr spp; 313 ServiceProviderPtr spp;
304 BindToProxy(stub_sp, &spp); 314 BindToProxy(stub_sp, &spp);
305 ConnectToApplication(application_url, GURL(), spp.Pass()); 315 ConnectToApplication(application_url, GURL(), spp.Pass());
306 MessagePipe pipe; 316 MessagePipe pipe;
307 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, 317 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name,
308 pipe.handle1.Pass()); 318 pipe.handle1.Pass());
309 return pipe.handle0.Pass(); 319 return pipe.handle0.Pass();
310 } 320 }
311 } // namespace mojo 321 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/application_manager/application_manager.h ('k') | mojo/application_manager/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698