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 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1114 BrowserThread::UI, | 1114 BrowserThread::UI, |
| 1115 FROM_HERE, | 1115 FROM_HERE, |
| 1116 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), | 1116 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), |
| 1117 base::TimeDelta::FromMinutes(1)); | 1117 base::TimeDelta::FromMinutes(1)); |
| 1118 #endif | 1118 #endif |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1121 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1122 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); | 1122 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); |
| 1123 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); | 1123 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); |
| 1124 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); | |
| 1124 // Android updates the metrics service dynamically depending on whether the | 1125 // Android updates the metrics service dynamically depending on whether the |
| 1125 // application is in the foreground or not. Do not start here. | 1126 // application is in the foreground or not. Do not start here. |
| 1126 #if !defined(OS_ANDROID) | 1127 #if !defined(OS_ANDROID) |
| 1127 // Now that the file thread has been started, start recording. | 1128 // Now that the file thread has been started, start recording. |
| 1128 StartMetricsRecording(); | 1129 StartMetricsRecording(); |
| 1129 #endif | 1130 #endif // !defined(OS_ANDROID) |
| 1130 | 1131 |
| 1131 if (!base::debug::BeingDebugged()) { | 1132 if (!base::debug::BeingDebugged()) { |
| 1132 // Create watchdog thread after creating all other threads because it will | 1133 // Create watchdog thread after creating all other threads because it will |
| 1133 // watch the other threads and they must be running. | 1134 // watch the other threads and they must be running. |
| 1134 browser_process_->watchdog_thread(); | 1135 browser_process_->watchdog_thread(); |
| 1135 } | 1136 } |
| 1136 | 1137 |
| 1137 // Do any initializating in the browser process that requires all threads | 1138 // Do any initializating in the browser process that requires all threads |
| 1138 // running. | 1139 // running. |
| 1139 browser_process_->PreMainMessageLoopRun(); | 1140 browser_process_->PreMainMessageLoopRun(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 if (parsed_command_line().HasSwitch(switches::kHideIcons) || | 1157 if (parsed_command_line().HasSwitch(switches::kHideIcons) || |
| 1157 parsed_command_line().HasSwitch(switches::kShowIcons)) { | 1158 parsed_command_line().HasSwitch(switches::kShowIcons)) { |
| 1158 return ChromeBrowserMainPartsWin::HandleIconsCommands( | 1159 return ChromeBrowserMainPartsWin::HandleIconsCommands( |
| 1159 parsed_command_line_); | 1160 parsed_command_line_); |
| 1160 } | 1161 } |
| 1161 | 1162 |
| 1162 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( | 1163 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( |
| 1163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 1164 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 1164 #endif | 1165 #endif // OS_WIN |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
defined()
Lei Zhang
2015/03/02 22:22:29
nit: Please be consistent and add defined(). Ditto
| |
| 1165 | 1166 |
| 1166 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { | 1167 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { |
| 1167 return ShellIntegration::SetAsDefaultBrowser() ? | 1168 return ShellIntegration::SetAsDefaultBrowser() ? |
| 1168 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : | 1169 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : |
| 1169 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); | 1170 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); |
| 1170 } | 1171 } |
| 1171 | 1172 |
| 1172 #if defined(USE_AURA) | 1173 #if defined(USE_AURA) |
| 1173 // Make sure aura::Env has been initialized. | 1174 // Make sure aura::Env has been initialized. |
| 1174 CHECK(aura::Env::GetInstance()); | 1175 CHECK(aura::Env::GetInstance()); |
| 1175 #endif | 1176 #endif // defined(USE_AURA) |
| 1176 | 1177 |
| 1177 // Android doesn't support extensions and doesn't implement ProcessSingleton. | 1178 // Android doesn't support extensions and doesn't implement ProcessSingleton. |
| 1178 #if !defined(OS_ANDROID) | 1179 #if !defined(OS_ANDROID) |
| 1179 // If the command line specifies --pack-extension, attempt the pack extension | 1180 // If the command line specifies --pack-extension, attempt the pack extension |
| 1180 // startup action and exit. | 1181 // startup action and exit. |
| 1181 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1182 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
| 1182 extensions::StartupHelper extension_startup_helper; | 1183 extensions::StartupHelper extension_startup_helper; |
| 1183 if (extension_startup_helper.PackExtension(parsed_command_line())) | 1184 if (extension_startup_helper.PackExtension(parsed_command_line())) |
| 1184 return content::RESULT_CODE_NORMAL_EXIT; | 1185 return content::RESULT_CODE_NORMAL_EXIT; |
| 1185 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1186 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1198 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1199 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
| 1199 switch (notify_result_) { | 1200 switch (notify_result_) { |
| 1200 case ProcessSingleton::PROCESS_NONE: | 1201 case ProcessSingleton::PROCESS_NONE: |
| 1201 // No process already running, fall through to starting a new one. | 1202 // No process already running, fall through to starting a new one. |
| 1202 break; | 1203 break; |
| 1203 | 1204 |
| 1204 case ProcessSingleton::PROCESS_NOTIFIED: | 1205 case ProcessSingleton::PROCESS_NOTIFIED: |
| 1205 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1206 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1206 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( | 1207 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( |
| 1207 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1208 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
| 1208 #endif | 1209 #endif // OS_POSIX && !defined(OS_MACOSX) |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
Nit: defined(OS_POSIX) && !defined(OS_MACOSX)
#if
| |
| 1210 | |
| 1209 // Having a differentiated return type for testing allows for tests to | 1211 // Having a differentiated return type for testing allows for tests to |
| 1210 // verify proper handling of some switches. When not testing, stick to | 1212 // verify proper handling of some switches. When not testing, stick to |
| 1211 // the standard Unix convention of returning zero when things went as | 1213 // the standard Unix convention of returning zero when things went as |
| 1212 // expected. | 1214 // expected. |
| 1213 if (parsed_command_line().HasSwitch(switches::kTestType)) | 1215 if (parsed_command_line().HasSwitch(switches::kTestType)) |
| 1214 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; | 1216 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; |
| 1215 return content::RESULT_CODE_NORMAL_EXIT; | 1217 return content::RESULT_CODE_NORMAL_EXIT; |
| 1216 | 1218 |
| 1217 case ProcessSingleton::PROFILE_IN_USE: | 1219 case ProcessSingleton::PROFILE_IN_USE: |
| 1218 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1220 return chrome::RESULT_CODE_PROFILE_IN_USE; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1255 // At this point the user is willing to try chrome again. | 1257 // At this point the user is willing to try chrome again. |
| 1256 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { | 1258 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { |
| 1257 // Only set in the unattended case, the interactive case is Windows 8. | 1259 // Only set in the unattended case, the interactive case is Windows 8. |
| 1258 if (ShellIntegration::CanSetAsDefaultBrowser() == | 1260 if (ShellIntegration::CanSetAsDefaultBrowser() == |
| 1259 ShellIntegration::SET_DEFAULT_UNATTENDED) | 1261 ShellIntegration::SET_DEFAULT_UNATTENDED) |
| 1260 ShellIntegration::SetAsDefaultBrowser(); | 1262 ShellIntegration::SetAsDefaultBrowser(); |
| 1261 } | 1263 } |
| 1262 #else | 1264 #else |
| 1263 // We don't support retention experiments on Mac or Linux. | 1265 // We don't support retention experiments on Mac or Linux. |
| 1264 return content::RESULT_CODE_NORMAL_EXIT; | 1266 return content::RESULT_CODE_NORMAL_EXIT; |
| 1265 #endif // defined(OS_WIN) | 1267 #endif // OS_WIN |
| 1266 } | 1268 } |
| 1267 | 1269 |
| 1268 #if defined(OS_WIN) | 1270 #if defined(OS_WIN) |
| 1269 // Do the tasks if chrome has been upgraded while it was last running. | 1271 // Do the tasks if chrome has been upgraded while it was last running. |
| 1270 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) | 1272 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) |
| 1271 return content::RESULT_CODE_NORMAL_EXIT; | 1273 return content::RESULT_CODE_NORMAL_EXIT; |
| 1272 | 1274 |
| 1273 // Check if there is any machine level Chrome installed on the current | 1275 // Check if there is any machine level Chrome installed on the current |
| 1274 // machine. If yes and the current Chrome process is user level, we do not | 1276 // machine. If yes and the current Chrome process is user level, we do not |
| 1275 // allow the user level Chrome to run. So we notify the user and uninstall | 1277 // allow the user level Chrome to run. So we notify the user and uninstall |
| 1276 // user level Chrome. | 1278 // user level Chrome. |
| 1277 // Note this check needs to happen here (after the process singleton was | 1279 // Note this check needs to happen here (after the process singleton was |
| 1278 // obtained but before potentially creating the first run sentinel). | 1280 // obtained but before potentially creating the first run sentinel). |
| 1279 if (ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) | 1281 if (ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) |
| 1280 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; | 1282 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; |
| 1281 #endif // defined(OS_WIN) | 1283 #endif // OS_WIN |
| 1282 | 1284 |
| 1283 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1285 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1284 if (sxs_linux::ShouldMigrateUserDataDir()) | 1286 if (sxs_linux::ShouldMigrateUserDataDir()) |
| 1285 return sxs_linux::MigrateUserDataDir(); | 1287 return sxs_linux::MigrateUserDataDir(); |
| 1286 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1288 #endif // OS_LINUX && !defined(OS_CHROMEOS) |
| 1287 | 1289 |
| 1288 // Desktop construction occurs here, (required before profile creation). | 1290 // Desktop construction occurs here, (required before profile creation). |
| 1289 PreProfileInit(); | 1291 PreProfileInit(); |
| 1290 | 1292 |
| 1291 // Profile creation ---------------------------------------------------------- | 1293 // Profile creation ---------------------------------------------------------- |
| 1292 | 1294 |
| 1293 metrics::MetricsService::SetExecutionPhase( | 1295 metrics::MetricsService::SetExecutionPhase( |
| 1294 metrics::MetricsService::CREATE_PROFILE, | 1296 metrics::MetricsService::CREATE_PROFILE, |
| 1295 g_browser_process->local_state()); | 1297 g_browser_process->local_state()); |
| 1298 | |
| 1299 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", | |
| 1300 base::TimeTicks::Now() - start_time_step1); | |
| 1301 | |
| 1302 // This step is costly and is already measured in Startup.CreateFirstProfile | |
| 1303 // and more directly Profile.CreateAndInitializeProfile. | |
| 1296 profile_ = CreatePrimaryProfile(parameters(), | 1304 profile_ = CreatePrimaryProfile(parameters(), |
| 1297 user_data_dir_, | 1305 user_data_dir_, |
| 1298 parsed_command_line()); | 1306 parsed_command_line()); |
| 1299 if (!profile_) | 1307 if (!profile_) |
| 1300 return content::RESULT_CODE_NORMAL_EXIT; | 1308 return content::RESULT_CODE_NORMAL_EXIT; |
| 1301 | 1309 |
| 1310 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); | |
| 1311 | |
| 1302 #if !defined(OS_ANDROID) | 1312 #if !defined(OS_ANDROID) |
| 1303 // The first run sentinel must be created after the process singleton was | 1313 // The first run sentinel must be created after the process singleton was |
| 1304 // grabbed and no early return paths were otherwise hit above. | 1314 // grabbed and no early return paths were otherwise hit above. |
| 1305 first_run::CreateSentinelIfNeeded(); | 1315 first_run::CreateSentinelIfNeeded(); |
| 1306 #endif // !defined(OS_ANDROID) | 1316 #endif // !defined(OS_ANDROID) |
| 1307 | 1317 |
| 1308 #if defined(ENABLE_BACKGROUND) | 1318 #if defined(ENABLE_BACKGROUND) |
| 1309 // Autoload any profiles which are running background apps. | 1319 // Autoload any profiles which are running background apps. |
| 1310 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1320 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
| 1311 browser_process_->profile_manager()->AutoloadProfiles(); | 1321 browser_process_->profile_manager()->AutoloadProfiles(); |
| 1312 #endif | 1322 #endif // ENABLE_BACKGROUND |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
defined()
| |
| 1313 // Post-profile init --------------------------------------------------------- | 1323 // Post-profile init --------------------------------------------------------- |
| 1314 | 1324 |
| 1315 TranslateService::Initialize(); | 1325 TranslateService::Initialize(); |
| 1316 | 1326 |
| 1317 // Needs to be done before PostProfileInit, since login manager on CrOS is | 1327 // Needs to be done before PostProfileInit, since login manager on CrOS is |
| 1318 // called inside PostProfileInit. | 1328 // called inside PostProfileInit. |
| 1319 content::WebUIControllerFactory::RegisterFactory( | 1329 content::WebUIControllerFactory::RegisterFactory( |
| 1320 ChromeWebUIControllerFactory::GetInstance()); | 1330 ChromeWebUIControllerFactory::GetInstance()); |
| 1321 | 1331 |
| 1322 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). | 1332 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). |
| 1323 // So make sure to create it before that. | 1333 // So make sure to create it before that. |
| 1324 #if !defined(DISABLE_NACL) | 1334 #if !defined(DISABLE_NACL) |
| 1325 NaClBrowserDelegateImpl* delegate = | 1335 NaClBrowserDelegateImpl* delegate = |
| 1326 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); | 1336 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); |
| 1327 nacl::NaClBrowser::SetDelegate(delegate); | 1337 nacl::NaClBrowser::SetDelegate(delegate); |
| 1328 #endif | 1338 #endif // !defined(DISABLE_NACL) |
| 1329 | 1339 |
| 1330 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. | 1340 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. |
| 1331 // (requires supporting early exit). | 1341 // (requires supporting early exit). |
| 1332 PostProfileInit(); | 1342 PostProfileInit(); |
| 1333 | 1343 |
| 1334 // Retrieve cached GL strings from local state and use them for GPU | 1344 // Retrieve cached GL strings from local state and use them for GPU |
| 1335 // blacklist decisions. | 1345 // blacklist decisions. |
| 1336 if (g_browser_process->gl_string_manager()) | 1346 if (g_browser_process->gl_string_manager()) |
| 1337 g_browser_process->gl_string_manager()->Initialize(); | 1347 g_browser_process->gl_string_manager()->Initialize(); |
| 1338 | 1348 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1396 // file thread to be run sometime later. If this is the first run we record | 1406 // file thread to be run sometime later. If this is the first run we record |
| 1397 // the installation event. | 1407 // the installation event. |
| 1398 PrefService* pref_service = profile_->GetPrefs(); | 1408 PrefService* pref_service = profile_->GetPrefs(); |
| 1399 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : | 1409 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : |
| 1400 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); | 1410 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); |
| 1401 // Negative ping delay means to send ping immediately after a first search is | 1411 // Negative ping delay means to send ping immediately after a first search is |
| 1402 // recorded. | 1412 // recorded. |
| 1403 RLZTracker::InitRlzFromProfileDelayed( | 1413 RLZTracker::InitRlzFromProfileDelayed( |
| 1404 profile_, first_run::IsChromeFirstRun(), ping_delay < 0, | 1414 profile_, first_run::IsChromeFirstRun(), ping_delay < 0, |
| 1405 base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 1415 base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
| 1406 #endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) | 1416 #endif // ENABLE_RLZ && !defined(OS_CHROMEOS) |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
Change back to defined()
| |
| 1407 | 1417 |
| 1408 // Configure modules that need access to resources. | 1418 // Configure modules that need access to resources. |
| 1409 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1419 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 1410 | 1420 |
| 1411 // In unittest mode, this will do nothing. In normal mode, this will create | 1421 // In unittest mode, this will do nothing. In normal mode, this will create |
| 1412 // the global IntranetRedirectDetector instance, which will promptly go to | 1422 // the global IntranetRedirectDetector instance, which will promptly go to |
| 1413 // sleep for seven seconds (to avoid slowing startup), and wake up afterwards | 1423 // sleep for seven seconds (to avoid slowing startup), and wake up afterwards |
| 1414 // to see if it should do anything else. | 1424 // to see if it should do anything else. |
| 1415 // | 1425 // |
| 1416 // A simpler way of doing all this would be to have some function which could | 1426 // A simpler way of doing all this would be to have some function which could |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1439 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) { | 1449 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) { |
| 1440 net::SdchManager::EnableSdchSupport(false); | 1450 net::SdchManager::EnableSdchSupport(false); |
| 1441 } | 1451 } |
| 1442 | 1452 |
| 1443 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) | 1453 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) |
| 1444 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { | 1454 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { |
| 1445 base::FilePath path = | 1455 base::FilePath path = |
| 1446 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); | 1456 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); |
| 1447 printing::PrintedDocument::set_debug_dump_path(path); | 1457 printing::PrintedDocument::set_debug_dump_path(path); |
| 1448 } | 1458 } |
| 1449 #endif | 1459 #endif // ENABLE_PRINT_PREVIEW && !defined(OFFICIAL_BUILD) |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
Ditto.
| |
| 1450 | 1460 |
| 1451 HandleTestParameters(parsed_command_line()); | 1461 HandleTestParameters(parsed_command_line()); |
| 1452 browser_process_->metrics_service()->RecordBreakpadHasDebugger( | 1462 browser_process_->metrics_service()->RecordBreakpadHasDebugger( |
| 1453 base::debug::BeingDebugged()); | 1463 base::debug::BeingDebugged()); |
| 1454 | 1464 |
| 1455 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( | 1465 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( |
| 1456 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1466 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 1457 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( | 1467 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( |
| 1458 browser_process_->GetApplicationLocale()); | 1468 browser_process_->GetApplicationLocale()); |
| 1459 | 1469 |
| 1460 // Start watching for hangs during startup. We disarm this hang detector when | 1470 // Start watching for hangs during startup. We disarm this hang detector when |
| 1461 // ThreadWatcher takes over or when browser is shutdown or when | 1471 // ThreadWatcher takes over or when browser is shutdown or when |
| 1462 // startup_watcher_ is deleted. | 1472 // startup_watcher_ is deleted. |
| 1463 metrics::MetricsService::SetExecutionPhase( | 1473 metrics::MetricsService::SetExecutionPhase( |
| 1464 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, | 1474 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, |
| 1465 g_browser_process->local_state()); | 1475 g_browser_process->local_state()); |
| 1466 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); | 1476 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); |
| 1467 | 1477 |
| 1468 // On mobile, need for clean shutdown arises only when the application comes | 1478 // On mobile, need for clean shutdown arises only when the application comes |
| 1469 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). | 1479 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). |
| 1470 // http://crbug.com/179143 | 1480 // http://crbug.com/179143 |
| 1471 #if !defined(OS_ANDROID) | 1481 #if !defined(OS_ANDROID) |
| 1472 // Start watching for a hang. | 1482 // Start watching for a hang. |
| 1473 browser_process_->metrics_service()->LogNeedForCleanShutdown(); | 1483 browser_process_->metrics_service()->LogNeedForCleanShutdown(); |
| 1474 #endif | 1484 #endif // !defined(OS_ANDROID) |
| 1475 | 1485 |
| 1476 #if defined(ENABLE_PRINT_PREVIEW) | 1486 #if defined(ENABLE_PRINT_PREVIEW) |
| 1477 // Create the instance of the cloud print proxy service so that it can launch | 1487 // Create the instance of the cloud print proxy service so that it can launch |
| 1478 // the service process if needed. This is needed because the service process | 1488 // the service process if needed. This is needed because the service process |
| 1479 // might have shutdown because an update was available. | 1489 // might have shutdown because an update was available. |
| 1480 // TODO(torne): this should maybe be done with | 1490 // TODO(torne): this should maybe be done with |
| 1481 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() | 1491 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() |
| 1482 // instead? | 1492 // instead? |
| 1483 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1493 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
| 1484 #endif | 1494 #endif // ENABLE_PRINT_PREVIEW |
|
Alexei Svitkine (slow)
2015/03/02 22:11:54
Ditto.
| |
| 1485 | 1495 |
| 1486 // Start watching all browser threads for responsiveness. | 1496 // Start watching all browser threads for responsiveness. |
| 1487 metrics::MetricsService::SetExecutionPhase( | 1497 metrics::MetricsService::SetExecutionPhase( |
| 1488 metrics::MetricsService::THREAD_WATCHER_START, | 1498 metrics::MetricsService::THREAD_WATCHER_START, |
| 1489 g_browser_process->local_state()); | 1499 g_browser_process->local_state()); |
| 1490 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1500 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
| 1491 | 1501 |
| 1492 #if defined(OS_ANDROID) | 1502 #if defined(OS_ANDROID) |
| 1493 ThreadWatcherAndroid::RegisterApplicationStatusListener(); | 1503 ThreadWatcherAndroid::RegisterApplicationStatusListener(); |
| 1494 #endif | 1504 #endif // OS_ANDROID |
|
Alexei Svitkine (slow)
2015/03/02 22:11:54
Ditto.
| |
| 1495 | 1505 |
| 1496 #if !defined(DISABLE_NACL) | 1506 #if !defined(DISABLE_NACL) |
| 1497 BrowserThread::PostTask( | 1507 BrowserThread::PostTask( |
| 1498 BrowserThread::IO, | 1508 BrowserThread::IO, |
| 1499 FROM_HERE, | 1509 FROM_HERE, |
| 1500 base::Bind(nacl::NaClProcessHost::EarlyStartup)); | 1510 base::Bind(nacl::NaClProcessHost::EarlyStartup)); |
| 1501 #endif | 1511 #endif // !defined(DISABLE_NACL) |
| 1502 | 1512 |
| 1503 // Make sure initial prefs are recorded | 1513 // Make sure initial prefs are recorded |
| 1504 PrefMetricsService::Factory::GetForProfile(profile_); | 1514 PrefMetricsService::Factory::GetForProfile(profile_); |
| 1505 | 1515 |
| 1506 PreBrowserStart(); | 1516 PreBrowserStart(); |
| 1507 | 1517 |
| 1508 // Instantiate the notification UI manager, as this triggers a perf timer | 1518 // Instantiate the notification UI manager, as this triggers a perf timer |
| 1509 // used to measure startup time. TODO(stevenjb): Figure out what is actually | 1519 // used to measure startup time. TODO(stevenjb): Figure out what is actually |
| 1510 // triggering the timer and call that explicitly in the approprate place. | 1520 // triggering the timer and call that explicitly in the approprate place. |
| 1511 // http://crbug.com/105065. | 1521 // http://crbug.com/105065. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1537 // We are in regular browser boot sequence. Open initial tabs and enter the | 1547 // We are in regular browser boot sequence. Open initial tabs and enter the |
| 1538 // main message loop. | 1548 // main message loop. |
| 1539 #if defined(OS_CHROMEOS) | 1549 #if defined(OS_CHROMEOS) |
| 1540 // On ChromeOS multiple profiles doesn't apply, and will break if we load | 1550 // On ChromeOS multiple profiles doesn't apply, and will break if we load |
| 1541 // them this early as the cryptohome hasn't yet been mounted (which happens | 1551 // them this early as the cryptohome hasn't yet been mounted (which happens |
| 1542 // only once we log in. | 1552 // only once we log in. |
| 1543 std::vector<Profile*> last_opened_profiles; | 1553 std::vector<Profile*> last_opened_profiles; |
| 1544 #else | 1554 #else |
| 1545 std::vector<Profile*> last_opened_profiles = | 1555 std::vector<Profile*> last_opened_profiles = |
| 1546 g_browser_process->profile_manager()->GetLastOpenedProfiles(); | 1556 g_browser_process->profile_manager()->GetLastOpenedProfiles(); |
| 1547 #endif | 1557 #endif // OS_CHROMEOS |
|
Alexei Svitkine (slow)
2015/03/02 22:11:55
Ditto.
| |
| 1548 | 1558 |
| 1549 if (browser_creator_->Start(parsed_command_line(), base::FilePath(), | 1559 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep2Time", |
| 1550 profile_, last_opened_profiles)) { | 1560 base::TimeTicks::Now() - start_time_step2); |
| 1561 | |
| 1562 // This step is costly and is already measured in | |
| 1563 // Startup.StartupBrowserCreator_Start. | |
| 1564 bool started = browser_creator_->Start( | |
| 1565 parsed_command_line(), base::FilePath(), profile_, last_opened_profiles); | |
| 1566 const base::TimeTicks start_time_step3 = base::TimeTicks::Now(); | |
| 1567 if (started) { | |
| 1551 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 1568 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 1552 // Initialize autoupdate timer. Timer callback costs basically nothing | 1569 // Initialize autoupdate timer. Timer callback costs basically nothing |
| 1553 // when browser is not in persistent mode, so it's OK to let it ride on | 1570 // when browser is not in persistent mode, so it's OK to let it ride on |
| 1554 // the main thread. This needs to be done here because we don't want | 1571 // the main thread. This needs to be done here because we don't want |
| 1555 // to start the timer when Chrome is run inside a test harness. | 1572 // to start the timer when Chrome is run inside a test harness. |
| 1556 browser_process_->StartAutoupdateTimer(); | 1573 browser_process_->StartAutoupdateTimer(); |
| 1557 #endif | 1574 #endif // OS_WIN || (OS_LINUX && !defined(OS_CHROMEOS)) |
| 1558 | 1575 |
| 1559 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1576 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1560 // On Linux, the running exe will be updated if an upgrade becomes | 1577 // On Linux, the running exe will be updated if an upgrade becomes |
| 1561 // available while the browser is running. We need to save the last | 1578 // available while the browser is running. We need to save the last |
| 1562 // modified time of the exe, so we can compare to determine if there is | 1579 // modified time of the exe, so we can compare to determine if there is |
| 1563 // an upgrade while the browser is kept alive by a persistent extension. | 1580 // an upgrade while the browser is kept alive by a persistent extension. |
| 1564 upgrade_util::SaveLastModifiedTimeOfExe(); | 1581 upgrade_util::SaveLastModifiedTimeOfExe(); |
| 1565 #endif | 1582 #endif // OS_LINUX && !defined(OS_CHROMEOS) |
| 1566 | 1583 |
| 1567 // Record now as the last successful chrome start. | 1584 // Record now as the last successful chrome start. |
| 1568 GoogleUpdateSettings::SetLastRunTime(); | 1585 GoogleUpdateSettings::SetLastRunTime(); |
| 1569 | 1586 |
| 1570 #if defined(OS_MACOSX) | 1587 #if defined(OS_MACOSX) |
| 1571 // Call Recycle() here as late as possible, before going into the loop | 1588 // Call Recycle() here as late as possible, before going into the loop |
| 1572 // because Start() will add things to it while creating the main window. | 1589 // because Start() will add things to it while creating the main window. |
| 1573 if (parameters().autorelease_pool) | 1590 if (parameters().autorelease_pool) |
| 1574 parameters().autorelease_pool->Recycle(); | 1591 parameters().autorelease_pool->Recycle(); |
| 1575 #endif | 1592 #endif // defined(OS_MACOSX) |
| 1576 | 1593 |
| 1577 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; | 1594 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; |
| 1578 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); | 1595 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); |
| 1579 | 1596 |
| 1580 // If we're running tests (ui_task is non-null), then we don't want to | 1597 // If we're running tests (ui_task is non-null), then we don't want to |
| 1581 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or | 1598 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or |
| 1582 // RequestLanguageList | 1599 // RequestLanguageList |
| 1583 if (parameters().ui_task == NULL) { | 1600 if (parameters().ui_task == NULL) { |
| 1584 // Request new variations seed information from server. | 1601 // Request new variations seed information from server. |
| 1585 chrome_variations::VariationsService* variations_service = | 1602 chrome_variations::VariationsService* variations_service = |
| 1586 browser_process_->variations_service(); | 1603 browser_process_->variations_service(); |
| 1587 if (variations_service) { | 1604 if (variations_service) { |
| 1588 variations_service->StartRepeatedVariationsSeedFetch(); | 1605 variations_service->StartRepeatedVariationsSeedFetch(); |
| 1589 | 1606 |
| 1590 #if defined(OS_WIN) | 1607 #if defined(OS_WIN) |
| 1591 variations_service->StartGoogleUpdateRegistrySync(); | 1608 variations_service->StartGoogleUpdateRegistrySync(); |
| 1592 #endif | 1609 #endif // OS_WIN |
| 1593 } | 1610 } |
| 1594 | 1611 |
| 1595 translate::TranslateDownloadManager::RequestLanguageList( | 1612 translate::TranslateDownloadManager::RequestLanguageList( |
| 1596 profile_->GetPrefs()); | 1613 profile_->GetPrefs()); |
| 1597 } | 1614 } |
| 1598 | 1615 |
| 1599 run_message_loop_ = true; | 1616 run_message_loop_ = true; |
| 1600 } else { | 1617 } else { |
| 1601 run_message_loop_ = false; | 1618 run_message_loop_ = false; |
| 1602 } | 1619 } |
| 1603 browser_creator_.reset(); | 1620 browser_creator_.reset(); |
| 1604 | 1621 |
| 1605 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 | 1622 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 |
| 1606 if (g_browser_process->metrics_service()->reporting_active()) | 1623 if (g_browser_process->metrics_service()->reporting_active()) |
| 1607 content::StartPowerUsageMonitor(); | 1624 content::StartPowerUsageMonitor(); |
| 1608 #endif | 1625 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 1609 | 1626 |
| 1610 process_power_collector_.reset(new ProcessPowerCollector); | 1627 process_power_collector_.reset(new ProcessPowerCollector); |
| 1611 process_power_collector_->Initialize(); | 1628 process_power_collector_->Initialize(); |
| 1612 #endif // !defined(OS_ANDROID) | 1629 #endif // !defined(OS_ANDROID) |
| 1613 | 1630 |
| 1614 PostBrowserStart(); | 1631 PostBrowserStart(); |
| 1615 | 1632 |
| 1616 if (parameters().ui_task) { | 1633 if (parameters().ui_task) { |
| 1617 parameters().ui_task->Run(); | 1634 parameters().ui_task->Run(); |
| 1618 delete parameters().ui_task; | 1635 delete parameters().ui_task; |
| 1619 run_message_loop_ = false; | 1636 run_message_loop_ = false; |
| 1620 } | 1637 } |
| 1621 #if defined(OS_ANDROID) | 1638 #if defined(OS_ANDROID) |
| 1622 // We never run the C++ main loop on Android, since the UI thread message | 1639 // We never run the C++ main loop on Android, since the UI thread message |
| 1623 // loop is controlled by the OS, so this is as close as we can get to | 1640 // loop is controlled by the OS, so this is as close as we can get to |
| 1624 // the start of the main loop | 1641 // the start of the main loop. |
| 1625 if (result_code_ <= 0) { | 1642 if (result_code_ <= 0) { |
| 1626 RecordBrowserStartupTime(); | 1643 RecordBrowserStartupTime(); |
| 1627 } | 1644 } |
| 1628 #endif | 1645 #endif // OS_ANDROID |
| 1646 | |
| 1647 #if !defined(OS_ANDROID) | |
| 1648 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time", | |
| 1649 base::TimeTicks::Now() - start_time_step3); | |
| 1650 #endif // !defined(OS_ANDROID) | |
| 1651 | |
| 1629 return result_code_; | 1652 return result_code_; |
| 1630 } | 1653 } |
| 1631 | 1654 |
| 1632 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { | 1655 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 1633 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); | 1656 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); |
| 1634 #if defined(OS_ANDROID) | 1657 #if defined(OS_ANDROID) |
| 1635 // Chrome on Android does not use default MessageLoop. It has its own | 1658 // Chrome on Android does not use default MessageLoop. It has its own |
| 1636 // Android specific MessageLoop | 1659 // Android specific MessageLoop |
| 1637 NOTREACHED(); | 1660 NOTREACHED(); |
| 1638 return true; | 1661 return true; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 chromeos::CrosSettings::Shutdown(); | 1753 chromeos::CrosSettings::Shutdown(); |
| 1731 #endif | 1754 #endif |
| 1732 #endif | 1755 #endif |
| 1733 } | 1756 } |
| 1734 | 1757 |
| 1735 // Public members: | 1758 // Public members: |
| 1736 | 1759 |
| 1737 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1760 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1738 chrome_extra_parts_.push_back(parts); | 1761 chrome_extra_parts_.push_back(parts); |
| 1739 } | 1762 } |
| OLD | NEW |