| 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 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1214 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1215 if (sxs_linux::ShouldMigrateUserDataDir()) | 1215 if (sxs_linux::ShouldMigrateUserDataDir()) |
| 1216 return sxs_linux::MigrateUserDataDir(); | 1216 return sxs_linux::MigrateUserDataDir(); |
| 1217 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1217 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1218 | 1218 |
| 1219 // Desktop construction occurs here, (required before profile creation). | 1219 // Desktop construction occurs here, (required before profile creation). |
| 1220 PreProfileInit(); | 1220 PreProfileInit(); |
| 1221 | 1221 |
| 1222 // Profile creation ---------------------------------------------------------- | 1222 // Profile creation ---------------------------------------------------------- |
| 1223 | 1223 |
| 1224 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE); | 1224 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE, |
| 1225 g_browser_process->local_state()); |
| 1225 profile_ = CreatePrimaryProfile(parameters(), | 1226 profile_ = CreatePrimaryProfile(parameters(), |
| 1226 user_data_dir_, | 1227 user_data_dir_, |
| 1227 parsed_command_line()); | 1228 parsed_command_line()); |
| 1228 if (!profile_) | 1229 if (!profile_) |
| 1229 return content::RESULT_CODE_NORMAL_EXIT; | 1230 return content::RESULT_CODE_NORMAL_EXIT; |
| 1230 | 1231 |
| 1231 #if !defined(OS_ANDROID) | 1232 #if !defined(OS_ANDROID) |
| 1232 // The first run sentinel must be created after the process singleton was | 1233 // The first run sentinel must be created after the process singleton was |
| 1233 // grabbed and no early return paths were otherwise hit above. | 1234 // grabbed and no early return paths were otherwise hit above. |
| 1234 first_run::CreateSentinelIfNeeded(); | 1235 first_run::CreateSentinelIfNeeded(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 base::debug::BeingDebugged()); | 1389 base::debug::BeingDebugged()); |
| 1389 | 1390 |
| 1390 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( | 1391 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( |
| 1391 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1392 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 1392 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( | 1393 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( |
| 1393 browser_process_->GetApplicationLocale()); | 1394 browser_process_->GetApplicationLocale()); |
| 1394 | 1395 |
| 1395 // Start watching for hangs during startup. We disarm this hang detector when | 1396 // Start watching for hangs during startup. We disarm this hang detector when |
| 1396 // ThreadWatcher takes over or when browser is shutdown or when | 1397 // ThreadWatcher takes over or when browser is shutdown or when |
| 1397 // startup_watcher_ is deleted. | 1398 // startup_watcher_ is deleted. |
| 1398 MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM); | 1399 MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM, |
| 1400 g_browser_process->local_state()); |
| 1399 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); | 1401 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
| 1400 | 1402 |
| 1401 // On mobile, need for clean shutdown arises only when the application comes | 1403 // On mobile, need for clean shutdown arises only when the application comes |
| 1402 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). | 1404 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). |
| 1403 // http://crbug.com/179143 | 1405 // http://crbug.com/179143 |
| 1404 #if !defined(OS_ANDROID) | 1406 #if !defined(OS_ANDROID) |
| 1405 // Start watching for a hang. | 1407 // Start watching for a hang. |
| 1406 MetricsService::LogNeedForCleanShutdown(); | 1408 MetricsService::LogNeedForCleanShutdown(g_browser_process->local_state()); |
| 1407 #endif | 1409 #endif |
| 1408 | 1410 |
| 1409 #if defined(ENABLE_FULL_PRINTING) | 1411 #if defined(ENABLE_FULL_PRINTING) |
| 1410 // Create the instance of the cloud print proxy service so that it can launch | 1412 // Create the instance of the cloud print proxy service so that it can launch |
| 1411 // the service process if needed. This is needed because the service process | 1413 // the service process if needed. This is needed because the service process |
| 1412 // might have shutdown because an update was available. | 1414 // might have shutdown because an update was available. |
| 1413 // TODO(torne): this should maybe be done with | 1415 // TODO(torne): this should maybe be done with |
| 1414 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() | 1416 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() |
| 1415 // instead? | 1417 // instead? |
| 1416 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1418 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
| 1417 #endif | 1419 #endif |
| 1418 | 1420 |
| 1419 // Start watching all browser threads for responsiveness. | 1421 // Start watching all browser threads for responsiveness. |
| 1420 MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START); | 1422 MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START, |
| 1423 g_browser_process->local_state()); |
| 1421 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1424 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
| 1422 | 1425 |
| 1423 #if defined(OS_ANDROID) | 1426 #if defined(OS_ANDROID) |
| 1424 ThreadWatcherAndroid::RegisterApplicationStatusListener(); | 1427 ThreadWatcherAndroid::RegisterApplicationStatusListener(); |
| 1425 #endif | 1428 #endif |
| 1426 | 1429 |
| 1427 #if !defined(DISABLE_NACL) | 1430 #if !defined(DISABLE_NACL) |
| 1428 content::BrowserThread::PostTask( | 1431 content::BrowserThread::PostTask( |
| 1429 content::BrowserThread::IO, | 1432 content::BrowserThread::IO, |
| 1430 FROM_HERE, | 1433 FROM_HERE, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 // across versions. | 1575 // across versions. |
| 1573 RecordBrowserStartupTime(); | 1576 RecordBrowserStartupTime(); |
| 1574 startup_timer_->SignalStartupComplete( | 1577 startup_timer_->SignalStartupComplete( |
| 1575 performance_monitor::StartupTimer::STARTUP_NORMAL); | 1578 performance_monitor::StartupTimer::STARTUP_NORMAL); |
| 1576 | 1579 |
| 1577 DCHECK(base::MessageLoopForUI::IsCurrent()); | 1580 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 1578 base::RunLoop run_loop; | 1581 base::RunLoop run_loop; |
| 1579 | 1582 |
| 1580 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); | 1583 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); |
| 1581 | 1584 |
| 1582 MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN); | 1585 MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN, |
| 1586 g_browser_process->local_state()); |
| 1583 run_loop.Run(); | 1587 run_loop.Run(); |
| 1584 | 1588 |
| 1585 return true; | 1589 return true; |
| 1586 #endif | 1590 #endif |
| 1587 } | 1591 } |
| 1588 | 1592 |
| 1589 void ChromeBrowserMainParts::PostMainMessageLoopRun() { | 1593 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
| 1590 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); | 1594 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); |
| 1591 #if defined(OS_ANDROID) | 1595 #if defined(OS_ANDROID) |
| 1592 // Chrome on Android does not use default MessageLoop. It has its own | 1596 // Chrome on Android does not use default MessageLoop. It has its own |
| 1593 // Android specific MessageLoop | 1597 // Android specific MessageLoop |
| 1594 NOTREACHED(); | 1598 NOTREACHED(); |
| 1595 #else | 1599 #else |
| 1596 | 1600 |
| 1597 // Start watching for jank during shutdown. It gets disarmed when | 1601 // Start watching for jank during shutdown. It gets disarmed when |
| 1598 // |shutdown_watcher_| object is destructed. | 1602 // |shutdown_watcher_| object is destructed. |
| 1599 MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM); | 1603 MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM, |
| 1604 g_browser_process->local_state()); |
| 1600 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); | 1605 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
| 1601 | 1606 |
| 1602 // Disarm the startup hang detector time bomb if it is still Arm'ed. | 1607 // Disarm the startup hang detector time bomb if it is still Arm'ed. |
| 1603 startup_watcher_->Disarm(); | 1608 startup_watcher_->Disarm(); |
| 1604 | 1609 |
| 1605 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1610 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1606 chrome_extra_parts_[i]->PostMainMessageLoopRun(); | 1611 chrome_extra_parts_[i]->PostMainMessageLoopRun(); |
| 1607 | 1612 |
| 1608 // Some tests don't set parameters.ui_task, so they started translate | 1613 // Some tests don't set parameters.ui_task, so they started translate |
| 1609 // language fetch that was never completed so we need to cleanup here | 1614 // language fetch that was never completed so we need to cleanup here |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 chromeos::CrosSettings::Shutdown(); | 1653 chromeos::CrosSettings::Shutdown(); |
| 1649 #endif | 1654 #endif |
| 1650 #endif | 1655 #endif |
| 1651 } | 1656 } |
| 1652 | 1657 |
| 1653 // Public members: | 1658 // Public members: |
| 1654 | 1659 |
| 1655 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1660 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1656 chrome_extra_parts_.push_back(parts); | 1661 chrome_extra_parts_.push_back(parts); |
| 1657 } | 1662 } |
| OLD | NEW |