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

Side by Side Diff: shell/context.cc

Issue 1024723002: Add some trace points to mojo_shell for app lifetime (Closed) Base URL: git@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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/context.h" 5 #include "shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/trace_event/trace_event.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "mojo/common/trace_controller_impl.h" 23 #include "mojo/common/trace_controller_impl.h"
23 #include "mojo/common/tracing_impl.h" 24 #include "mojo/common/tracing_impl.h"
24 #include "mojo/edk/embedder/embedder.h" 25 #include "mojo/edk/embedder/embedder.h"
25 #include "mojo/edk/embedder/simple_platform_support.h" 26 #include "mojo/edk/embedder/simple_platform_support.h"
26 #include "mojo/public/cpp/application/application_connection.h" 27 #include "mojo/public/cpp/application/application_connection.h"
27 #include "mojo/public/cpp/application/application_delegate.h" 28 #include "mojo/public/cpp/application/application_delegate.h"
28 #include "mojo/public/cpp/application/application_impl.h" 29 #include "mojo/public/cpp/application/application_impl.h"
29 #include "services/tracing/tracing.mojom.h" 30 #include "services/tracing/tracing.mojom.h"
30 #include "shell/application_manager/application_loader.h" 31 #include "shell/application_manager/application_loader.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 228
228 void Context::SetCommandLineCWD(const base::FilePath& path) { 229 void Context::SetCommandLineCWD(const base::FilePath& path) {
229 command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); 230 command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path));
230 } 231 }
231 232
232 GURL Context::ResolveCommandLineURL(const std::string& path) { 233 GURL Context::ResolveCommandLineURL(const std::string& path) {
233 return command_line_cwd_.Resolve(path); 234 return command_line_cwd_.Resolve(path);
234 } 235 }
235 236
236 bool Context::Init() { 237 bool Context::Init() {
238 TRACE_EVENT0("mojo_shell", "Context::Init");
237 const base::CommandLine& command_line = 239 const base::CommandLine& command_line =
238 *base::CommandLine::ForCurrentProcess(); 240 *base::CommandLine::ForCurrentProcess();
239 241
240 if (command_line.HasSwitch(switches::kWaitForDebugger)) 242 if (command_line.HasSwitch(switches::kWaitForDebugger))
241 base::debug::WaitForDebugger(60, true); 243 base::debug::WaitForDebugger(60, true);
242 244
243 EnsureEmbedderIsInitialized(); 245 EnsureEmbedderIsInitialized();
244 task_runners_.reset( 246 task_runners_.reset(
245 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); 247 new TaskRunners(base::MessageLoop::current()->message_loop_proxy()));
246 248
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 GURL("mojo:tracing"), GURL(""), nullptr, 293 GURL("mojo:tracing"), GURL(""), nullptr,
292 tracing_service_provider_ptr.Pass()); 294 tracing_service_provider_ptr.Pass());
293 295
294 if (listener_) 296 if (listener_)
295 listener_->WaitForListening(); 297 listener_->WaitForListening();
296 298
297 return true; 299 return true;
298 } 300 }
299 301
300 void Context::Shutdown() { 302 void Context::Shutdown() {
303 TRACE_EVENT0("mojo_shell", "Context::Shutdown");
301 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 304 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
302 task_runners_->shell_runner()); 305 task_runners_->shell_runner());
303 embedder::ShutdownIPCSupport(); 306 embedder::ShutdownIPCSupport();
304 // We'll quit when we get OnShutdownComplete(). 307 // We'll quit when we get OnShutdownComplete().
305 base::MessageLoop::current()->Run(); 308 base::MessageLoop::current()->Run();
306 } 309 }
307 310
308 void Context::OnApplicationError(const GURL& url) { 311 void Context::OnApplicationError(const GURL& url) {
312 TRACE_EVENT1("mojo_shell", "Context::OnApplicationError", "url", url.spec());
309 if (app_urls_.find(url) != app_urls_.end()) { 313 if (app_urls_.find(url) != app_urls_.end()) {
310 app_urls_.erase(url); 314 app_urls_.erase(url);
311 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { 315 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
312 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 316 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
313 task_runners_->shell_runner()); 317 task_runners_->shell_runner());
314 base::MessageLoop::current()->Quit(); 318 base::MessageLoop::current()->Quit();
315 } 319 }
316 } 320 }
317 } 321 }
318 322
(...skipping 23 matching lines...) Expand all
342 ScopedMessagePipeHandle Context::ConnectToServiceByName( 346 ScopedMessagePipeHandle Context::ConnectToServiceByName(
343 const GURL& application_url, 347 const GURL& application_url,
344 const std::string& service_name) { 348 const std::string& service_name) {
345 app_urls_.insert(application_url); 349 app_urls_.insert(application_url);
346 return application_manager_.ConnectToServiceByName(application_url, 350 return application_manager_.ConnectToServiceByName(application_url,
347 service_name).Pass(); 351 service_name).Pass();
348 } 352 }
349 353
350 } // namespace shell 354 } // namespace shell
351 } // namespace mojo 355 } // namespace mojo
OLDNEW
« shell/application_manager/network_fetcher.cc ('K') | « shell/application_manager/network_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698