Index: chrome/browser/ui/startup/startup_browser_creator.cc |
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc |
index 202f9f8f2c473aeddd0aa22a1a0214921d1e298b..3d434911d4237874872cf04cdd11d6240e80c590 100644 |
--- a/chrome/browser/ui/startup/startup_browser_creator.cc |
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc |
@@ -14,11 +14,13 @@ |
#include "base/command_line.h" |
#include "base/compiler_specific.h" |
#include "base/environment.h" |
+#include "base/file_util.h" |
#include "base/files/file_path.h" |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/metrics/histogram.h" |
+#include "base/metrics/statistics_recorder.h" |
#include "base/path_service.h" |
#include "base/prefs/pref_service.h" |
#include "base/strings/string_number_conversions.h" |
@@ -227,6 +229,21 @@ class ProfileLaunchObserver : public content::NotificationObserver { |
base::LazyInstance<ProfileLaunchObserver> profile_launch_observer = |
LAZY_INSTANCE_INITIALIZER; |
+// This function should only be called in the blocking pool. |
Alexei Svitkine (slow)
2013/11/13 19:04:32
Nit: Have the comment actually briefly mention wha
grt (UTC plus 2)
2013/11/14 05:08:51
Done.
|
+void DumpBrowserHistograms(const base::FilePath& output_file) { |
+ base::ThreadRestrictions::AssertIOAllowed(); |
+ |
+ if (base::PathExists(output_file)) |
+ return; |
+ |
+ std::string output_string; |
+ base::StatisticsRecorder::WriteJSON(std::string(), &output_string); |
+ if (output_string.size() <= INT_MAX) { |
+ file_util::WriteFile(output_file, output_string.data(), |
+ static_cast<int>(output_string.size())); |
+ } |
+} |
+ |
} // namespace |
StartupBrowserCreator::StartupBrowserCreator() |
@@ -602,6 +619,17 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
#endif |
+ if (!process_startup) { |
marja
2013/11/13 15:37:34
Doing some code searching, it seems process_startu
grt (UTC plus 2)
2013/11/14 05:08:51
Indeed. Nice catch. I had meant for silent_launch
|
+ base::FilePath output_file( |
+ command_line.GetSwitchValuePath(switches::kDumpBrowserHistograms)); |
+ if (!output_file.empty()) { |
+ BrowserThread::PostBlockingPoolTask( |
+ FROM_HERE, |
+ base::Bind(&DumpBrowserHistograms, output_file)); |
+ } |
+ silent_launch = true; |
+ } |
+ |
// If we don't want to launch a new browser window or tab (in the case |
// of an automation request), we are done here. |
if (silent_launch) |