OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/trace_event/trace_event.h" |
13 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
14 #include "mojo/public/cpp/bindings/error_handler.h" | 15 #include "mojo/public/cpp/bindings/error_handler.h" |
15 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | 16 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" |
16 #include "shell/application_manager/fetcher.h" | 17 #include "shell/application_manager/fetcher.h" |
17 #include "shell/application_manager/local_fetcher.h" | 18 #include "shell/application_manager/local_fetcher.h" |
18 #include "shell/application_manager/network_fetcher.h" | 19 #include "shell/application_manager/network_fetcher.h" |
19 #include "shell/application_manager/query_util.h" | 20 #include "shell/application_manager/query_util.h" |
20 #include "shell/application_manager/shell_impl.h" | 21 #include "shell/application_manager/shell_impl.h" |
21 #include "shell/switches.h" | 22 #include "shell/switches.h" |
22 | 23 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 105 |
105 void ApplicationManager::TerminateShellConnections() { | 106 void ApplicationManager::TerminateShellConnections() { |
106 STLDeleteValues(&identity_to_shell_impl_); | 107 STLDeleteValues(&identity_to_shell_impl_); |
107 } | 108 } |
108 | 109 |
109 void ApplicationManager::ConnectToApplication( | 110 void ApplicationManager::ConnectToApplication( |
110 const GURL& requested_url, | 111 const GURL& requested_url, |
111 const GURL& requestor_url, | 112 const GURL& requestor_url, |
112 InterfaceRequest<ServiceProvider> services, | 113 InterfaceRequest<ServiceProvider> services, |
113 ServiceProviderPtr exposed_services) { | 114 ServiceProviderPtr exposed_services) { |
| 115 TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::ConnectToApplication", |
| 116 TRACE_EVENT_SCOPE_THREAD, "requested_url", |
| 117 requested_url.spec()); |
114 DCHECK(requested_url.is_valid()); | 118 DCHECK(requested_url.is_valid()); |
115 | 119 |
116 // We check both the mapped and resolved urls for existing shell_impls because | 120 // We check both the mapped and resolved urls for existing shell_impls because |
117 // external applications can be registered for the unresolved mojo:foo urls. | 121 // external applications can be registered for the unresolved mojo:foo urls. |
118 | 122 |
119 GURL mapped_url = delegate_->ResolveMappings(requested_url); | 123 GURL mapped_url = delegate_->ResolveMappings(requested_url); |
120 if (ConnectToRunningApplication(mapped_url, requestor_url, &services, | 124 if (ConnectToRunningApplication(mapped_url, requestor_url, &services, |
121 &exposed_services)) { | 125 &exposed_services)) { |
122 return; | 126 return; |
123 } | 127 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 fetcher.reset(); | 327 fetcher.reset(); |
324 | 328 |
325 DCHECK(application_request.is_pending()); | 329 DCHECK(application_request.is_pending()); |
326 | 330 |
327 if (!path_exists) { | 331 if (!path_exists) { |
328 LOG(ERROR) << "Library not started because library path '" << path.value() | 332 LOG(ERROR) << "Library not started because library path '" << path.value() |
329 << "' does not exist."; | 333 << "' does not exist."; |
330 return; | 334 return; |
331 } | 335 } |
332 | 336 |
| 337 TRACE_EVENT1("mojo_shell", "ApplicationManager::RunNativeApplication", "path", |
| 338 path.AsUTF8Unsafe()); |
333 NativeRunner* runner = native_runner_factory_->Create(options).release(); | 339 NativeRunner* runner = native_runner_factory_->Create(options).release(); |
334 native_runners_.push_back(runner); | 340 native_runners_.push_back(runner); |
335 runner->Start(path, cleanup_behavior, application_request.Pass(), | 341 runner->Start(path, cleanup_behavior, application_request.Pass(), |
336 base::Bind(&ApplicationManager::CleanupRunner, | 342 base::Bind(&ApplicationManager::CleanupRunner, |
337 weak_ptr_factory_.GetWeakPtr(), runner)); | 343 weak_ptr_factory_.GetWeakPtr(), runner)); |
338 } | 344 } |
339 | 345 |
340 void ApplicationManager::RegisterExternalApplication( | 346 void ApplicationManager::RegisterExternalApplication( |
341 const GURL& url, | 347 const GURL& url, |
342 const std::vector<std::string>& args, | 348 const std::vector<std::string>& args, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 return Array<String>(); | 470 return Array<String>(); |
465 } | 471 } |
466 | 472 |
467 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 473 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
468 native_runners_.erase( | 474 native_runners_.erase( |
469 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 475 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
470 } | 476 } |
471 | 477 |
472 } // namespace shell | 478 } // namespace shell |
473 } // namespace mojo | 479 } // namespace mojo |
OLD | NEW |