Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 8480032: Add ChromeBrowserMainExtraParts for non main parts. (take 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_extra_parts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_main_extra_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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } else { 552 } else {
552 if (!parsed_command_line.HasSwitch(switches::kTestName)) { 553 if (!parsed_command_line.HasSwitch(switches::kTestName)) {
553 // We did not log in (we crashed or are debugging), so we need to 554 // We did not log in (we crashed or are debugging), so we need to
554 // set the user name for sync. 555 // set the user name for sync.
555 chromeos::LoginUtils::Get()->RestoreAuthenticationSession( 556 chromeos::LoginUtils::Get()->RestoreAuthenticationSession(
556 chromeos::UserManager::Get()->logged_in_user().email(), profile); 557 chromeos::UserManager::Get()->logged_in_user().email(), profile);
557 } 558 }
558 } 559 }
559 } 560 }
560 561
561 #else
562
563 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line,
564 Profile* profile) {
565 // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below.
566 }
567
568 #endif // defined(OS_CHROMEOS) 562 #endif // defined(OS_CHROMEOS)
569 563
570 #if defined(OS_MACOSX) 564 #if defined(OS_MACOSX)
571 OSStatus KeychainCallback(SecKeychainEvent keychain_event, 565 OSStatus KeychainCallback(SecKeychainEvent keychain_event,
572 SecKeychainCallbackInfo *info, void *context) { 566 SecKeychainCallbackInfo *info, void *context) {
573 return noErr; 567 return noErr;
574 } 568 }
575 #endif 569 #endif
576 570
577 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) 571 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 translate_manager_(NULL), 672 translate_manager_(NULL),
679 profile_(NULL), 673 profile_(NULL),
680 run_message_loop_(true), 674 run_message_loop_(true),
681 notify_result_(ProcessSingleton::PROCESS_NONE) { 675 notify_result_(ProcessSingleton::PROCESS_NONE) {
682 // If we're running tests (ui_task is non-null). 676 // If we're running tests (ui_task is non-null).
683 if (parameters.ui_task) 677 if (parameters.ui_task)
684 browser_defaults::enable_help_app = false; 678 browser_defaults::enable_help_app = false;
685 } 679 }
686 680
687 ChromeBrowserMainParts::~ChromeBrowserMainParts() { 681 ChromeBrowserMainParts::~ChromeBrowserMainParts() {
682 for (int i = static_cast<int>(chrome_extra_parts_.size())-1; i >= 0; --i)
683 delete chrome_extra_parts_[i];
684 chrome_extra_parts_.clear();
688 } 685 }
689 686
690 // This will be called after the command-line has been mutated by about:flags 687 // This will be called after the command-line has been mutated by about:flags
691 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( 688 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials(
692 PrefService* local_state) { 689 PrefService* local_state) {
693 // Must initialize metrics after labs have been converted into switches, 690 // Must initialize metrics after labs have been converted into switches,
694 // but before field trials are set up (so that client ID is available for 691 // but before field trials are set up (so that client ID is available for
695 // one-time randomized field trials). 692 // one-time randomized field trials).
696 MetricsService* metrics = InitializeMetrics( 693 MetricsService* metrics = InitializeMetrics(
697 parsed_command_line_, local_state); 694 parsed_command_line_, local_state);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1156
1160 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { 1157 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
1161 // Need an instance of AtExitManager to handle singleton creations and 1158 // Need an instance of AtExitManager to handle singleton creations and
1162 // deletions. We need this new instance because, the old instance created 1159 // deletions. We need this new instance because, the old instance created
1163 // in ChromeMain() got destructed when the function returned. 1160 // in ChromeMain() got destructed when the function returned.
1164 base::AtExitManager exit_manager; 1161 base::AtExitManager exit_manager;
1165 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 1162 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
1166 } 1163 }
1167 #endif 1164 #endif
1168 1165
1166 // content::BrowserMainParts implementation ------------------------------------
1167
1169 void ChromeBrowserMainParts::PreEarlyInitialization() { 1168 void ChromeBrowserMainParts::PreEarlyInitialization() {
1169 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1170 chrome_extra_parts_[i]->PreEarlyInitialization();
1170 } 1171 }
1171 1172
1172 void ChromeBrowserMainParts::PostEarlyInitialization() { 1173 void ChromeBrowserMainParts::PostEarlyInitialization() {
1174 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1175 chrome_extra_parts_[i]->PostEarlyInitialization();
1173 } 1176 }
1174 1177
1175 void ChromeBrowserMainParts::ToolkitInitialized() { 1178 void ChromeBrowserMainParts::ToolkitInitialized() {
1179 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1180 chrome_extra_parts_[i]->ToolkitInitialized();
1176 } 1181 }
1177 1182
1178 void ChromeBrowserMainParts::PreMainMessageLoopStart() { 1183 void ChromeBrowserMainParts::PreMainMessageLoopStart() {
1184 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1185 chrome_extra_parts_[i]->PreMainMessageLoopStart();
1179 } 1186 }
1180 1187
1181 void ChromeBrowserMainParts::PostMainMessageLoopStart() { 1188 void ChromeBrowserMainParts::PostMainMessageLoopStart() {
1189 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1190 chrome_extra_parts_[i]->PostMainMessageLoopStart();
1182 } 1191 }
1183 1192
1184 void ChromeBrowserMainParts::PreMainMessageLoopRun() { 1193 void ChromeBrowserMainParts::PreMainMessageLoopRun() {
1185 result_code_ = PreMainMessageLoopRunImpl(); 1194 result_code_ = PreMainMessageLoopRunImpl();
1195
1196 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1197 chrome_extra_parts_[i]->PreMainMessageLoopRun();
1186 } 1198 }
1187 1199
1188 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { 1200 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
1189 run_message_loop_ = false; 1201 run_message_loop_ = false;
1190 FilePath user_data_dir; 1202 FilePath user_data_dir;
1191 #if defined(OS_WIN) 1203 #if defined(OS_WIN)
1192 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 1204 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
1193 #else 1205 #else
1194 // Getting the user data dir can fail if the directory isn't 1206 // Getting the user data dir can fail if the directory isn't
1195 // creatable, for example; on Windows in code below we bring up a 1207 // creatable, for example; on Windows in code below we bring up a
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 NOTREACHED(); 1501 NOTREACHED();
1490 } 1502 }
1491 #if !defined(OS_MACOSX) // closing brace for if 1503 #if !defined(OS_MACOSX) // closing brace for if
1492 } 1504 }
1493 #endif 1505 #endif
1494 1506
1495 #if defined(USE_X11) 1507 #if defined(USE_X11)
1496 SetBrowserX11ErrorHandlers(); 1508 SetBrowserX11ErrorHandlers();
1497 #endif 1509 #endif
1498 1510
1511 // Desktop construction occurs here, (required before profile creation).
1512 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1513 chrome_extra_parts_[i]->PostBrowserProcessInit();
1514
1499 // Profile creation ---------------------------------------------------------- 1515 // Profile creation ----------------------------------------------------------
1500 1516
1501 #if defined(OS_CHROMEOS) 1517 #if defined(OS_CHROMEOS)
1502 // Initialize the screen locker now so that it can receive 1518 // Initialize the screen locker now so that it can receive
1503 // LOGIN_USER_CHANGED notification from UserManager. 1519 // LOGIN_USER_CHANGED notification from UserManager.
1504 chromeos::ScreenLocker::InitClass(); 1520 chromeos::ScreenLocker::InitClass();
1505 1521
1506 // This forces the ProfileManager to be created and register for the 1522 // This forces the ProfileManager to be created and register for the
1507 // notification it needs to track the logged in user. 1523 // notification it needs to track the logged in user.
1508 g_browser_process->profile_manager(); 1524 g_browser_process->profile_manager();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 1570
1555 #if defined(OS_CHROMEOS) 1571 #if defined(OS_CHROMEOS)
1556 // Pass the TokenService pointer to the policy connector so user policy can 1572 // Pass the TokenService pointer to the policy connector so user policy can
1557 // grab a token and register with the policy server. 1573 // grab a token and register with the policy server.
1558 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. 1574 // TODO(mnissler): Remove once OAuth is the only authentication mechanism.
1559 if (parsed_command_line().HasSwitch(switches::kLoginUser) && 1575 if (parsed_command_line().HasSwitch(switches::kLoginUser) &&
1560 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { 1576 !parsed_command_line().HasSwitch(switches::kLoginPassword)) {
1561 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( 1577 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService(
1562 profile_->GetTokenService()); 1578 profile_->GetTokenService());
1563 } 1579 }
1580
1581 // Tests should be able to tune login manager before showing it.
1582 // Thus only show login manager in normal (non-testing) mode.
1583 if (!parameters().ui_task)
1584 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_);
1564 #endif 1585 #endif
1565 1586
1566 #if !defined(OS_MACOSX) 1587 #if !defined(OS_MACOSX)
1567 // Importing other browser settings is done in a browser-like process 1588 // Importing other browser settings is done in a browser-like process
1568 // that exits when this task has finished. 1589 // that exits when this task has finished.
1569 // TODO(port): Port the Mac's IPC-based implementation to other platforms to 1590 // TODO(port): Port the Mac's IPC-based implementation to other platforms to
1570 // replace this implementation. http://crbug.com/22142 1591 // replace this implementation. http://crbug.com/22142
1571 if (parsed_command_line().HasSwitch(switches::kImport) || 1592 if (parsed_command_line().HasSwitch(switches::kImport) ||
1572 parsed_command_line().HasSwitch(switches::kImportFromFile)) { 1593 parsed_command_line().HasSwitch(switches::kImportFromFile)) {
1573 return FirstRun::ImportNow(profile_, parsed_command_line()); 1594 return FirstRun::ImportNow(profile_, parsed_command_line());
(...skipping 28 matching lines...) Expand all
1602 // Disk image installation is sort of a first-run task, so it shares the 1623 // Disk image installation is sort of a first-run task, so it shares the
1603 // kNoFirstRun switch. 1624 // kNoFirstRun switch.
1604 if (MaybeInstallFromDiskImage()) { 1625 if (MaybeInstallFromDiskImage()) {
1605 // The application was installed and the installed copy has been 1626 // The application was installed and the installed copy has been
1606 // launched. This process is now obsolete. Exit. 1627 // launched. This process is now obsolete. Exit.
1607 return content::RESULT_CODE_NORMAL_EXIT; 1628 return content::RESULT_CODE_NORMAL_EXIT;
1608 } 1629 }
1609 } 1630 }
1610 #endif 1631 #endif
1611 1632
1633 // TODO(stevenjb): Move ChromeOS login code into PostProfileInitialized().
1634 // (Requires making ChromeBrowserMainPartsChromeos a non "main" Parts).
1635 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1636 chrome_extra_parts_[i]->PostProfileInitialized();
1637
1612 // Show the First Run UI if this is the first time Chrome has been run on 1638 // Show the First Run UI if this is the first time Chrome has been run on
1613 // this computer, or we're being compelled to do so by a command line flag. 1639 // this computer, or we're being compelled to do so by a command line flag.
1614 // Note that this be done _after_ the PrefService is initialized and all 1640 // Note that this be done _after_ the PrefService is initialized and all
1615 // preferences are registered, since some of the code that the importer 1641 // preferences are registered, since some of the code that the importer
1616 // touches reads preferences. 1642 // touches reads preferences.
1617 if (is_first_run) { 1643 if (is_first_run) {
1618 if (!first_run_ui_bypass) { 1644 if (!first_run_ui_bypass) {
1619 FirstRun::AutoImport(profile_, 1645 FirstRun::AutoImport(profile_,
1620 master_prefs_->homepage_defined, 1646 master_prefs_->homepage_defined,
1621 master_prefs_->do_import_items, 1647 master_prefs_->do_import_items,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 BrowserThread::FILE, FROM_HERE, 1853 BrowserThread::FILE, FROM_HERE,
1828 base::Bind(&GpuBlacklistUpdater::SetupOnFileThread)); 1854 base::Bind(&GpuBlacklistUpdater::SetupOnFileThread));
1829 1855
1830 // Start watching all browser threads for responsiveness. 1856 // Start watching all browser threads for responsiveness.
1831 ThreadWatcherList::StartWatchingAll(parsed_command_line()); 1857 ThreadWatcherList::StartWatchingAll(parsed_command_line());
1832 1858
1833 #if !defined(DISABLE_NACL) 1859 #if !defined(DISABLE_NACL)
1834 NaClProcessHost::EarlyStartup(); 1860 NaClProcessHost::EarlyStartup();
1835 #endif 1861 #endif
1836 1862
1837 run_message_loop_ = true;
1838 return content::RESULT_CODE_NORMAL_EXIT;
1839 }
1840
1841 // Called from MainMessageLoopRun().
1842 void ChromeBrowserMainParts::StartBrowserOrUITask() {
1843 // Still initializing, so need to allow IO.
1844 base::ThreadRestrictions::ScopedAllowIO allow_io;
1845
1846 // Tests should be able to tune login manager before showing it.
1847 // Thus only show login manager in normal (non-testing) mode.
1848 if (!parameters().ui_task)
1849 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_);
1850
1851 if (parameters().ui_task) { 1863 if (parameters().ui_task) {
1852 // We are in test mode. Run one task and enter the main message loop. 1864 // We are in test mode. Run one task and enter the main message loop.
1853 #if defined(OS_MACOSX) 1865 #if defined(OS_MACOSX)
1854 if (parameters().autorelease_pool) 1866 if (parameters().autorelease_pool)
1855 parameters().autorelease_pool->Recycle(); 1867 parameters().autorelease_pool->Recycle();
1856 #endif 1868 #endif
1857 parameters().ui_task->Run(); 1869 parameters().ui_task->Run();
1858 delete parameters().ui_task; 1870 delete parameters().ui_task;
1859 run_message_loop_ = false; 1871 run_message_loop_ = false;
1860 } else { 1872 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 profile_->GetPrefs()); 1922 profile_->GetPrefs());
1911 } 1923 }
1912 #endif 1924 #endif
1913 1925
1914 run_message_loop_ = true; 1926 run_message_loop_ = true;
1915 } else { 1927 } else {
1916 run_message_loop_ = false; 1928 run_message_loop_ = false;
1917 } 1929 }
1918 } 1930 }
1919 browser_init_.reset(); 1931 browser_init_.reset();
1932 return result_code_;
1920 } 1933 }
1921 1934
1922 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { 1935 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
1923 // Set the result code set in PreMainMessageLoopRun or set above. 1936 // Set the result code set in PreMainMessageLoopRun or set above.
1924 *result_code = result_code_; 1937 *result_code = result_code_;
1925 1938
1926 // TODO(stevenjb): Move this to another phase, and/or clean up
1927 // PreMainMessageLoopRun() so that this can happen after desktop
1928 // initilaization and before running the main loop.
1929 if (run_message_loop_)
1930 StartBrowserOrUITask();
1931
1932 if (!run_message_loop_) 1939 if (!run_message_loop_)
1933 return true; // Don't run the default message loop. 1940 return true; // Don't run the default message loop.
1934 1941
1935 // This should be invoked as close to the start of the browser's 1942 // This should be invoked as close to the start of the browser's
1936 // UI thread message loop as possible to get a stable measurement 1943 // UI thread message loop as possible to get a stable measurement
1937 // across versions. 1944 // across versions.
1938 RecordBrowserStartupTime(); 1945 RecordBrowserStartupTime();
1939 1946
1940 #if defined(USE_AURA) 1947 #if defined(USE_AURA)
1941 aura::Desktop::GetInstance()->Run(); 1948 aura::Desktop::GetInstance()->Run();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 browser_shutdown::Shutdown(); 2050 browser_shutdown::Shutdown();
2044 master_prefs_.reset(); 2051 master_prefs_.reset();
2045 process_singleton_.reset(); 2052 process_singleton_.reset();
2046 2053
2047 // We need to do this check as late as possible, but due to modularity, this 2054 // We need to do this check as late as possible, but due to modularity, this
2048 // may be the last point in Chrome. This would be more effective if done at 2055 // may be the last point in Chrome. This would be more effective if done at
2049 // a higher level on the stack, so that it is impossible for an early return 2056 // a higher level on the stack, so that it is impossible for an early return
2050 // to bypass this code. Perhaps we need a *final* hook that is called on all 2057 // to bypass this code. Perhaps we need a *final* hook that is called on all
2051 // paths from content/browser/browser_main. 2058 // paths from content/browser/browser_main.
2052 CHECK(MetricsService::UmaMetricsProperlyShutdown()); 2059 CHECK(MetricsService::UmaMetricsProperlyShutdown());
2060
2061 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
2062 chrome_extra_parts_[i]->PostMainMessageLoopRun();
2053 } 2063 }
2054 2064
2065 // Public members:
2066
2067 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
2068 chrome_extra_parts_.push_back(parts);
2069 }
2070
2071 // Misc ------------------------------------------------------------------------
2072
2055 // This code is specific to the Windows-only PreReadExperiment field-trial. 2073 // This code is specific to the Windows-only PreReadExperiment field-trial.
2056 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { 2074 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) {
2057 DCHECK(name != NULL); 2075 DCHECK(name != NULL);
2058 2076
2059 // This gets called with different histogram names, so we don't want to use 2077 // This gets called with different histogram names, so we don't want to use
2060 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the 2078 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the
2061 // first call wins. 2079 // first call wins.
2062 AddPreReadHistogramTime(name, time); 2080 AddPreReadHistogramTime(name, time);
2063 2081
2064 #if defined(OS_WIN) 2082 #if defined(OS_WIN)
2065 #if defined(GOOGLE_CHROME_BUILD) 2083 #if defined(GOOGLE_CHROME_BUILD)
2066 // The pre-read experiment is Windows and Google Chrome specific. 2084 // The pre-read experiment is Windows and Google Chrome specific.
2067 scoped_ptr<base::Environment> env(base::Environment::Create()); 2085 scoped_ptr<base::Environment> env(base::Environment::Create());
2068 2086
2069 // Only record the sub-histogram result if the experiment is running 2087 // Only record the sub-histogram result if the experiment is running
2070 // (environment variable is set, and valid). 2088 // (environment variable is set, and valid).
2071 std::string pre_read; 2089 std::string pre_read;
2072 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && 2090 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) &&
2073 (pre_read == "0" || pre_read == "1")) { 2091 (pre_read == "0" || pre_read == "1")) {
2074 std::string uma_name(name); 2092 std::string uma_name(name);
2075 uma_name += "_PreRead"; 2093 uma_name += "_PreRead";
2076 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; 2094 uma_name += pre_read == "1" ? "Enabled" : "Disabled";
2077 AddPreReadHistogramTime(uma_name.c_str(), time); 2095 AddPreReadHistogramTime(uma_name.c_str(), time);
2078 } 2096 }
2079 #endif 2097 #endif
2080 #endif 2098 #endif
2081 } 2099 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_extra_parts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698