Chromium Code Reviews| 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_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 14 matching lines...) Expand all Loading... | |
| 25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
| 26 #include "base/threading/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
| 27 #include "base/time.h" | 27 #include "base/time.h" |
| 28 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
| 29 #include "base/values.h" | 29 #include "base/values.h" |
| 30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "chrome/browser/about_flags.h" | 31 #include "chrome/browser/about_flags.h" |
| 32 #include "chrome/browser/background/background_mode_manager.h" | 32 #include "chrome/browser/background/background_mode_manager.h" |
| 33 #include "chrome/browser/browser_process_impl.h" | 33 #include "chrome/browser/browser_process_impl.h" |
| 34 #include "chrome/browser/browser_shutdown.h" | 34 #include "chrome/browser/browser_shutdown.h" |
| 35 #include "chrome/browser/chrome_browser_parts.h" | |
| 35 #include "chrome/browser/defaults.h" | 36 #include "chrome/browser/defaults.h" |
| 36 #include "chrome/browser/extensions/default_apps_trial.h" | 37 #include "chrome/browser/extensions/default_apps_trial.h" |
| 37 #include "chrome/browser/extensions/extension_protocols.h" | 38 #include "chrome/browser/extensions/extension_protocols.h" |
| 38 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
| 39 #include "chrome/browser/extensions/extensions_startup.h" | 40 #include "chrome/browser/extensions/extensions_startup.h" |
| 40 #include "chrome/browser/first_run/first_run_browser_process.h" | 41 #include "chrome/browser/first_run/first_run_browser_process.h" |
| 41 #include "chrome/browser/first_run/upgrade_util.h" | 42 #include "chrome/browser/first_run/upgrade_util.h" |
| 42 #include "chrome/browser/google/google_url_tracker.h" | 43 #include "chrome/browser/google/google_url_tracker.h" |
| 43 #include "chrome/browser/google/google_util.h" | 44 #include "chrome/browser/google/google_util.h" |
| 44 #include "chrome/browser/instant/instant_field_trial.h" | 45 #include "chrome/browser/instant/instant_field_trial.h" |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), | 549 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), |
| 549 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); | 550 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); |
| 550 } else { | 551 } else { |
| 551 // We did not log in (we crashed or are debugging), so we need to | 552 // We did not log in (we crashed or are debugging), so we need to |
| 552 // set the user name for sync. | 553 // set the user name for sync. |
| 553 profile->GetProfileSyncService( | 554 profile->GetProfileSyncService( |
| 554 chromeos::UserManager::Get()->logged_in_user().email()); | 555 chromeos::UserManager::Get()->logged_in_user().email()); |
| 555 } | 556 } |
| 556 } | 557 } |
| 557 | 558 |
| 558 #else | |
| 559 | |
| 560 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | |
| 561 Profile* profile) { | |
| 562 // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below. | |
| 563 } | |
| 564 | |
| 565 #endif // defined(OS_CHROMEOS) | 559 #endif // defined(OS_CHROMEOS) |
| 566 | 560 |
| 567 #if defined(OS_MACOSX) | 561 #if defined(OS_MACOSX) |
| 568 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 562 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
| 569 SecKeychainCallbackInfo *info, void *context) { | 563 SecKeychainCallbackInfo *info, void *context) { |
| 570 return noErr; | 564 return noErr; |
| 571 } | 565 } |
| 572 #endif | 566 #endif |
| 573 | 567 |
| 574 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) | 568 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 | 1150 |
| 1157 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 1151 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 1158 // Need an instance of AtExitManager to handle singleton creations and | 1152 // Need an instance of AtExitManager to handle singleton creations and |
| 1159 // deletions. We need this new instance because, the old instance created | 1153 // deletions. We need this new instance because, the old instance created |
| 1160 // in ChromeMain() got destructed when the function returned. | 1154 // in ChromeMain() got destructed when the function returned. |
| 1161 base::AtExitManager exit_manager; | 1155 base::AtExitManager exit_manager; |
| 1162 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 1156 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 1163 } | 1157 } |
| 1164 #endif | 1158 #endif |
| 1165 | 1159 |
| 1160 // content::BrowserMainParts implementation ------------------------------------ | |
| 1161 | |
| 1166 void ChromeBrowserMainParts::PreEarlyInitialization() { | 1162 void ChromeBrowserMainParts::PreEarlyInitialization() { |
| 1163 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1164 chrome_parts_[i]->PreEarlyInitialization(); | |
| 1167 } | 1165 } |
| 1168 | 1166 |
| 1169 void ChromeBrowserMainParts::PostEarlyInitialization() { | 1167 void ChromeBrowserMainParts::PostEarlyInitialization() { |
| 1168 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1169 chrome_parts_[i]->PostEarlyInitialization(); | |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 void ChromeBrowserMainParts::ToolkitInitialized() { | 1172 void ChromeBrowserMainParts::ToolkitInitialized() { |
| 1173 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1174 chrome_parts_[i]->ToolkitInitialized(); | |
| 1173 } | 1175 } |
| 1174 | 1176 |
| 1175 void ChromeBrowserMainParts::PreMainMessageLoopStart() { | 1177 void ChromeBrowserMainParts::PreMainMessageLoopStart() { |
| 1178 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1179 chrome_parts_[i]->PreMainMessageLoopStart(); | |
| 1176 } | 1180 } |
| 1177 | 1181 |
| 1178 void ChromeBrowserMainParts::PostMainMessageLoopStart() { | 1182 void ChromeBrowserMainParts::PostMainMessageLoopStart() { |
| 1183 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1184 chrome_parts_[i]->PostMainMessageLoopStart(); | |
| 1179 } | 1185 } |
| 1180 | 1186 |
| 1181 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1187 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
| 1182 result_code_ = PreMainMessageLoopRunImpl(); | 1188 result_code_ = PreMainMessageLoopRunImpl(); |
| 1189 | |
| 1190 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1191 chrome_parts_[i]->PreMainMessageLoopRun(); | |
| 1183 } | 1192 } |
| 1184 | 1193 |
| 1185 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1194 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1186 run_message_loop_ = false; | 1195 run_message_loop_ = false; |
| 1187 FilePath user_data_dir; | 1196 FilePath user_data_dir; |
| 1188 #if defined(OS_WIN) | 1197 #if defined(OS_WIN) |
| 1189 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 1198 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 1190 #else | 1199 #else |
| 1191 // Getting the user data dir can fail if the directory isn't | 1200 // Getting the user data dir can fail if the directory isn't |
| 1192 // creatable, for example; on Windows in code below we bring up a | 1201 // creatable, for example; on Windows in code below we bring up a |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1500 NOTREACHED(); | 1509 NOTREACHED(); |
| 1501 } | 1510 } |
| 1502 #if !defined(OS_MACOSX) // closing brace for if | 1511 #if !defined(OS_MACOSX) // closing brace for if |
| 1503 } | 1512 } |
| 1504 #endif | 1513 #endif |
| 1505 | 1514 |
| 1506 #if defined(USE_X11) | 1515 #if defined(USE_X11) |
| 1507 SetBrowserX11ErrorHandlers(); | 1516 SetBrowserX11ErrorHandlers(); |
| 1508 #endif | 1517 #endif |
| 1509 | 1518 |
| 1519 // Desktop construction occurs here, (required before profile creation). | |
| 1520 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1521 chrome_parts_[i]->PostBrowserProcessInit(); | |
| 1522 | |
| 1510 // Profile creation ---------------------------------------------------------- | 1523 // Profile creation ---------------------------------------------------------- |
| 1511 | 1524 |
| 1512 #if defined(OS_CHROMEOS) | 1525 #if defined(OS_CHROMEOS) |
| 1513 // Initialize the screen locker now so that it can receive | 1526 // Initialize the screen locker now so that it can receive |
| 1514 // LOGIN_USER_CHANGED notification from UserManager. | 1527 // LOGIN_USER_CHANGED notification from UserManager. |
| 1515 chromeos::ScreenLocker::InitClass(); | 1528 chromeos::ScreenLocker::InitClass(); |
| 1516 | 1529 |
| 1517 // This forces the ProfileManager to be created and register for the | 1530 // This forces the ProfileManager to be created and register for the |
| 1518 // notification it needs to track the logged in user. | 1531 // notification it needs to track the logged in user. |
| 1519 g_browser_process->profile_manager(); | 1532 g_browser_process->profile_manager(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1565 | 1578 |
| 1566 #if defined(OS_CHROMEOS) | 1579 #if defined(OS_CHROMEOS) |
| 1567 // Pass the TokenService pointer to the policy connector so user policy can | 1580 // Pass the TokenService pointer to the policy connector so user policy can |
| 1568 // grab a token and register with the policy server. | 1581 // grab a token and register with the policy server. |
| 1569 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. | 1582 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. |
| 1570 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 1583 if (parsed_command_line().HasSwitch(switches::kLoginUser) && |
| 1571 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | 1584 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { |
| 1572 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( | 1585 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( |
| 1573 profile_->GetTokenService()); | 1586 profile_->GetTokenService()); |
| 1574 } | 1587 } |
| 1588 | |
| 1589 // Tests should be able to tune login manager before showing it. | |
| 1590 // Thus only show login manager in normal (non-testing) mode. | |
| 1591 if (!parameters().ui_task) | |
| 1592 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); | |
|
stevenjb
2011/11/12 03:10:16
Note: This is exactly where this code used to be b
| |
| 1575 #endif | 1593 #endif |
| 1576 | 1594 |
| 1577 #if !defined(OS_MACOSX) | 1595 #if !defined(OS_MACOSX) |
| 1578 // Importing other browser settings is done in a browser-like process | 1596 // Importing other browser settings is done in a browser-like process |
| 1579 // that exits when this task has finished. | 1597 // that exits when this task has finished. |
| 1580 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | 1598 // TODO(port): Port the Mac's IPC-based implementation to other platforms to |
| 1581 // replace this implementation. http://crbug.com/22142 | 1599 // replace this implementation. http://crbug.com/22142 |
| 1582 if (parsed_command_line().HasSwitch(switches::kImport) || | 1600 if (parsed_command_line().HasSwitch(switches::kImport) || |
| 1583 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1601 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
| 1584 return FirstRun::ImportNow(profile_, parsed_command_line()); | 1602 return FirstRun::ImportNow(profile_, parsed_command_line()); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1613 // Disk image installation is sort of a first-run task, so it shares the | 1631 // Disk image installation is sort of a first-run task, so it shares the |
| 1614 // kNoFirstRun switch. | 1632 // kNoFirstRun switch. |
| 1615 if (MaybeInstallFromDiskImage()) { | 1633 if (MaybeInstallFromDiskImage()) { |
| 1616 // The application was installed and the installed copy has been | 1634 // The application was installed and the installed copy has been |
| 1617 // launched. This process is now obsolete. Exit. | 1635 // launched. This process is now obsolete. Exit. |
| 1618 return content::RESULT_CODE_NORMAL_EXIT; | 1636 return content::RESULT_CODE_NORMAL_EXIT; |
| 1619 } | 1637 } |
| 1620 } | 1638 } |
| 1621 #endif | 1639 #endif |
| 1622 | 1640 |
| 1641 // TODO(stevenjb): Move ChromeOS login code into PostProfileInitialized(). | |
| 1642 // (Requires making ChromeBrowserMainPartsChromeos a non "main" Parts). | |
| 1643 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 1644 chrome_parts_[i]->PostProfileInitialized(); | |
| 1645 | |
| 1623 // Show the First Run UI if this is the first time Chrome has been run on | 1646 // Show the First Run UI if this is the first time Chrome has been run on |
| 1624 // this computer, or we're being compelled to do so by a command line flag. | 1647 // this computer, or we're being compelled to do so by a command line flag. |
| 1625 // Note that this be done _after_ the PrefService is initialized and all | 1648 // Note that this be done _after_ the PrefService is initialized and all |
| 1626 // preferences are registered, since some of the code that the importer | 1649 // preferences are registered, since some of the code that the importer |
| 1627 // touches reads preferences. | 1650 // touches reads preferences. |
| 1628 if (is_first_run) { | 1651 if (is_first_run) { |
| 1629 if (!first_run_ui_bypass) { | 1652 if (!first_run_ui_bypass) { |
| 1630 FirstRun::AutoImport(profile_, | 1653 FirstRun::AutoImport(profile_, |
| 1631 master_prefs_->homepage_defined, | 1654 master_prefs_->homepage_defined, |
| 1632 master_prefs_->do_import_items, | 1655 master_prefs_->do_import_items, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1834 | 1857 |
| 1835 // Initialize GpuDataManager and collect preliminary gpu info on FILE thread. | 1858 // Initialize GpuDataManager and collect preliminary gpu info on FILE thread. |
| 1836 // Upon completion, it posts GpuBlacklist auto update task on UI thread. | 1859 // Upon completion, it posts GpuBlacklist auto update task on UI thread. |
| 1837 BrowserThread::PostTask( | 1860 BrowserThread::PostTask( |
| 1838 BrowserThread::FILE, FROM_HERE, | 1861 BrowserThread::FILE, FROM_HERE, |
| 1839 base::Bind(&GpuBlacklistUpdater::SetupOnFileThread)); | 1862 base::Bind(&GpuBlacklistUpdater::SetupOnFileThread)); |
| 1840 | 1863 |
| 1841 // Start watching all browser threads for responsiveness. | 1864 // Start watching all browser threads for responsiveness. |
| 1842 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1865 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
| 1843 | 1866 |
| 1844 run_message_loop_ = true; | |
| 1845 return content::RESULT_CODE_NORMAL_EXIT; | |
| 1846 } | |
| 1847 | |
| 1848 // Called from MainMessageLoopRun(). | |
| 1849 void ChromeBrowserMainParts::StartBrowserOrUITask() { | |
| 1850 // Still initializing, so need to allow IO. | |
| 1851 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 1852 | |
| 1853 // Set the notification UI manager after any desktop initialization in | |
| 1854 // PreMainMessageLoopRun() is complete, and before starting the browser. | |
| 1855 DesktopNotificationServiceFactory::GetForProfile(profile_)->SetUIManager( | |
| 1856 g_browser_process->notification_ui_manager()); | |
| 1857 | |
| 1858 // Tests should be able to tune login manager before showing it. | |
| 1859 // Thus only show login manager in normal (non-testing) mode. | |
| 1860 if (!parameters().ui_task) | |
| 1861 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); | |
|
stevenjb
2011/11/12 03:10:16
No longer necessary to split this function or derf
| |
| 1862 | |
| 1863 if (parameters().ui_task) { | 1867 if (parameters().ui_task) { |
| 1864 // We are in test mode. Run one task and enter the main message loop. | 1868 // We are in test mode. Run one task and enter the main message loop. |
| 1865 #if defined(OS_MACOSX) | 1869 #if defined(OS_MACOSX) |
| 1866 if (parameters().autorelease_pool) | 1870 if (parameters().autorelease_pool) |
| 1867 parameters().autorelease_pool->Recycle(); | 1871 parameters().autorelease_pool->Recycle(); |
| 1868 #endif | 1872 #endif |
| 1869 parameters().ui_task->Run(); | 1873 parameters().ui_task->Run(); |
| 1870 delete parameters().ui_task; | 1874 delete parameters().ui_task; |
| 1871 run_message_loop_ = false; | 1875 run_message_loop_ = false; |
| 1872 } else { | 1876 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1922 profile_->GetPrefs()); | 1926 profile_->GetPrefs()); |
| 1923 } | 1927 } |
| 1924 #endif | 1928 #endif |
| 1925 | 1929 |
| 1926 run_message_loop_ = true; | 1930 run_message_loop_ = true; |
| 1927 } else { | 1931 } else { |
| 1928 run_message_loop_ = false; | 1932 run_message_loop_ = false; |
| 1929 } | 1933 } |
| 1930 } | 1934 } |
| 1931 browser_init_.reset(); | 1935 browser_init_.reset(); |
| 1936 return result_code_; | |
| 1932 } | 1937 } |
| 1933 | 1938 |
| 1934 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { | 1939 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 1935 // Set the result code set in PreMainMessageLoopRun or set above. | 1940 // Set the result code set in PreMainMessageLoopRun or set above. |
| 1936 *result_code = result_code_; | 1941 *result_code = result_code_; |
| 1937 | 1942 |
| 1938 // TODO(stevenjb): Move this to another phase, and/or clean up | |
| 1939 // PreMainMessageLoopRun() so that this can happen after desktop | |
| 1940 // initilaization and before running the main loop. | |
| 1941 if (run_message_loop_) | |
| 1942 StartBrowserOrUITask(); | |
| 1943 | |
| 1944 if (!run_message_loop_) | 1943 if (!run_message_loop_) |
| 1945 return true; // Don't run the default message loop. | 1944 return true; // Don't run the default message loop. |
| 1946 | 1945 |
| 1947 // This should be invoked as close to the start of the browser's | 1946 // This should be invoked as close to the start of the browser's |
| 1948 // UI thread message loop as possible to get a stable measurement | 1947 // UI thread message loop as possible to get a stable measurement |
| 1949 // across versions. | 1948 // across versions. |
| 1950 RecordBrowserStartupTime(); | 1949 RecordBrowserStartupTime(); |
| 1951 | 1950 |
| 1952 #if defined(USE_AURA) | 1951 #if defined(USE_AURA) |
| 1953 aura::Desktop::GetInstance()->Run(); | 1952 aura::Desktop::GetInstance()->Run(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 browser_shutdown::Shutdown(); | 2054 browser_shutdown::Shutdown(); |
| 2056 master_prefs_.reset(); | 2055 master_prefs_.reset(); |
| 2057 process_singleton_.reset(); | 2056 process_singleton_.reset(); |
| 2058 | 2057 |
| 2059 // We need to do this check as late as possible, but due to modularity, this | 2058 // We need to do this check as late as possible, but due to modularity, this |
| 2060 // may be the last point in Chrome. This would be more effective if done at | 2059 // may be the last point in Chrome. This would be more effective if done at |
| 2061 // a higher level on the stack, so that it is impossible for an early return | 2060 // a higher level on the stack, so that it is impossible for an early return |
| 2062 // to bypass this code. Perhaps we need a *final* hook that is called on all | 2061 // to bypass this code. Perhaps we need a *final* hook that is called on all |
| 2063 // paths from content/browser/browser_main. | 2062 // paths from content/browser/browser_main. |
| 2064 CHECK(MetricsService::UmaMetricsProperlyShutdown()); | 2063 CHECK(MetricsService::UmaMetricsProperlyShutdown()); |
| 2064 | |
| 2065 for (size_t i = 0; i < chrome_parts_.size(); ++i) | |
| 2066 chrome_parts_[i]->PostMainMessageLoopRun(); | |
| 2065 } | 2067 } |
| 2066 | 2068 |
| 2069 // Public members: | |
| 2070 | |
| 2071 void ChromeBrowserMainParts::AddParts(ChromeBrowserParts* parts) { | |
| 2072 chrome_parts_.push_back(parts); | |
| 2073 } | |
| 2074 | |
| 2075 // Misc ------------------------------------------------------------------------ | |
| 2076 | |
| 2067 // This code is specific to the Windows-only PreReadExperiment field-trial. | 2077 // This code is specific to the Windows-only PreReadExperiment field-trial. |
| 2068 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { | 2078 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
| 2069 DCHECK(name != NULL); | 2079 DCHECK(name != NULL); |
| 2070 | 2080 |
| 2071 // This gets called with different histogram names, so we don't want to use | 2081 // This gets called with different histogram names, so we don't want to use |
| 2072 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | 2082 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the |
| 2073 // first call wins. | 2083 // first call wins. |
| 2074 AddPreReadHistogramTime(name, time); | 2084 AddPreReadHistogramTime(name, time); |
| 2075 | 2085 |
| 2076 #if defined(OS_WIN) | 2086 #if defined(OS_WIN) |
| 2077 #if defined(GOOGLE_CHROME_BUILD) | 2087 #if defined(GOOGLE_CHROME_BUILD) |
| 2078 // The pre-read experiment is Windows and Google Chrome specific. | 2088 // The pre-read experiment is Windows and Google Chrome specific. |
| 2079 scoped_ptr<base::Environment> env(base::Environment::Create()); | 2089 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 2080 | 2090 |
| 2081 // Only record the sub-histogram result if the experiment is running | 2091 // Only record the sub-histogram result if the experiment is running |
| 2082 // (environment variable is set, and valid). | 2092 // (environment variable is set, and valid). |
| 2083 std::string pre_read; | 2093 std::string pre_read; |
| 2084 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2094 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2085 (pre_read == "0" || pre_read == "1")) { | 2095 (pre_read == "0" || pre_read == "1")) { |
| 2086 std::string uma_name(name); | 2096 std::string uma_name(name); |
| 2087 uma_name += "_PreRead"; | 2097 uma_name += "_PreRead"; |
| 2088 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2098 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2089 AddPreReadHistogramTime(uma_name.c_str(), time); | 2099 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2090 } | 2100 } |
| 2091 #endif | 2101 #endif |
| 2092 #endif | 2102 #endif |
| 2093 } | 2103 } |
| OLD | NEW |