| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_main.h" | 5 #include "chrome/browser/browser_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 #if defined(OS_CHROMEOS) | 624 #if defined(OS_CHROMEOS) |
| 625 // Test loading libcros and exit. We return 0 if the library could be loaded, | 625 // Test loading libcros and exit. We return 0 if the library could be loaded, |
| 626 // and 1 if it can't be. This is for validation that the library is installed | 626 // and 1 if it can't be. This is for validation that the library is installed |
| 627 // and versioned properly for Chrome to find. | 627 // and versioned properly for Chrome to find. |
| 628 if (command_line.HasSwitch(switches::kTestLoadLibcros)) | 628 if (command_line.HasSwitch(switches::kTestLoadLibcros)) |
| 629 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); | 629 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 630 #endif | 630 #endif |
| 631 } | 631 } |
| 632 | 632 |
| 633 void RunUIMessageLoop(BrowserProcess* browser_process) { | 633 void RunUIMessageLoop(BrowserProcess* browser_process) { |
| 634 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 634 TRACE_EVENT_BEGIN("BrowserMain:MESSAGE_LOOP", 0, ""); |
| 635 // This should be invoked as close to the start of the browser's | 635 // This should be invoked as close to the start of the browser's |
| 636 // UI thread message loop as possible to get a stable measurement | 636 // UI thread message loop as possible to get a stable measurement |
| 637 // across versions. | 637 // across versions. |
| 638 RecordBrowserStartupTime(); | 638 RecordBrowserStartupTime(); |
| 639 | 639 |
| 640 // If the UI thread blocks, the whole UI is unresponsive. | 640 // If the UI thread blocks, the whole UI is unresponsive. |
| 641 // Do not allow disk IO from the UI thread. | 641 // Do not allow disk IO from the UI thread. |
| 642 base::ThreadRestrictions::SetIOAllowed(false); | 642 base::ThreadRestrictions::SetIOAllowed(false); |
| 643 | 643 |
| 644 #if defined(TOOLKIT_VIEWS) | 644 #if defined(TOOLKIT_VIEWS) |
| 645 views::AcceleratorHandler accelerator_handler; | 645 views::AcceleratorHandler accelerator_handler; |
| 646 MessageLoopForUI::current()->Run(&accelerator_handler); | 646 MessageLoopForUI::current()->Run(&accelerator_handler); |
| 647 #elif defined(USE_X11) | 647 #elif defined(USE_X11) |
| 648 MessageLoopForUI::current()->Run(NULL); | 648 MessageLoopForUI::current()->Run(NULL); |
| 649 #elif defined(OS_POSIX) | 649 #elif defined(OS_POSIX) |
| 650 MessageLoopForUI::current()->Run(); | 650 MessageLoopForUI::current()->Run(); |
| 651 #endif | 651 #endif |
| 652 #if defined(OS_CHROMEOS) | 652 #if defined(OS_CHROMEOS) |
| 653 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", | 653 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", |
| 654 true); | 654 true); |
| 655 #endif | 655 #endif |
| 656 | 656 |
| 657 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | 657 TRACE_EVENT_END("BrowserMain:MESSAGE_LOOP", 0, ""); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void AddFirstRunNewTabs(BrowserInit* browser_init, | 660 void AddFirstRunNewTabs(BrowserInit* browser_init, |
| 661 const std::vector<GURL>& new_tabs) { | 661 const std::vector<GURL>& new_tabs) { |
| 662 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); | 662 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); |
| 663 it != new_tabs.end(); ++it) { | 663 it != new_tabs.end(); ++it) { |
| 664 if (it->is_valid()) | 664 if (it->is_valid()) |
| 665 browser_init->AddFirstRunTab(*it); | 665 browser_init->AddFirstRunTab(*it); |
| 666 } | 666 } |
| 667 } | 667 } |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 1138 local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
| 1139 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) | 1139 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) |
| 1140 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 1140 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
| 1141 #endif // #if defined(OS_CHROMEOS) | 1141 #endif // #if defined(OS_CHROMEOS) |
| 1142 return breakpad_enabled; | 1142 return breakpad_enabled; |
| 1143 } | 1143 } |
| 1144 #endif // #if defined(USE_LINUX_BREAKPAD) | 1144 #endif // #if defined(USE_LINUX_BREAKPAD) |
| 1145 | 1145 |
| 1146 // Main routine for running as the Browser process. | 1146 // Main routine for running as the Browser process. |
| 1147 int BrowserMain(const MainFunctionParams& parameters) { | 1147 int BrowserMain(const MainFunctionParams& parameters) { |
| 1148 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); | 1148 TRACE_EVENT_BEGIN("BrowserMain", 0, ""); |
| 1149 | 1149 |
| 1150 // If we're running tests (ui_task is non-null). | 1150 // If we're running tests (ui_task is non-null). |
| 1151 if (parameters.ui_task) | 1151 if (parameters.ui_task) |
| 1152 browser_defaults::enable_help_app = false; | 1152 browser_defaults::enable_help_app = false; |
| 1153 | 1153 |
| 1154 scoped_ptr<BrowserMainParts> | 1154 scoped_ptr<BrowserMainParts> |
| 1155 parts(BrowserMainParts::CreateBrowserMainParts(parameters)); | 1155 parts(BrowserMainParts::CreateBrowserMainParts(parameters)); |
| 1156 | 1156 |
| 1157 parts->EarlyInitialization(); | 1157 parts->EarlyInitialization(); |
| 1158 | 1158 |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 ignore_result(browser_process.release()); | 1921 ignore_result(browser_process.release()); |
| 1922 browser_shutdown::Shutdown(); | 1922 browser_shutdown::Shutdown(); |
| 1923 | 1923 |
| 1924 #if defined(OS_CHROMEOS) | 1924 #if defined(OS_CHROMEOS) |
| 1925 // To be precise, logout (browser shutdown) is not yet done, but the | 1925 // To be precise, logout (browser shutdown) is not yet done, but the |
| 1926 // remaining work is negligible, hence we say LogoutDone here. | 1926 // remaining work is negligible, hence we say LogoutDone here. |
| 1927 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 1927 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 1928 false); | 1928 false); |
| 1929 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 1929 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 1930 #endif | 1930 #endif |
| 1931 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 1931 TRACE_EVENT_END("BrowserMain", 0, 0); |
| 1932 return result_code; | 1932 return result_code; |
| 1933 } | 1933 } |
| OLD | NEW |