Chromium Code Reviews| 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..b836fdeb4002571a3d9f8268ef837f61a9bbc87f 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; |
| +void DumpBrowserHistograms(const base::FilePath& output_file) { |
| + // To be called only on the blocking pool. |
|
Peter Kasting
2013/11/13 03:49:21
Nit: I'd put a comment like this above the functio
grt (UTC plus 2)
2013/11/13 15:13:00
Done.
|
| + base::ThreadRestrictions::AssertIOAllowed(); |
| + |
| + if (base::PathExists(output_file)) |
|
Peter Kasting
2013/11/13 03:49:21
Maybe we should overwrite or append to the file in
grt (UTC plus 2)
2013/11/13 15:13:00
I considered but discarded both. Overwrite introdu
|
| + return; |
| + |
| + std::string output_string; |
| + base::StatisticsRecorder::WriteJSON(std::string(), &output_string); |
|
Peter Kasting
2013/11/13 03:49:21
Could you perhaps also change the WriteJSON() meth
grt (UTC plus 2)
2013/11/13 15:13:00
Thanks for the suggestion. I'm going to pass on th
Peter Kasting
2013/11/13 19:18:26
Then can we do this as a followon change? It's re
grt (UTC plus 2)
2013/11/14 05:08:51
I've gone ahead and made this change for the new S
|
| + if (output_string.size() <= INT_MAX) { |
|
Peter Kasting
2013/11/13 03:49:21
Urgh... I wonder if we can assume histograms are s
grt (UTC plus 2)
2013/11/13 15:13:00
I feel pretty confident that they'll be smaller th
Peter Kasting
2013/11/13 19:18:26
Well, if your definition of correct code is that w
grt (UTC plus 2)
2013/11/14 05:08:51
Likely not.
|
| + 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) { |
|
Peter Kasting
2013/11/13 03:49:21
I lack sufficient familiarity with this file to tr
grt (UTC plus 2)
2013/11/13 15:13:00
Done.
|
| + 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) |