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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 profile_->GetPrefs()); | 1549 profile_->GetPrefs()); |
1552 } | 1550 } |
1553 | 1551 |
1554 run_message_loop_ = true; | 1552 run_message_loop_ = true; |
1555 } else { | 1553 } else { |
1556 run_message_loop_ = false; | 1554 run_message_loop_ = false; |
1557 } | 1555 } |
1558 browser_creator_.reset(); | 1556 browser_creator_.reset(); |
1559 #endif // !defined(OS_ANDROID) | 1557 #endif // !defined(OS_ANDROID) |
1560 | 1558 |
1561 performance_monitor::PerformanceMonitor::GetInstance()->Initialize(); | |
1562 | |
1563 #if !defined(OS_ANDROID) | 1559 #if !defined(OS_ANDROID) |
1564 process_power_collector_.reset(new ProcessPowerCollector); | 1560 process_power_collector_.reset(new ProcessPowerCollector); |
1565 process_power_collector_->Initialize(); | 1561 process_power_collector_->Initialize(); |
1566 #endif | 1562 #endif |
1567 | 1563 |
1568 PostBrowserStart(); | 1564 PostBrowserStart(); |
1569 | 1565 |
1570 if (parameters().ui_task) { | 1566 if (parameters().ui_task) { |
1571 // We end the startup timer here if we have parameters to run, because we | |
1572 // never start to run the main loop (where we normally stop the timer). | |
1573 startup_timer_->SignalStartupComplete( | |
1574 performance_monitor::StartupTimer::STARTUP_TEST); | |
1575 parameters().ui_task->Run(); | 1567 parameters().ui_task->Run(); |
1576 delete parameters().ui_task; | 1568 delete parameters().ui_task; |
1577 run_message_loop_ = false; | 1569 run_message_loop_ = false; |
1578 } | 1570 } |
1579 #if defined(OS_ANDROID) | 1571 #if defined(OS_ANDROID) |
1580 // We never run the C++ main loop on Android, since the UI thread message | 1572 // We never run the C++ main loop on Android, since the UI thread message |
1581 // loop is controlled by the OS, so this is as close as we can get to | 1573 // loop is controlled by the OS, so this is as close as we can get to |
1582 // the start of the main loop | 1574 // the start of the main loop |
1583 if (result_code_ <= 0) { | 1575 if (result_code_ <= 0) { |
1584 RecordBrowserStartupTime(); | 1576 RecordBrowserStartupTime(); |
(...skipping 12 matching lines...) Expand all Loading... |
1597 #else | 1589 #else |
1598 // Set the result code set in PreMainMessageLoopRun or set above. | 1590 // Set the result code set in PreMainMessageLoopRun or set above. |
1599 *result_code = result_code_; | 1591 *result_code = result_code_; |
1600 if (!run_message_loop_) | 1592 if (!run_message_loop_) |
1601 return true; // Don't run the default message loop. | 1593 return true; // Don't run the default message loop. |
1602 | 1594 |
1603 // These should be invoked as close to the start of the browser's | 1595 // These should be invoked as close to the start of the browser's |
1604 // UI thread message loop as possible to get a stable measurement | 1596 // UI thread message loop as possible to get a stable measurement |
1605 // across versions. | 1597 // across versions. |
1606 RecordBrowserStartupTime(); | 1598 RecordBrowserStartupTime(); |
1607 startup_timer_->SignalStartupComplete( | |
1608 performance_monitor::StartupTimer::STARTUP_NORMAL); | |
1609 | 1599 |
1610 DCHECK(base::MessageLoopForUI::IsCurrent()); | 1600 DCHECK(base::MessageLoopForUI::IsCurrent()); |
1611 base::RunLoop run_loop; | 1601 base::RunLoop run_loop; |
1612 | 1602 |
1613 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); | 1603 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); |
1614 | 1604 |
1615 metrics::MetricsService::SetExecutionPhase( | 1605 metrics::MetricsService::SetExecutionPhase( |
1616 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, | 1606 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, |
1617 g_browser_process->local_state()); | 1607 g_browser_process->local_state()); |
1618 run_loop.Run(); | 1608 run_loop.Run(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 chromeos::CrosSettings::Shutdown(); | 1679 chromeos::CrosSettings::Shutdown(); |
1690 #endif | 1680 #endif |
1691 #endif | 1681 #endif |
1692 } | 1682 } |
1693 | 1683 |
1694 // Public members: | 1684 // Public members: |
1695 | 1685 |
1696 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1686 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1697 chrome_extra_parts_.push_back(parts); | 1687 chrome_extra_parts_.push_back(parts); |
1698 } | 1688 } |
OLD | NEW |