OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/startup/startup_browser_creator.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "apps/app_load_service.h" | 10 #include "apps/app_load_service.h" |
11 #include "apps/switches.h" | 11 #include "apps/switches.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/environment.h" | 16 #include "base/environment.h" |
17 #include "base/file_util.h" | |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
18 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
21 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
23 #include "base/metrics/statistics_recorder.h" | |
22 #include "base/path_service.h" | 24 #include "base/path_service.h" |
23 #include "base/prefs/pref_service.h" | 25 #include "base/prefs/pref_service.h" |
24 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/string_split.h" | 27 #include "base/strings/string_split.h" |
26 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
27 #include "base/threading/thread_restrictions.h" | 29 #include "base/threading/thread_restrictions.h" |
28 #include "chrome/browser/app_mode/app_mode_utils.h" | 30 #include "chrome/browser/app_mode/app_mode_utils.h" |
29 #include "chrome/browser/auto_launch_trial.h" | 31 #include "chrome/browser/auto_launch_trial.h" |
30 #include "chrome/browser/automation/automation_provider.h" | 32 #include "chrome/browser/automation/automation_provider.h" |
31 #include "chrome/browser/automation/automation_provider_list.h" | 33 #include "chrome/browser/automation/automation_provider_list.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 Profile* profile_to_activate_; | 222 Profile* profile_to_activate_; |
221 // Set once we attempted to activate a profile. We only get one shot at this. | 223 // Set once we attempted to activate a profile. We only get one shot at this. |
222 bool activated_profile_; | 224 bool activated_profile_; |
223 | 225 |
224 DISALLOW_COPY_AND_ASSIGN(ProfileLaunchObserver); | 226 DISALLOW_COPY_AND_ASSIGN(ProfileLaunchObserver); |
225 }; | 227 }; |
226 | 228 |
227 base::LazyInstance<ProfileLaunchObserver> profile_launch_observer = | 229 base::LazyInstance<ProfileLaunchObserver> profile_launch_observer = |
228 LAZY_INSTANCE_INITIALIZER; | 230 LAZY_INSTANCE_INITIALIZER; |
229 | 231 |
232 void DumpBrowserHistograms(const base::FilePath& output_file) { | |
233 // 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.
| |
234 base::ThreadRestrictions::AssertIOAllowed(); | |
235 | |
236 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
| |
237 return; | |
238 | |
239 std::string output_string; | |
240 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
| |
241 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.
| |
242 file_util::WriteFile(output_file, output_string.data(), | |
243 static_cast<int>(output_string.size())); | |
244 } | |
245 } | |
246 | |
230 } // namespace | 247 } // namespace |
231 | 248 |
232 StartupBrowserCreator::StartupBrowserCreator() | 249 StartupBrowserCreator::StartupBrowserCreator() |
233 : is_default_browser_dialog_suppressed_(false), | 250 : is_default_browser_dialog_suppressed_(false), |
234 show_main_browser_window_(true) { | 251 show_main_browser_window_(true) { |
235 } | 252 } |
236 | 253 |
237 StartupBrowserCreator::~StartupBrowserCreator() {} | 254 StartupBrowserCreator::~StartupBrowserCreator() {} |
238 | 255 |
239 // static | 256 // static |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 612 |
596 // Skip browser launch since app mode launches its app window. | 613 // Skip browser launch since app mode launches its app window. |
597 silent_launch = true; | 614 silent_launch = true; |
598 } | 615 } |
599 #endif | 616 #endif |
600 | 617 |
601 #if defined(TOOLKIT_VIEWS) && defined(USE_X11) | 618 #if defined(TOOLKIT_VIEWS) && defined(USE_X11) |
602 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); | 619 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
603 #endif | 620 #endif |
604 | 621 |
622 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.
| |
623 base::FilePath output_file( | |
624 command_line.GetSwitchValuePath(switches::kDumpBrowserHistograms)); | |
625 if (!output_file.empty()) { | |
626 BrowserThread::PostBlockingPoolTask( | |
627 FROM_HERE, | |
628 base::Bind(&DumpBrowserHistograms, output_file)); | |
629 } | |
630 silent_launch = true; | |
631 } | |
632 | |
605 // If we don't want to launch a new browser window or tab (in the case | 633 // If we don't want to launch a new browser window or tab (in the case |
606 // of an automation request), we are done here. | 634 // of an automation request), we are done here. |
607 if (silent_launch) | 635 if (silent_launch) |
608 return true; | 636 return true; |
609 | 637 |
610 // Check for --load-and-launch-app. | 638 // Check for --load-and-launch-app. |
611 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && | 639 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && |
612 !IncognitoModePrefs::ShouldLaunchIncognito( | 640 !IncognitoModePrefs::ShouldLaunchIncognito( |
613 command_line, last_used_profile->GetPrefs())) { | 641 command_line, last_used_profile->GetPrefs())) { |
614 CommandLine::StringType path = command_line.GetSwitchValueNative( | 642 CommandLine::StringType path = command_line.GetSwitchValueNative( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 | 782 |
755 // static | 783 // static |
756 bool StartupBrowserCreator::ActivatedProfile() { | 784 bool StartupBrowserCreator::ActivatedProfile() { |
757 return profile_launch_observer.Get().activated_profile(); | 785 return profile_launch_observer.Get().activated_profile(); |
758 } | 786 } |
759 | 787 |
760 bool HasPendingUncleanExit(Profile* profile) { | 788 bool HasPendingUncleanExit(Profile* profile) { |
761 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && | 789 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && |
762 !profile_launch_observer.Get().HasBeenLaunched(profile); | 790 !profile_launch_observer.Get().HasBeenLaunched(profile); |
763 } | 791 } |
OLD | NEW |