diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 07:47:07 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 07:47:07 +0000 |
commit | 89af400288e84e47f5756909dd7463c27f6f3423 (patch) | |
tree | 803f959ded9e6a16a81aca406705a1d04fa8e3dd /content/browser/browser_main_runner.cc | |
parent | f69751276e78d137623b342e52537f8b49377e03 (diff) | |
download | chromium_src-89af400288e84e47f5756909dd7463c27f6f3423.zip chromium_src-89af400288e84e47f5756909dd7463c27f6f3423.tar.gz chromium_src-89af400288e84e47f5756909dd7463c27f6f3423.tar.bz2 |
Adding shutdown tracing capabilities
use "--trace-shutdown" to enable the feature to start profiling when the user has pressed "shutdown" and specify "--trace-shutdown-file=<name>" to specify the file where you want to dump to. Additionally you can specify which modules to trace with e.g. "--trace-shutdown=base,net".
That said: NOTE that the dumping will cost time since it has to be done after the shutdown of Chrome is finished. As such it takes time and will make it impossible to get a correct reading of time from shutdown till a new startup is finished.
Note: This is similar to the trace-startup - with the exception that upon shutdown it is not possible to rely on threads for IO anymore.
BUG=281524
TEST=visual tests
Review URL: https://chromiumcodereview.appspot.com/23691025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_main_runner.cc')
-rw-r--r-- | content/browser/browser_main_runner.cc | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index f97318a..27fb6fc 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -12,6 +12,7 @@ #include "base/metrics/histogram.h" #include "base/metrics/statistics_recorder.h" #include "content/browser/browser_main_loop.h" +#include "content/browser/browser_shutdown_profile_dumper.h" #include "content/browser/notification_service_impl.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" @@ -124,20 +125,32 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { virtual void Shutdown() OVERRIDE { DCHECK(initialization_started_); DCHECK(!is_shutdown_); - g_exited_main_message_loop = true; + // The shutdown tracing got enabled in AttemptUserExit earlier, but someone + // needs to write the result to disc. For that a dumper needs to get created + // which will dump the traces to disc when it gets destroyed. + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + scoped_ptr<BrowserShutdownProfileDumper> profiler; + if (command_line.HasSwitch(switches::kTraceShutdown)) + profiler.reset(new BrowserShutdownProfileDumper()); - main_loop_->ShutdownThreadsAndCleanUp(); + { + // The trace event has to stay between profiler creation and destruction. + TRACE_EVENT0("shutdown", "BrowserMainRunner"); + g_exited_main_message_loop = true; - ui::ShutdownInputMethod(); -#if defined(OS_WIN) - ole_initializer_.reset(NULL); -#endif + main_loop_->ShutdownThreadsAndCleanUp(); - main_loop_.reset(NULL); + ui::ShutdownInputMethod(); + #if defined(OS_WIN) + ole_initializer_.reset(NULL); + #endif - notification_service_.reset(NULL); + main_loop_.reset(NULL); - is_shutdown_ = true; + notification_service_.reset(NULL); + + is_shutdown_ = true; + } } protected: |