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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 #if defined(OS_CHROMEOS) | 557 #if defined(OS_CHROMEOS) |
558 // Test loading libcros and exit. We return 0 if the library could be loaded, | 558 // Test loading libcros and exit. We return 0 if the library could be loaded, |
559 // and 1 if it can't be. This is for validation that the library is installed | 559 // and 1 if it can't be. This is for validation that the library is installed |
560 // and versioned properly for Chrome to find. | 560 // and versioned properly for Chrome to find. |
561 if (command_line.HasSwitch(switches::kTestLoadLibcros)) | 561 if (command_line.HasSwitch(switches::kTestLoadLibcros)) |
562 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); | 562 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); |
563 #endif | 563 #endif |
564 } | 564 } |
565 | 565 |
566 void RunUIMessageLoop(BrowserProcess* browser_process) { | 566 void RunUIMessageLoop(BrowserProcess* browser_process) { |
567 TRACE_EVENT_BEGIN("BrowserMain:MESSAGE_LOOP", 0, ""); | 567 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
568 // This should be invoked as close to the start of the browser's | 568 // This should be invoked as close to the start of the browser's |
569 // UI thread message loop as possible to get a stable measurement | 569 // UI thread message loop as possible to get a stable measurement |
570 // across versions. | 570 // across versions. |
571 RecordBrowserStartupTime(); | 571 RecordBrowserStartupTime(); |
572 | 572 |
573 // If the UI thread blocks, the whole UI is unresponsive. | 573 // If the UI thread blocks, the whole UI is unresponsive. |
574 // Do not allow disk IO from the UI thread. | 574 // Do not allow disk IO from the UI thread. |
575 base::ThreadRestrictions::SetIOAllowed(false); | 575 base::ThreadRestrictions::SetIOAllowed(false); |
576 | 576 |
577 #if defined(TOOLKIT_VIEWS) | 577 #if defined(TOOLKIT_VIEWS) |
578 views::AcceleratorHandler accelerator_handler; | 578 views::AcceleratorHandler accelerator_handler; |
579 MessageLoopForUI::current()->Run(&accelerator_handler); | 579 MessageLoopForUI::current()->Run(&accelerator_handler); |
580 #elif defined(USE_X11) | 580 #elif defined(USE_X11) |
581 MessageLoopForUI::current()->Run(NULL); | 581 MessageLoopForUI::current()->Run(NULL); |
582 #elif defined(OS_POSIX) | 582 #elif defined(OS_POSIX) |
583 MessageLoopForUI::current()->Run(); | 583 MessageLoopForUI::current()->Run(); |
584 #endif | 584 #endif |
585 #if defined(OS_CHROMEOS) | 585 #if defined(OS_CHROMEOS) |
586 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", | 586 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", |
587 true); | 587 true); |
588 #endif | 588 #endif |
589 | 589 |
590 TRACE_EVENT_END("BrowserMain:MESSAGE_LOOP", 0, ""); | 590 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); |
591 } | 591 } |
592 | 592 |
593 void AddFirstRunNewTabs(BrowserInit* browser_init, | 593 void AddFirstRunNewTabs(BrowserInit* browser_init, |
594 const std::vector<GURL>& new_tabs) { | 594 const std::vector<GURL>& new_tabs) { |
595 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); | 595 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); |
596 it != new_tabs.end(); ++it) { | 596 it != new_tabs.end(); ++it) { |
597 if (it->is_valid()) | 597 if (it->is_valid()) |
598 browser_init->AddFirstRunTab(*it); | 598 browser_init->AddFirstRunTab(*it); |
599 } | 599 } |
600 } | 600 } |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 1110 local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
1111 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) | 1111 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) |
1112 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 1112 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
1113 #endif // #if defined(OS_CHROMEOS) | 1113 #endif // #if defined(OS_CHROMEOS) |
1114 return breakpad_enabled; | 1114 return breakpad_enabled; |
1115 } | 1115 } |
1116 #endif // #if defined(USE_LINUX_BREAKPAD) | 1116 #endif // #if defined(USE_LINUX_BREAKPAD) |
1117 | 1117 |
1118 // Main routine for running as the Browser process. | 1118 // Main routine for running as the Browser process. |
1119 int BrowserMain(const MainFunctionParams& parameters) { | 1119 int BrowserMain(const MainFunctionParams& parameters) { |
1120 TRACE_EVENT_BEGIN("BrowserMain", 0, ""); | 1120 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); |
1121 | 1121 |
1122 // If we're running tests (ui_task is non-null). | 1122 // If we're running tests (ui_task is non-null). |
1123 if (parameters.ui_task) | 1123 if (parameters.ui_task) |
1124 browser_defaults::enable_help_app = false; | 1124 browser_defaults::enable_help_app = false; |
1125 | 1125 |
1126 scoped_ptr<BrowserMainParts> | 1126 scoped_ptr<BrowserMainParts> |
1127 parts(BrowserMainParts::CreateBrowserMainParts(parameters)); | 1127 parts(BrowserMainParts::CreateBrowserMainParts(parameters)); |
1128 | 1128 |
1129 parts->EarlyInitialization(); | 1129 parts->EarlyInitialization(); |
1130 | 1130 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 ignore_result(browser_process.release()); | 1895 ignore_result(browser_process.release()); |
1896 browser_shutdown::Shutdown(); | 1896 browser_shutdown::Shutdown(); |
1897 | 1897 |
1898 #if defined(OS_CHROMEOS) | 1898 #if defined(OS_CHROMEOS) |
1899 // To be precise, logout (browser shutdown) is not yet done, but the | 1899 // To be precise, logout (browser shutdown) is not yet done, but the |
1900 // remaining work is negligible, hence we say LogoutDone here. | 1900 // remaining work is negligible, hence we say LogoutDone here. |
1901 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 1901 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
1902 false); | 1902 false); |
1903 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 1903 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
1904 #endif | 1904 #endif |
1905 TRACE_EVENT_END("BrowserMain", 0, 0); | 1905 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
1906 return result_code; | 1906 return result_code; |
1907 } | 1907 } |
OLD | NEW |