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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "chrome/browser/metrics/field_trial_synchronizer.h" | 58 #include "chrome/browser/metrics/field_trial_synchronizer.h" |
59 #include "chrome/browser/metrics/thread_watcher.h" | 59 #include "chrome/browser/metrics/thread_watcher.h" |
60 #include "chrome/browser/metrics/tracking_synchronizer.h" | 60 #include "chrome/browser/metrics/tracking_synchronizer.h" |
61 #include "chrome/browser/metrics/variations/variations_service.h" | 61 #include "chrome/browser/metrics/variations/variations_service.h" |
62 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" | 62 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
63 #include "chrome/browser/net/chrome_net_log.h" | 63 #include "chrome/browser/net/chrome_net_log.h" |
64 #include "chrome/browser/net/crl_set_fetcher.h" | 64 #include "chrome/browser/net/crl_set_fetcher.h" |
65 #include "chrome/browser/notifications/desktop_notification_service.h" | 65 #include "chrome/browser/notifications/desktop_notification_service.h" |
66 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 66 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
67 #include "chrome/browser/performance_monitor/performance_monitor.h" | 67 #include "chrome/browser/performance_monitor/performance_monitor.h" |
68 #include "chrome/browser/performance_monitor/startup_timer.h" | |
69 #include "chrome/browser/plugins/plugin_prefs.h" | 68 #include "chrome/browser/plugins/plugin_prefs.h" |
70 #include "chrome/browser/power/process_power_collector.h" | 69 #include "chrome/browser/power/process_power_collector.h" |
71 #include "chrome/browser/pref_service_flags_storage.h" | 70 #include "chrome/browser/pref_service_flags_storage.h" |
72 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 71 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
73 #include "chrome/browser/prefs/command_line_pref_store.h" | 72 #include "chrome/browser/prefs/command_line_pref_store.h" |
74 #include "chrome/browser/prefs/pref_metrics_service.h" | 73 #include "chrome/browser/prefs/pref_metrics_service.h" |
75 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 74 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
76 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 75 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
77 #include "chrome/browser/process_singleton.h" | 76 #include "chrome/browser/process_singleton.h" |
78 #include "chrome/browser/profiles/profile.h" | 77 #include "chrome/browser/profiles/profile.h" |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ = | 535 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ = |
537 false; | 536 false; |
538 | 537 |
539 ChromeBrowserMainParts::ChromeBrowserMainParts( | 538 ChromeBrowserMainParts::ChromeBrowserMainParts( |
540 const content::MainFunctionParams& parameters) | 539 const content::MainFunctionParams& parameters) |
541 : parameters_(parameters), | 540 : parameters_(parameters), |
542 parsed_command_line_(parameters.command_line), | 541 parsed_command_line_(parameters.command_line), |
543 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 542 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
544 startup_watcher_(new StartupTimeBomb()), | 543 startup_watcher_(new StartupTimeBomb()), |
545 shutdown_watcher_(new ShutdownWatcherHelper()), | 544 shutdown_watcher_(new ShutdownWatcherHelper()), |
546 startup_timer_(new performance_monitor::StartupTimer()), | |
547 browser_field_trials_(parameters.command_line), | 545 browser_field_trials_(parameters.command_line), |
548 profile_(NULL), | 546 profile_(NULL), |
549 run_message_loop_(true), | 547 run_message_loop_(true), |
550 notify_result_(ProcessSingleton::PROCESS_NONE), | 548 notify_result_(ProcessSingleton::PROCESS_NONE), |
551 local_state_(NULL), | 549 local_state_(NULL), |
552 restart_last_session_(false) { | 550 restart_last_session_(false) { |
553 // If we're running tests (ui_task is non-null). | 551 // If we're running tests (ui_task is non-null). |
554 if (parameters.ui_task) | 552 if (parameters.ui_task) |
555 browser_defaults::enable_help_app = false; | 553 browser_defaults::enable_help_app = false; |
556 | 554 |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 profile_->GetPrefs()); | 1542 profile_->GetPrefs()); |
1545 } | 1543 } |
1546 | 1544 |
1547 run_message_loop_ = true; | 1545 run_message_loop_ = true; |
1548 } else { | 1546 } else { |
1549 run_message_loop_ = false; | 1547 run_message_loop_ = false; |
1550 } | 1548 } |
1551 browser_creator_.reset(); | 1549 browser_creator_.reset(); |
1552 #endif // !defined(OS_ANDROID) | 1550 #endif // !defined(OS_ANDROID) |
1553 | 1551 |
1554 performance_monitor::PerformanceMonitor::GetInstance()->Initialize(); | |
1555 | |
1556 #if !defined(OS_ANDROID) | 1552 #if !defined(OS_ANDROID) |
1557 process_power_collector_.reset(new ProcessPowerCollector); | 1553 process_power_collector_.reset(new ProcessPowerCollector); |
1558 process_power_collector_->Initialize(); | 1554 process_power_collector_->Initialize(); |
1559 #endif | 1555 #endif |
1560 | 1556 |
1561 PostBrowserStart(); | 1557 PostBrowserStart(); |
1562 | 1558 |
1563 if (parameters().ui_task) { | 1559 if (parameters().ui_task) { |
1564 // We end the startup timer here if we have parameters to run, because we | |
1565 // never start to run the main loop (where we normally stop the timer). | |
1566 startup_timer_->SignalStartupComplete( | |
1567 performance_monitor::StartupTimer::STARTUP_TEST); | |
1568 parameters().ui_task->Run(); | 1560 parameters().ui_task->Run(); |
1569 delete parameters().ui_task; | 1561 delete parameters().ui_task; |
1570 run_message_loop_ = false; | 1562 run_message_loop_ = false; |
1571 } | 1563 } |
1572 #if defined(OS_ANDROID) | 1564 #if defined(OS_ANDROID) |
1573 // We never run the C++ main loop on Android, since the UI thread message | 1565 // We never run the C++ main loop on Android, since the UI thread message |
1574 // loop is controlled by the OS, so this is as close as we can get to | 1566 // loop is controlled by the OS, so this is as close as we can get to |
1575 // the start of the main loop | 1567 // the start of the main loop |
1576 if (result_code_ <= 0) { | 1568 if (result_code_ <= 0) { |
1577 RecordBrowserStartupTime(); | 1569 RecordBrowserStartupTime(); |
(...skipping 12 matching lines...) Expand all Loading... |
1590 #else | 1582 #else |
1591 // Set the result code set in PreMainMessageLoopRun or set above. | 1583 // Set the result code set in PreMainMessageLoopRun or set above. |
1592 *result_code = result_code_; | 1584 *result_code = result_code_; |
1593 if (!run_message_loop_) | 1585 if (!run_message_loop_) |
1594 return true; // Don't run the default message loop. | 1586 return true; // Don't run the default message loop. |
1595 | 1587 |
1596 // These should be invoked as close to the start of the browser's | 1588 // These should be invoked as close to the start of the browser's |
1597 // UI thread message loop as possible to get a stable measurement | 1589 // UI thread message loop as possible to get a stable measurement |
1598 // across versions. | 1590 // across versions. |
1599 RecordBrowserStartupTime(); | 1591 RecordBrowserStartupTime(); |
1600 startup_timer_->SignalStartupComplete( | |
1601 performance_monitor::StartupTimer::STARTUP_NORMAL); | |
1602 | 1592 |
1603 DCHECK(base::MessageLoopForUI::IsCurrent()); | 1593 DCHECK(base::MessageLoopForUI::IsCurrent()); |
1604 base::RunLoop run_loop; | 1594 base::RunLoop run_loop; |
1605 | 1595 |
1606 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); | 1596 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); |
1607 | 1597 |
1608 metrics::MetricsService::SetExecutionPhase( | 1598 metrics::MetricsService::SetExecutionPhase( |
1609 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, | 1599 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, |
1610 g_browser_process->local_state()); | 1600 g_browser_process->local_state()); |
1611 run_loop.Run(); | 1601 run_loop.Run(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 chromeos::CrosSettings::Shutdown(); | 1672 chromeos::CrosSettings::Shutdown(); |
1683 #endif | 1673 #endif |
1684 #endif | 1674 #endif |
1685 } | 1675 } |
1686 | 1676 |
1687 // Public members: | 1677 // Public members: |
1688 | 1678 |
1689 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1679 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1690 chrome_extra_parts_.push_back(parts); | 1680 chrome_extra_parts_.push_back(parts); |
1691 } | 1681 } |
OLD | NEW |