summaryrefslogtreecommitdiffstats
path: root/chrome/browser/lifetime
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 07:47:07 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 07:47:07 +0000
commit89af400288e84e47f5756909dd7463c27f6f3423 (patch)
tree803f959ded9e6a16a81aca406705a1d04fa8e3dd /chrome/browser/lifetime
parentf69751276e78d137623b342e52537f8b49377e03 (diff)
downloadchromium_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 'chrome/browser/lifetime')
-rw-r--r--chrome/browser/lifetime/application_lifetime.cc15
-rw-r--r--chrome/browser/lifetime/application_lifetime.h5
2 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc
index 503a074..a160d71 100644
--- a/chrome/browser/lifetime/application_lifetime.cc
+++ b/chrome/browser/lifetime/application_lifetime.cc
@@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -125,6 +126,7 @@ void CloseAllBrowsers() {
void AttemptUserExit() {
#if defined(OS_CHROMEOS)
+ StartShutdownTracing();
chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutStarted", false);
// Write /tmp/uptime-logout-started as well.
const char kLogoutStarted[] = "logout-started";
@@ -138,6 +140,7 @@ void AttemptUserExit() {
state->GetString(prefs::kApplicationLocale) != owner_locale &&
!state->IsManagedPreference(prefs::kApplicationLocale)) {
state->SetString(prefs::kApplicationLocale, owner_locale);
+ TRACE_EVENT0("shutdown", "CommitPendingWrite");
state->CommitPendingWrite();
}
}
@@ -154,6 +157,18 @@ void AttemptUserExit() {
#endif
}
+void StartShutdownTracing() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kTraceShutdown)) {
+ base::debug::CategoryFilter category_filter(
+ command_line.GetSwitchValueASCII(switches::kTraceShutdown));
+ base::debug::TraceLog::GetInstance()->SetEnabled(
+ category_filter,
+ base::debug::TraceLog::RECORD_UNTIL_FULL);
+ }
+ TRACE_EVENT0("shutdown", "StartShutdownTracing");
+}
+
// The Android implementation is in application_lifetime_android.cc
#if !defined(OS_ANDROID)
void AttemptRestart() {
diff --git a/chrome/browser/lifetime/application_lifetime.h b/chrome/browser/lifetime/application_lifetime.h
index 6961e29..2f25219 100644
--- a/chrome/browser/lifetime/application_lifetime.h
+++ b/chrome/browser/lifetime/application_lifetime.h
@@ -16,6 +16,11 @@ namespace chrome {
// SIGTERM to start actual exit process.
void AttemptUserExit();
+// Starts to collect shutdown traces. On ChromeOS this will start immediately
+// on AttemptUserExit() and all other systems will start once all tabs are
+// closed.
+void StartShutdownTracing();
+
// Starts a user initiated restart process. On platforms other than
// chromeos, this sets a restart bit in the preference so that
// chrome will be restarted at the end of shutdown process. On