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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ = | 542 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ = |
544 false; | 543 false; |
545 | 544 |
546 ChromeBrowserMainParts::ChromeBrowserMainParts( | 545 ChromeBrowserMainParts::ChromeBrowserMainParts( |
547 const content::MainFunctionParams& parameters) | 546 const content::MainFunctionParams& parameters) |
548 : parameters_(parameters), | 547 : parameters_(parameters), |
549 parsed_command_line_(parameters.command_line), | 548 parsed_command_line_(parameters.command_line), |
550 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 549 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
551 startup_watcher_(new StartupTimeBomb()), | 550 startup_watcher_(new StartupTimeBomb()), |
552 shutdown_watcher_(new ShutdownWatcherHelper()), | 551 shutdown_watcher_(new ShutdownWatcherHelper()), |
553 startup_timer_(new performance_monitor::StartupTimer()), | |
554 browser_field_trials_(parameters.command_line), | 552 browser_field_trials_(parameters.command_line), |
555 profile_(NULL), | 553 profile_(NULL), |
556 run_message_loop_(true), | 554 run_message_loop_(true), |
557 notify_result_(ProcessSingleton::PROCESS_NONE), | 555 notify_result_(ProcessSingleton::PROCESS_NONE), |
558 local_state_(NULL), | 556 local_state_(NULL), |
559 restart_last_session_(false) { | 557 restart_last_session_(false) { |
560 // If we're running tests (ui_task is non-null). | 558 // If we're running tests (ui_task is non-null). |
561 if (parameters.ui_task) | 559 if (parameters.ui_task) |
562 browser_defaults::enable_help_app = false; | 560 browser_defaults::enable_help_app = false; |
563 | 561 |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 profile_->GetPrefs()); | 1548 profile_->GetPrefs()); |
1551 } | 1549 } |
1552 | 1550 |
1553 run_message_loop_ = true; | 1551 run_message_loop_ = true; |
1554 } else { | 1552 } else { |
1555 run_message_loop_ = false; | 1553 run_message_loop_ = false; |
1556 } | 1554 } |
1557 browser_creator_.reset(); | 1555 browser_creator_.reset(); |
1558 #endif // !defined(OS_ANDROID) | 1556 #endif // !defined(OS_ANDROID) |
1559 | 1557 |
1560 performance_monitor::PerformanceMonitor::GetInstance()->Initialize(); | |
1561 | |
1562 #if !defined(OS_ANDROID) | 1558 #if !defined(OS_ANDROID) |
1563 process_power_collector_.reset(new ProcessPowerCollector); | 1559 process_power_collector_.reset(new ProcessPowerCollector); |
1564 process_power_collector_->Initialize(); | 1560 process_power_collector_->Initialize(); |
1565 #endif | 1561 #endif |
1566 | 1562 |
1567 PostBrowserStart(); | 1563 PostBrowserStart(); |
1568 | 1564 |
1569 if (parameters().ui_task) { | 1565 if (parameters().ui_task) { |
1570 // We end the startup timer here if we have parameters to run, because we | |
1571 // never start to run the main loop (where we normally stop the timer). | |
1572 startup_timer_->SignalStartupComplete( | |
1573 performance_monitor::StartupTimer::STARTUP_TEST); | |
1574 parameters().ui_task->Run(); | 1566 parameters().ui_task->Run(); |
1575 delete parameters().ui_task; | 1567 delete parameters().ui_task; |
1576 run_message_loop_ = false; | 1568 run_message_loop_ = false; |
1577 } | 1569 } |
1578 #if defined(OS_ANDROID) | 1570 #if defined(OS_ANDROID) |
1579 // We never run the C++ main loop on Android, since the UI thread message | 1571 // We never run the C++ main loop on Android, since the UI thread message |
1580 // loop is controlled by the OS, so this is as close as we can get to | 1572 // loop is controlled by the OS, so this is as close as we can get to |
1581 // the start of the main loop | 1573 // the start of the main loop |
1582 if (result_code_ <= 0) { | 1574 if (result_code_ <= 0) { |
1583 RecordBrowserStartupTime(); | 1575 RecordBrowserStartupTime(); |
(...skipping 12 matching lines...) Expand all Loading... |
1596 #else | 1588 #else |
1597 // Set the result code set in PreMainMessageLoopRun or set above. | 1589 // Set the result code set in PreMainMessageLoopRun or set above. |
1598 *result_code = result_code_; | 1590 *result_code = result_code_; |
1599 if (!run_message_loop_) | 1591 if (!run_message_loop_) |
1600 return true; // Don't run the default message loop. | 1592 return true; // Don't run the default message loop. |
1601 | 1593 |
1602 // These should be invoked as close to the start of the browser's | 1594 // These should be invoked as close to the start of the browser's |
1603 // UI thread message loop as possible to get a stable measurement | 1595 // UI thread message loop as possible to get a stable measurement |
1604 // across versions. | 1596 // across versions. |
1605 RecordBrowserStartupTime(); | 1597 RecordBrowserStartupTime(); |
1606 startup_timer_->SignalStartupComplete( | |
1607 performance_monitor::StartupTimer::STARTUP_NORMAL); | |
1608 | 1598 |
1609 DCHECK(base::MessageLoopForUI::IsCurrent()); | 1599 DCHECK(base::MessageLoopForUI::IsCurrent()); |
1610 base::RunLoop run_loop; | 1600 base::RunLoop run_loop; |
1611 | 1601 |
1612 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); | 1602 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); |
1613 | 1603 |
1614 metrics::MetricsService::SetExecutionPhase( | 1604 metrics::MetricsService::SetExecutionPhase( |
1615 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, | 1605 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, |
1616 g_browser_process->local_state()); | 1606 g_browser_process->local_state()); |
1617 run_loop.Run(); | 1607 run_loop.Run(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 chromeos::CrosSettings::Shutdown(); | 1678 chromeos::CrosSettings::Shutdown(); |
1689 #endif | 1679 #endif |
1690 #endif | 1680 #endif |
1691 } | 1681 } |
1692 | 1682 |
1693 // Public members: | 1683 // Public members: |
1694 | 1684 |
1695 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1685 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1696 chrome_extra_parts_.push_back(parts); | 1686 chrome_extra_parts_.push_back(parts); |
1697 } | 1687 } |
OLD | NEW |