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

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

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
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/context.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 #include "shell/application_manager/application_manager.h" 5 #include "shell/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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/bindings/error_handler.h" 16 #include "mojo/public/cpp/bindings/error_handler.h"
17 #include "mojo/public/interfaces/application/shell.mojom.h" 17 #include "mojo/public/interfaces/application/shell.mojom.h"
18 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h" 18 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h"
19 #include "shell/application_manager/fetcher.h" 19 #include "shell/application_manager/fetcher.h"
20 #include "shell/application_manager/local_fetcher.h" 20 #include "shell/application_manager/local_fetcher.h"
21 #include "shell/application_manager/network_fetcher.h" 21 #include "shell/application_manager/network_fetcher.h"
22 22
23 namespace mojo { 23 namespace mojo {
24 24
25 namespace { 25 namespace {
26
26 // Used by TestAPI. 27 // Used by TestAPI.
27 bool has_created_instance = false; 28 bool has_created_instance = false;
28 29
29 GURL StripQueryFromURL(const GURL& url) { 30 GURL StripQueryFromURL(const GURL& url) {
30 GURL::Replacements repl; 31 GURL::Replacements repl;
31 repl.SetQueryStr(""); 32 repl.SetQueryStr("");
32 std::string result = url.ReplaceComponents(repl).spec(); 33 std::string result = url.ReplaceComponents(repl).spec();
33 34
34 // Remove the dangling '?' because it's ugly. 35 // Remove the dangling '?' because it's ugly.
35 base::ReplaceChars(result, "?", "", &result); 36 base::ReplaceChars(result, "?", "", &result);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (iter != mime_type_to_url_.end()) { 290 if (iter != mime_type_to_url_.end()) {
290 LoadWithContentHandler(iter->second, request.Pass(), 291 LoadWithContentHandler(iter->second, request.Pass(),
291 fetcher->AsURLResponse(blocking_pool_, 0)); 292 fetcher->AsURLResponse(blocking_pool_, 0));
292 return; 293 return;
293 } 294 }
294 295
295 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo 296 // TODO(aa): Sanity check that the thing we got looks vaguely like a mojo
296 // application. That could either mean looking for the platform-specific dll 297 // application. That could either mean looking for the platform-specific dll
297 // header, or looking for some specific mojo signature prepended to the 298 // header, or looking for some specific mojo signature prepended to the
298 // library. 299 // library.
300 // TODO(vtl): (Maybe this should be done by the factory/runner?)
301
302 NativeRunnerFactory::Options options;
303 if (url_to_native_options_.find(requested_url) !=
jamesr 2015/03/04 20:55:24 hmm, I would think that options would apply to the
304 url_to_native_options_.end())
305 options = url_to_native_options_[requested_url];
299 306
300 fetcher->AsPath( 307 fetcher->AsPath(
301 blocking_pool_, 308 blocking_pool_,
302 base::Bind(&ApplicationManager::RunNativeApplication, 309 base::Bind(&ApplicationManager::RunNativeApplication,
303 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()), 310 weak_ptr_factory_.GetWeakPtr(), base::Passed(request.Pass()),
304 cleanup_behavior, base::Passed(fetcher.Pass()))); 311 options, cleanup_behavior, base::Passed(fetcher.Pass())));
305 } 312 }
306 313
307 void ApplicationManager::RunNativeApplication( 314 void ApplicationManager::RunNativeApplication(
308 InterfaceRequest<Application> application_request, 315 InterfaceRequest<Application> application_request,
316 const NativeRunnerFactory::Options& options,
309 NativeRunner::CleanupBehavior cleanup_behavior, 317 NativeRunner::CleanupBehavior cleanup_behavior,
310 scoped_ptr<Fetcher> fetcher, 318 scoped_ptr<Fetcher> fetcher,
311 const base::FilePath& path, 319 const base::FilePath& path,
312 bool path_exists) { 320 bool path_exists) {
313 // We only passed fetcher to keep it alive. Done with it now. 321 // We only passed fetcher to keep it alive. Done with it now.
314 fetcher.reset(); 322 fetcher.reset();
315 323
316 DCHECK(application_request.is_pending()); 324 DCHECK(application_request.is_pending());
317 325
318 if (!path_exists) { 326 if (!path_exists) {
319 LOG(ERROR) << "Library not started because library path '" << path.value() 327 LOG(ERROR) << "Library not started because library path '" << path.value()
320 << "' does not exist."; 328 << "' does not exist.";
321 return; 329 return;
322 } 330 }
323 331
324 NativeRunner* runner = native_runner_factory_->Create().release(); 332 NativeRunner* runner = native_runner_factory_->Create(options).release();
325 native_runners_.push_back(runner); 333 native_runners_.push_back(runner);
326 runner->Start(path, cleanup_behavior, application_request.Pass(), 334 runner->Start(path, cleanup_behavior, application_request.Pass(),
327 base::Bind(&ApplicationManager::CleanupRunner, 335 base::Bind(&ApplicationManager::CleanupRunner,
328 weak_ptr_factory_.GetWeakPtr(), runner)); 336 weak_ptr_factory_.GetWeakPtr(), runner));
329 } 337 }
330 338
331 void ApplicationManager::RegisterExternalApplication( 339 void ApplicationManager::RegisterExternalApplication(
332 const GURL& url, 340 const GURL& url,
333 const std::vector<std::string>& args, 341 const std::vector<std::string>& args,
334 ApplicationPtr application) { 342 ApplicationPtr application) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (it != scheme_to_loader_.end()) 391 if (it != scheme_to_loader_.end())
384 delete it->second; 392 delete it->second;
385 scheme_to_loader_[scheme] = loader.release(); 393 scheme_to_loader_[scheme] = loader.release();
386 } 394 }
387 395
388 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args, 396 void ApplicationManager::SetArgsForURL(const std::vector<std::string>& args,
389 const GURL& url) { 397 const GURL& url) {
390 url_to_args_[url] = args; 398 url_to_args_[url] = args;
391 } 399 }
392 400
401 void ApplicationManager::SetNativeOptionsForURL(
402 const NativeRunnerFactory::Options& options,
403 const GURL& url) {
404 url_to_native_options_[url] = options;
405 }
406
393 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) { 407 ApplicationLoader* ApplicationManager::GetLoaderForURL(const GURL& url) {
394 auto url_it = url_to_loader_.find(StripQueryFromURL(url)); 408 auto url_it = url_to_loader_.find(StripQueryFromURL(url));
395 if (url_it != url_to_loader_.end()) 409 if (url_it != url_to_loader_.end())
396 return url_it->second; 410 return url_it->second;
397 auto scheme_it = scheme_to_loader_.find(url.scheme()); 411 auto scheme_it = scheme_to_loader_.find(url.scheme());
398 if (scheme_it != scheme_to_loader_.end()) 412 if (scheme_it != scheme_to_loader_.end())
399 return scheme_it->second; 413 return scheme_it->second;
400 return NULL; 414 return NULL;
401 } 415 }
402 416
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return Array<String>::From(args_it->second); 452 return Array<String>::From(args_it->second);
439 return Array<String>(); 453 return Array<String>();
440 } 454 }
441 455
442 void ApplicationManager::CleanupRunner(NativeRunner* runner) { 456 void ApplicationManager::CleanupRunner(NativeRunner* runner) {
443 native_runners_.erase( 457 native_runners_.erase(
444 std::find(native_runners_.begin(), native_runners_.end(), runner)); 458 std::find(native_runners_.begin(), native_runners_.end(), runner));
445 } 459 }
446 460
447 } // namespace mojo 461 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698