Chromium Code Reviews| 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/at_exit.h" | 14 #include "base/at_exit.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/debug/debugger.h" | |
| 17 #include "base/debug/trace_event.h" | 18 #include "base/debug/trace_event.h" |
| 18 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 19 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
| 20 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| 21 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 22 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 23 #include "base/prefs/json_pref_store.h" | 24 #include "base/prefs/json_pref_store.h" |
| 24 #include "base/prefs/pref_registry_simple.h" | 25 #include "base/prefs/pref_registry_simple.h" |
| 25 #include "base/prefs/pref_service.h" | 26 #include "base/prefs/pref_service.h" |
| 26 #include "base/prefs/pref_value_store.h" | 27 #include "base/prefs/pref_value_store.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 83 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
| 83 #include "chrome/browser/prefs/command_line_pref_store.h" | 84 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 84 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 85 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 85 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 86 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 86 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | 87 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" |
| 87 #include "chrome/browser/process_singleton.h" | 88 #include "chrome/browser/process_singleton.h" |
| 88 #include "chrome/browser/profiles/profile.h" | 89 #include "chrome/browser/profiles/profile.h" |
| 89 #include "chrome/browser/profiles/profile_manager.h" | 90 #include "chrome/browser/profiles/profile_manager.h" |
| 90 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" | 91 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
| 91 #include "chrome/browser/search_engines/search_engine_type.h" | 92 #include "chrome/browser/search_engines/search_engine_type.h" |
| 92 #include "chrome/browser/search_engines/template_url.h" | |
| 93 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | |
| 94 #include "chrome/browser/search_engines/template_url_service.h" | |
| 95 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 96 #include "chrome/browser/service/service_process_control.h" | 93 #include "chrome/browser/service/service_process_control.h" |
| 97 #include "chrome/browser/shell_integration.h" | 94 #include "chrome/browser/shell_integration.h" |
| 98 #include "chrome/browser/three_d_api_observer.h" | 95 #include "chrome/browser/three_d_api_observer.h" |
| 99 #include "chrome/browser/translate/translate_manager.h" | 96 #include "chrome/browser/translate/translate_manager.h" |
| 100 #include "chrome/browser/ui/app_list/app_list_service.h" | 97 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 101 #include "chrome/browser/ui/browser.h" | 98 #include "chrome/browser/ui/browser.h" |
| 102 #include "chrome/browser/ui/browser_finder.h" | 99 #include "chrome/browser/ui/browser_finder.h" |
| 103 #include "chrome/browser/ui/host_desktop.h" | 100 #include "chrome/browser/ui/host_desktop.h" |
| 104 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 101 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| 105 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 102 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 #endif | 192 #endif |
| 196 | 193 |
| 197 #if defined(ENABLE_RLZ) | 194 #if defined(ENABLE_RLZ) |
| 198 #include "chrome/browser/rlz/rlz.h" | 195 #include "chrome/browser/rlz/rlz.h" |
| 199 #endif | 196 #endif |
| 200 | 197 |
| 201 #if defined(TOOLKIT_VIEWS) | 198 #if defined(TOOLKIT_VIEWS) |
| 202 #include "ui/views/focus/accelerator_handler.h" | 199 #include "ui/views/focus/accelerator_handler.h" |
| 203 #endif | 200 #endif |
| 204 | 201 |
| 205 #if defined(USE_X11) | |
| 206 #include "chrome/browser/chrome_browser_main_x11.h" | |
| 207 #endif | |
| 208 | |
| 209 using content::BrowserThread; | 202 using content::BrowserThread; |
| 210 | 203 |
| 211 namespace { | 204 namespace { |
| 212 | 205 |
| 213 // This function provides some ways to test crash and assertion handling | 206 // This function provides some ways to test crash and assertion handling |
| 214 // behavior of the program. | 207 // behavior of the program. |
| 215 void HandleTestParameters(const CommandLine& command_line) { | 208 void HandleTestParameters(const CommandLine& command_line) { |
| 216 // This parameter causes an assertion. | 209 // This parameter causes an assertion. |
| 217 if (command_line.HasSwitch(switches::kBrowserAssertTest)) { | 210 if (command_line.HasSwitch(switches::kBrowserAssertTest)) { |
| 218 DCHECK(false); | 211 DCHECK(false); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 ChromeBrowserMainParts::ChromeBrowserMainParts( | 546 ChromeBrowserMainParts::ChromeBrowserMainParts( |
| 554 const content::MainFunctionParams& parameters) | 547 const content::MainFunctionParams& parameters) |
| 555 : parameters_(parameters), | 548 : parameters_(parameters), |
| 556 parsed_command_line_(parameters.command_line), | 549 parsed_command_line_(parameters.command_line), |
| 557 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 550 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
| 558 startup_watcher_(new StartupTimeBomb()), | 551 startup_watcher_(new StartupTimeBomb()), |
| 559 shutdown_watcher_(new ShutdownWatcherHelper()), | 552 shutdown_watcher_(new ShutdownWatcherHelper()), |
| 560 startup_timer_(new performance_monitor::StartupTimer()), | 553 startup_timer_(new performance_monitor::StartupTimer()), |
| 561 browser_field_trials_(parameters.command_line), | 554 browser_field_trials_(parameters.command_line), |
| 562 rvh_callback_(base::Bind(&RenderViewHostCreated)), | 555 rvh_callback_(base::Bind(&RenderViewHostCreated)), |
| 563 record_search_engine_(false), | |
| 564 translate_manager_(NULL), | 556 translate_manager_(NULL), |
| 565 profile_(NULL), | 557 profile_(NULL), |
| 566 run_message_loop_(true), | 558 run_message_loop_(true), |
| 567 notify_result_(ProcessSingleton::PROCESS_NONE), | 559 notify_result_(ProcessSingleton::PROCESS_NONE), |
| 568 do_first_run_tasks_(false), | 560 do_first_run_tasks_(false), |
| 569 local_state_(NULL), | 561 local_state_(NULL), |
| 570 restart_last_session_(false) { | 562 restart_last_session_(false) { |
| 571 // If we're running tests (ui_task is non-null). | 563 // If we're running tests (ui_task is non-null). |
| 572 if (parameters.ui_task) | 564 if (parameters.ui_task) |
| 573 browser_defaults::enable_help_app = false; | 565 browser_defaults::enable_help_app = false; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 #if defined(OS_CHROMEOS) | 681 #if defined(OS_CHROMEOS) |
| 690 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 682 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
| 691 &enabled); | 683 &enabled); |
| 692 #else | 684 #else |
| 693 enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled); | 685 enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled); |
| 694 #endif // #if defined(OS_CHROMEOS) | 686 #endif // #if defined(OS_CHROMEOS) |
| 695 #endif // defined(GOOGLE_CHROME_BUILD) | 687 #endif // defined(GOOGLE_CHROME_BUILD) |
| 696 return enabled; | 688 return enabled; |
| 697 } | 689 } |
| 698 | 690 |
| 691 void ChromeBrowserMainParts::RecordBrowserStartupTime(bool is_first_run) { | |
| 692 // Don't record any metrics if UI was displayed before this point e.g. | |
| 693 // warning dialogs. | |
| 694 if (startup_metric_utils::WasNonBrowserUIDisplayed()) | |
| 695 return; | |
| 696 | |
| 697 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and | |
| 698 // Windows. | |
| 699 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 700 const base::Time* process_creation_time = | |
| 701 base::CurrentProcessInfo::CreationTime(); | |
| 702 | |
| 703 if (!is_first_run && process_creation_time) { | |
| 704 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", | |
| 705 base::Time::Now() - *process_creation_time); | |
| 706 } | |
| 707 #endif // defined(OS_MACOSX) || defined(OS_WIN) | |
| 708 | |
| 709 // Record collected startup metrics. | |
| 710 startup_metric_utils::OnBrowserStartupComplete(is_first_run); | |
| 711 | |
| 712 // Deletes self. | |
| 713 new LoadCompleteListener(); | |
| 714 } | |
| 715 | |
| 716 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 717 void ChromeBrowserMainParts::RecordPreReadExperimentTime(const char* name, | |
| 718 base::TimeDelta time) { | |
| 719 DCHECK(name != NULL); | |
| 720 | |
| 721 // This gets called with different histogram names, so we don't want to use | |
| 722 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
| 723 // first call wins. | |
| 724 AddPreReadHistogramTime(name, time); | |
| 725 | |
| 726 #if defined(OS_WIN) | |
| 727 #if defined(GOOGLE_CHROME_BUILD) | |
| 728 // The pre-read experiment is Windows and Google Chrome specific. | |
| 729 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 730 | |
| 731 // Only record the sub-histogram result if the experiment is running | |
| 732 // (environment variable is set, and valid). | |
| 733 std::string pre_read_percentage; | |
| 734 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { | |
| 735 std::string uma_name(name); | |
| 736 | |
| 737 // We want XP to record a separate histogram, as the loader on XP | |
| 738 // is very different from the Vista and Win7 loaders. | |
| 739 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
| 740 uma_name += "_XP"; | |
| 741 | |
| 742 uma_name += "_PreRead_"; | |
| 743 uma_name += pre_read_percentage; | |
| 744 AddPreReadHistogramTime(uma_name.c_str(), time); | |
| 745 } | |
| 746 #endif | |
| 747 #endif | |
| 748 } | |
| 749 | |
| 699 // ----------------------------------------------------------------------------- | 750 // ----------------------------------------------------------------------------- |
| 700 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 751 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
| 701 | 752 |
| 702 #if defined(OS_WIN) | 753 #if defined(OS_WIN) |
| 703 #define DLLEXPORT __declspec(dllexport) | 754 #define DLLEXPORT __declspec(dllexport) |
| 704 | 755 |
| 705 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 756 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
| 706 extern "C" { | 757 extern "C" { |
| 707 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 758 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 708 } | 759 } |
| 709 | 760 |
| 710 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 761 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 711 // Need an instance of AtExitManager to handle singleton creations and | 762 // Need an instance of AtExitManager to handle singleton creations and |
| 712 // deletions. We need this new instance because, the old instance created | 763 // deletions. We need this new instance because, the old instance created |
| 713 // in ChromeMain() got destructed when the function returned. | 764 // in ChromeMain() got destructed when the function returned. |
| 714 base::AtExitManager exit_manager; | 765 base::AtExitManager exit_manager; |
| 715 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 766 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 716 } | 767 } |
| 717 #endif | 768 #endif |
| 718 | 769 |
| 719 // content::BrowserMainParts implementation ------------------------------------ | 770 // content::BrowserMainParts implementation ------------------------------------ |
| 720 | 771 |
| 721 void ChromeBrowserMainParts::PreEarlyInitialization() { | 772 void ChromeBrowserMainParts::PreEarlyInitialization() { |
| 722 #if defined(USE_X11) | |
| 723 SetBrowserX11ErrorHandlersPreEarlyInitialization(); | |
| 724 #endif | |
|
Nico
2013/07/10 17:32:50
I would've guessed that this is here to make sure
jam
2013/07/10 17:47:02
I didn't see any indication that it was put here b
oshima
2013/07/10 18:50:37
SetBrowserX11ErrorHandlersPreEarlyInitialization s
| |
| 725 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreEarlyInitialization"); | 773 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreEarlyInitialization"); |
| 726 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 774 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 727 chrome_extra_parts_[i]->PreEarlyInitialization(); | 775 chrome_extra_parts_[i]->PreEarlyInitialization(); |
| 728 } | 776 } |
| 729 | 777 |
| 730 void ChromeBrowserMainParts::PostEarlyInitialization() { | 778 void ChromeBrowserMainParts::PostEarlyInitialization() { |
| 731 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostEarlyInitialization"); | 779 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostEarlyInitialization"); |
| 732 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 780 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 733 chrome_extra_parts_[i]->PostEarlyInitialization(); | 781 chrome_extra_parts_[i]->PostEarlyInitialization(); |
| 734 } | 782 } |
| 735 | 783 |
| 736 void ChromeBrowserMainParts::ToolkitInitialized() { | 784 void ChromeBrowserMainParts::ToolkitInitialized() { |
| 737 TRACE_EVENT0("startup", "ChromeBrowserMainParts::ToolkitInitialized"); | 785 TRACE_EVENT0("startup", "ChromeBrowserMainParts::ToolkitInitialized"); |
| 738 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 786 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 739 chrome_extra_parts_[i]->ToolkitInitialized(); | 787 chrome_extra_parts_[i]->ToolkitInitialized(); |
| 740 } | 788 } |
| 741 | 789 |
| 742 void ChromeBrowserMainParts::PreMainMessageLoopStart() { | 790 void ChromeBrowserMainParts::PreMainMessageLoopStart() { |
| 743 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopStart"); | 791 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopStart"); |
| 744 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 792 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 745 chrome_extra_parts_[i]->PreMainMessageLoopStart(); | 793 chrome_extra_parts_[i]->PreMainMessageLoopStart(); |
| 746 } | 794 } |
| 747 | 795 |
| 748 void ChromeBrowserMainParts::PostMainMessageLoopStart() { | 796 void ChromeBrowserMainParts::PostMainMessageLoopStart() { |
| 749 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); | 797 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); |
| 750 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 798 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 751 chrome_extra_parts_[i]->PostMainMessageLoopStart(); | 799 chrome_extra_parts_[i]->PostMainMessageLoopStart(); |
| 752 #if defined(USE_X11) | |
| 753 SetBrowserX11ErrorHandlersPostMainMessageLoopStart(); | |
| 754 #endif | |
| 755 } | 800 } |
| 756 | 801 |
| 757 int ChromeBrowserMainParts::PreCreateThreads() { | 802 int ChromeBrowserMainParts::PreCreateThreads() { |
| 758 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); | 803 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); |
| 759 result_code_ = PreCreateThreadsImpl(); | 804 result_code_ = PreCreateThreadsImpl(); |
| 760 // These members must be initialized before returning from this function. | 805 // These members must be initialized before returning from this function. |
| 761 DCHECK(master_prefs_.get()); | 806 DCHECK(master_prefs_.get()); |
| 762 #if !defined(OS_ANDROID) | 807 #if !defined(OS_ANDROID) |
| 763 DCHECK(browser_creator_.get()); | 808 DCHECK(browser_creator_.get()); |
| 764 #endif | 809 #endif |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 | 1020 |
| 976 if (do_first_run_tasks_ || | 1021 if (do_first_run_tasks_ || |
| 977 parsed_command_line().HasSwitch(switches::kNoFirstRun)) { | 1022 parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
| 978 // Create the First Run sentinel whether first run tasks are executed | 1023 // Create the First Run sentinel whether first run tasks are executed |
| 979 // or not. | 1024 // or not. |
| 980 first_run::CreateSentinel(); | 1025 first_run::CreateSentinel(); |
| 981 } | 1026 } |
| 982 } | 1027 } |
| 983 #endif | 1028 #endif |
| 984 | 1029 |
| 985 // TODO(viettrungluu): why don't we run this earlier? | |
| 986 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) | |
| 987 WarnAboutMinimumSystemRequirements(); | |
| 988 | |
| 989 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) | 1030 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) |
| 990 // Set the product channel for crash reports. | 1031 // Set the product channel for crash reports. |
| 991 child_process_logging::SetChannel( | 1032 child_process_logging::SetChannel( |
| 992 chrome::VersionInfo::GetVersionStringModifier()); | 1033 chrome::VersionInfo::GetVersionStringModifier()); |
| 993 #endif | 1034 #endif |
| 994 | 1035 |
| 995 // Initialize tracking synchronizer system. | 1036 // Initialize tracking synchronizer system. |
| 996 tracking_synchronizer_ = new chrome_browser_metrics::TrackingSynchronizer(); | 1037 tracking_synchronizer_ = new chrome_browser_metrics::TrackingSynchronizer(); |
| 997 | 1038 |
| 998 // Now that all preferences have been registered, set the install date | 1039 // Now that all preferences have been registered, set the install date |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1423 | 1464 |
| 1424 #if defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD) | 1465 #if defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD) |
| 1425 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { | 1466 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { |
| 1426 base::FilePath path = | 1467 base::FilePath path = |
| 1427 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); | 1468 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); |
| 1428 printing::PrintedDocument::set_debug_dump_path(path); | 1469 printing::PrintedDocument::set_debug_dump_path(path); |
| 1429 } | 1470 } |
| 1430 #endif | 1471 #endif |
| 1431 | 1472 |
| 1432 HandleTestParameters(parsed_command_line()); | 1473 HandleTestParameters(parsed_command_line()); |
| 1433 RecordBreakpadStatusUMA(browser_process_->metrics_service()); | 1474 browser_process_->metrics_service()->RecordBreakpadHasDebugger( |
| 1475 base::debug::BeingDebugged()); | |
|
Nico
2013/07/10 17:32:50
On Mac and Linux, this used to call metrics->Recor
jam
2013/07/10 17:47:02
not quite. mac and linux used to do this as well,
| |
| 1476 | |
| 1434 #if defined(ENABLE_LANGUAGE_DETECTION) | 1477 #if defined(ENABLE_LANGUAGE_DETECTION) |
| 1435 LanguageUsageMetrics::RecordAcceptLanguages( | 1478 LanguageUsageMetrics::RecordAcceptLanguages( |
| 1436 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1479 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 1437 LanguageUsageMetrics::RecordApplicationLanguage( | 1480 LanguageUsageMetrics::RecordApplicationLanguage( |
| 1438 browser_process_->GetApplicationLocale()); | 1481 browser_process_->GetApplicationLocale()); |
| 1439 #endif | 1482 #endif |
| 1440 | 1483 |
| 1441 // The extension service may be available at this point. If the command line | 1484 // The extension service may be available at this point. If the command line |
| 1442 // specifies --uninstall-extension, attempt the uninstall extension startup | 1485 // specifies --uninstall-extension, attempt the uninstall extension startup |
| 1443 // action. | 1486 // action. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1455 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); | 1498 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
| 1456 | 1499 |
| 1457 // On mobile, need for clean shutdown arises only when the application comes | 1500 // On mobile, need for clean shutdown arises only when the application comes |
| 1458 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). | 1501 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). |
| 1459 // http://crbug.com/179143 | 1502 // http://crbug.com/179143 |
| 1460 #if !defined(OS_ANDROID) | 1503 #if !defined(OS_ANDROID) |
| 1461 // Start watching for a hang. | 1504 // Start watching for a hang. |
| 1462 MetricsService::LogNeedForCleanShutdown(); | 1505 MetricsService::LogNeedForCleanShutdown(); |
| 1463 #endif | 1506 #endif |
| 1464 | 1507 |
| 1465 #if defined(OS_WIN) | |
| 1466 // We check this here because if the profile is OTR (chromeos possibility) | |
| 1467 // it won't still be accessible after browser is destroyed. | |
| 1468 record_search_engine_ = do_first_run_tasks_ && !profile_->IsOffTheRecord(); | |
| 1469 #endif | |
| 1470 | |
| 1471 // Create the instance of the cloud print proxy service so that it can launch | 1508 // Create the instance of the cloud print proxy service so that it can launch |
| 1472 // the service process if needed. This is needed because the service process | 1509 // the service process if needed. This is needed because the service process |
| 1473 // might have shutdown because an update was available. | 1510 // might have shutdown because an update was available. |
| 1474 // TODO(torne): this should maybe be done with | 1511 // TODO(torne): this should maybe be done with |
| 1475 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() | 1512 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() |
| 1476 // instead? | 1513 // instead? |
| 1477 #if !defined(OS_ANDROID) | 1514 #if !defined(OS_ANDROID) |
| 1478 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1515 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
| 1479 #endif | 1516 #endif |
| 1480 | 1517 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 } | 1675 } |
| 1639 | 1676 |
| 1640 void ChromeBrowserMainParts::PostMainMessageLoopRun() { | 1677 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
| 1641 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); | 1678 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); |
| 1642 #if defined(OS_ANDROID) | 1679 #if defined(OS_ANDROID) |
| 1643 // Chrome on Android does not use default MessageLoop. It has its own | 1680 // Chrome on Android does not use default MessageLoop. It has its own |
| 1644 // Android specific MessageLoop | 1681 // Android specific MessageLoop |
| 1645 NOTREACHED(); | 1682 NOTREACHED(); |
| 1646 #else | 1683 #else |
| 1647 | 1684 |
| 1648 #if defined(USE_X11) | |
| 1649 // Unset the X11 error handlers. The X11 error handlers log the errors using a | |
| 1650 // |PostTask()| on the message-loop. But since the message-loop is in the | |
| 1651 // process of terminating, this can cause errors. | |
| 1652 UnsetBrowserX11ErrorHandlers(); | |
| 1653 #endif | |
| 1654 | |
| 1655 // Start watching for jank during shutdown. It gets disarmed when | 1685 // Start watching for jank during shutdown. It gets disarmed when |
| 1656 // |shutdown_watcher_| object is destructed. | 1686 // |shutdown_watcher_| object is destructed. |
| 1657 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); | 1687 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
| 1658 | 1688 |
| 1659 // Disarm the startup hang detector time bomb if it is still Arm'ed. | 1689 // Disarm the startup hang detector time bomb if it is still Arm'ed. |
| 1660 startup_watcher_->Disarm(); | 1690 startup_watcher_->Disarm(); |
| 1661 | 1691 |
| 1662 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1692 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1663 chrome_extra_parts_[i]->PostMainMessageLoopRun(); | 1693 chrome_extra_parts_[i]->PostMainMessageLoopRun(); |
| 1664 | 1694 |
| 1665 #if defined(OS_WIN) | |
| 1666 // Log the search engine chosen on first run. Do this at shutdown, after any | |
| 1667 // changes are made from the first run bubble link, etc. | |
| 1668 if (record_search_engine_) { | |
| 1669 TemplateURLService* url_service = | |
| 1670 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 1671 const TemplateURL* default_search_engine = | |
| 1672 url_service->GetDefaultSearchProvider(); | |
| 1673 // The default engine can be NULL if the administrator has disabled | |
| 1674 // default search. | |
| 1675 SearchEngineType search_engine_type = | |
| 1676 TemplateURLPrepopulateData::GetEngineType(default_search_engine ? | |
| 1677 default_search_engine->url() : std::string()); | |
| 1678 // Record the search engine chosen. | |
| 1679 UMA_HISTOGRAM_ENUMERATION("Chrome.SearchSelectExempt", search_engine_type, | |
| 1680 SEARCH_ENGINE_MAX); | |
| 1681 } | |
| 1682 #endif | |
| 1683 | |
| 1684 // Some tests don't set parameters.ui_task, so they started translate | 1695 // Some tests don't set parameters.ui_task, so they started translate |
| 1685 // language fetch that was never completed so we need to cleanup here | 1696 // language fetch that was never completed so we need to cleanup here |
| 1686 // otherwise it will be done by the destructor in a wrong thread. | 1697 // otherwise it will be done by the destructor in a wrong thread. |
| 1687 if (parameters().ui_task == NULL && translate_manager_ != NULL) | 1698 if (parameters().ui_task == NULL && translate_manager_ != NULL) |
| 1688 translate_manager_->CleanupPendingUlrFetcher(); | 1699 translate_manager_->CleanupPendingUlrFetcher(); |
| 1689 | 1700 |
| 1690 if (notify_result_ == ProcessSingleton::PROCESS_NONE) | 1701 if (notify_result_ == ProcessSingleton::PROCESS_NONE) |
| 1691 process_singleton_->Cleanup(); | 1702 process_singleton_->Cleanup(); |
| 1692 | 1703 |
| 1693 // Stop all tasks that might run on WatchDogThread. | 1704 // Stop all tasks that might run on WatchDogThread. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1725 chromeos::CrosSettings::Shutdown(); | 1736 chromeos::CrosSettings::Shutdown(); |
| 1726 #endif | 1737 #endif |
| 1727 #endif | 1738 #endif |
| 1728 } | 1739 } |
| 1729 | 1740 |
| 1730 // Public members: | 1741 // Public members: |
| 1731 | 1742 |
| 1732 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1743 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1733 chrome_extra_parts_.push_back(parts); | 1744 chrome_extra_parts_.push_back(parts); |
| 1734 } | 1745 } |
| 1735 | |
| 1736 // Misc ------------------------------------------------------------------------ | |
| 1737 | |
| 1738 void RecordBrowserStartupTime(bool is_first_run) { | |
| 1739 // Don't record any metrics if UI was displayed before this point e.g. | |
| 1740 // warning dialogs. | |
| 1741 if (startup_metric_utils::WasNonBrowserUIDisplayed()) | |
| 1742 return; | |
| 1743 | |
| 1744 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and | |
| 1745 // Windows. | |
| 1746 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 1747 const base::Time* process_creation_time = | |
| 1748 base::CurrentProcessInfo::CreationTime(); | |
| 1749 | |
| 1750 if (!is_first_run && process_creation_time) { | |
| 1751 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", | |
| 1752 base::Time::Now() - *process_creation_time); | |
| 1753 } | |
| 1754 #endif // defined(OS_MACOSX) || defined(OS_WIN) | |
| 1755 | |
| 1756 // Record collected startup metrics. | |
| 1757 startup_metric_utils::OnBrowserStartupComplete(is_first_run); | |
| 1758 | |
| 1759 // Deletes self. | |
| 1760 new LoadCompleteListener(); | |
| 1761 } | |
| 1762 | |
| 1763 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 1764 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { | |
| 1765 DCHECK(name != NULL); | |
| 1766 | |
| 1767 // This gets called with different histogram names, so we don't want to use | |
| 1768 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
| 1769 // first call wins. | |
| 1770 AddPreReadHistogramTime(name, time); | |
| 1771 | |
| 1772 #if defined(OS_WIN) | |
| 1773 #if defined(GOOGLE_CHROME_BUILD) | |
| 1774 // The pre-read experiment is Windows and Google Chrome specific. | |
| 1775 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 1776 | |
| 1777 // Only record the sub-histogram result if the experiment is running | |
| 1778 // (environment variable is set, and valid). | |
| 1779 std::string pre_read_percentage; | |
| 1780 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { | |
| 1781 std::string uma_name(name); | |
| 1782 | |
| 1783 // We want XP to record a separate histogram, as the loader on XP | |
| 1784 // is very different from the Vista and Win7 loaders. | |
| 1785 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
| 1786 uma_name += "_XP"; | |
| 1787 | |
| 1788 uma_name += "_PreRead_"; | |
| 1789 uma_name += pre_read_percentage; | |
| 1790 AddPreReadHistogramTime(uma_name.c_str(), time); | |
| 1791 } | |
| 1792 #endif | |
| 1793 #endif | |
| 1794 } | |
| OLD | NEW |