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

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

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

Powered by Google App Engine
This is Rietveld 408576698