| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/startup_metric_utils/browser/startup_metric_utils.h" | 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/process/process_info.h" | 18 #include "base/process/process_info.h" |
| 19 #include "base/profiler/stack_sampling_profiler.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 21 #include "base/threading/platform_thread.h" | 22 #include "base/threading/platform_thread.h" |
| 22 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "components/metrics/call_stack_profile_metrics_provider.h" |
| 24 #include "components/prefs/pref_registry_simple.h" | 26 #include "components/prefs/pref_registry_simple.h" |
| 25 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 26 #include "components/startup_metric_utils/browser/pref_names.h" | 28 #include "components/startup_metric_utils/browser/pref_names.h" |
| 27 #include "components/version_info/version_info.h" | 29 #include "components/version_info/version_info.h" |
| 28 | 30 |
| 29 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 30 #include <winternl.h> | 32 #include <winternl.h> |
| 31 #include "base/win/win_util.h" | 33 #include "base/win/win_util.h" |
| 32 #endif | 34 #endif |
| 33 | 35 |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 return; | 731 return; |
| 730 is_first_call = false; | 732 is_first_call = false; |
| 731 | 733 |
| 732 // Log Startup.BrowserMainToRendererMain now that the first renderer main | 734 // Log Startup.BrowserMainToRendererMain now that the first renderer main |
| 733 // entry time and the startup temperature are known. | 735 // entry time and the startup temperature are known. |
| 734 RecordRendererMainEntryHistogram(); | 736 RecordRendererMainEntryHistogram(); |
| 735 | 737 |
| 736 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 738 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 737 return; | 739 return; |
| 738 | 740 |
| 741 base::StackSamplingProfiler::SetProcessPhase( |
| 742 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); |
| 739 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 743 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 740 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", | 744 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", |
| 741 g_process_creation_ticks.Get(), ticks); | 745 g_process_creation_ticks.Get(), ticks); |
| 742 } | 746 } |
| 743 | 747 |
| 744 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) { | 748 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) { |
| 745 static bool is_first_call = true; | 749 static bool is_first_call = true; |
| 746 if (!is_first_call || ticks.is_null()) | 750 if (!is_first_call || ticks.is_null()) |
| 747 return; | 751 return; |
| 748 is_first_call = false; | 752 is_first_call = false; |
| 749 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 753 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 750 return; | 754 return; |
| 751 | 755 |
| 756 base::StackSamplingProfiler::SetProcessPhase( |
| 757 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START); |
| 752 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 758 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 753 UMA_HISTOGRAM_LONG_TIMES_100, | 759 UMA_HISTOGRAM_LONG_TIMES_100, |
| 754 "Startup.FirstWebContents.MainNavigationStart", | 760 "Startup.FirstWebContents.MainNavigationStart", |
| 755 g_process_creation_ticks.Get(), ticks); | 761 g_process_creation_ticks.Get(), ticks); |
| 756 } | 762 } |
| 757 | 763 |
| 758 void RecordFirstWebContentsMainNavigationFinished( | 764 void RecordFirstWebContentsMainNavigationFinished( |
| 759 const base::TimeTicks& ticks) { | 765 const base::TimeTicks& ticks) { |
| 760 static bool is_first_call = true; | 766 static bool is_first_call = true; |
| 761 if (!is_first_call || ticks.is_null()) | 767 if (!is_first_call || ticks.is_null()) |
| 762 return; | 768 return; |
| 763 is_first_call = false; | 769 is_first_call = false; |
| 764 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 770 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 765 return; | 771 return; |
| 766 | 772 |
| 773 base::StackSamplingProfiler::SetProcessPhase( |
| 774 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_FINISHED); |
| 767 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 775 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 768 UMA_HISTOGRAM_LONG_TIMES_100, | 776 UMA_HISTOGRAM_LONG_TIMES_100, |
| 769 "Startup.FirstWebContents.MainNavigationFinished", | 777 "Startup.FirstWebContents.MainNavigationFinished", |
| 770 g_process_creation_ticks.Get(), ticks); | 778 g_process_creation_ticks.Get(), ticks); |
| 771 } | 779 } |
| 772 | 780 |
| 773 base::TimeTicks MainEntryPointTicks() { | 781 base::TimeTicks MainEntryPointTicks() { |
| 774 return g_browser_main_entry_point_ticks.Get(); | 782 return g_browser_main_entry_point_ticks.Get(); |
| 775 } | 783 } |
| 776 | 784 |
| 777 } // namespace startup_metric_utils | 785 } // namespace startup_metric_utils |
| OLD | NEW |