OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/html_viewer/stats_collection_controller.h" | 5 #include "components/html_viewer/stats_collection_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | 12 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
13 #include "gin/handle.h" | 13 #include "gin/handle.h" |
14 #include "gin/object_template_builder.h" | 14 #include "gin/object_template_builder.h" |
15 #include "mojo/application/public/cpp/application_impl.h" | 15 #include "mojo/application/public/cpp/application_impl.h" |
16 #include "mojo/services/tracing/public/cpp/switches.h" | 16 #include "mojo/services/tracing/public/cpp/switches.h" |
17 #include "third_party/WebKit/public/web/WebKit.h" | 17 #include "third_party/WebKit/public/web/WebKit.h" |
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
19 | 19 |
20 namespace html_viewer { | 20 namespace html_viewer { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Initialize the histogram data using the given startup performance times. | 24 // Initialize the histogram data using the given startup performance times. |
25 // TODO(msw): Use TimeTicks to avoid system clock changes: crbug.com/521164 | |
26 void GetStartupPerformanceTimesCallbackImpl( | 25 void GetStartupPerformanceTimesCallbackImpl( |
27 tracing::StartupPerformanceTimesPtr times) { | 26 tracing::StartupPerformanceTimesPtr times) { |
28 base::StatisticsRecorder::Initialize(); | 27 base::StatisticsRecorder::Initialize(); |
29 | 28 |
30 startup_metric_utils::RecordStartupProcessCreationTime( | 29 startup_metric_utils::RecordStartupProcessCreationTime( |
31 base::Time::FromInternalValue(times->shell_process_creation_time)); | 30 base::Time::FromInternalValue(times->shell_process_creation_time)); |
32 | 31 |
33 // TODO(msw): Record the MojoMain() entry point time of mojo:browser instead? | 32 // TODO(msw): Record the MojoMain() entry point time of mojo:browser instead? |
34 startup_metric_utils::RecordMainEntryPointTime( | 33 startup_metric_utils::RecordMainEntryPointTime( |
35 base::Time::FromInternalValue(times->shell_main_entry_point_time)); | 34 base::Time::FromInternalValue(times->shell_main_entry_point_time)); |
36 | 35 |
37 // TODO(msw): Determine if this is the first run. | 36 // TODO(msw): Determine if this is the first run. |
38 startup_metric_utils::RecordBrowserMainMessageLoopStart( | 37 startup_metric_utils::RecordBrowserMainMessageLoopStart( |
39 base::Time::FromInternalValue(times->browser_message_loop_start_time), | 38 base::TimeTicks::FromInternalValue( |
| 39 times->browser_message_loop_start_ticks), |
40 false); | 40 false); |
41 | 41 |
42 startup_metric_utils::RecordBrowserWindowDisplay( | 42 startup_metric_utils::RecordBrowserWindowDisplay( |
43 base::Time::FromInternalValue(times->browser_window_display_time)); | 43 base::TimeTicks::FromInternalValue(times->browser_window_display_ticks)); |
44 | 44 |
45 startup_metric_utils::RecordBrowserOpenTabsDelta( | 45 startup_metric_utils::RecordBrowserOpenTabsDelta( |
46 base::TimeDelta::FromInternalValue(times->browser_open_tabs_time_delta)); | 46 base::TimeDelta::FromInternalValue(times->browser_open_tabs_time_delta)); |
47 | 47 |
48 startup_metric_utils::RecordFirstWebContentsMainFrameLoad( | 48 startup_metric_utils::RecordFirstWebContentsMainFrameLoad( |
49 base::Time::FromInternalValue( | 49 base::TimeTicks::FromInternalValue( |
50 times->first_web_contents_main_frame_load_time)); | 50 times->first_web_contents_main_frame_load_ticks)); |
51 | 51 |
52 startup_metric_utils::RecordFirstWebContentsNonEmptyPaint( | 52 startup_metric_utils::RecordFirstWebContentsNonEmptyPaint( |
53 base::Time::FromInternalValue( | 53 base::TimeTicks::FromInternalValue( |
54 times->first_visually_non_empty_layout_time)); | 54 times->first_visually_non_empty_layout_ticks)); |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 // static | 59 // static |
60 gin::WrapperInfo StatsCollectionController::kWrapperInfo = { | 60 gin::WrapperInfo StatsCollectionController::kWrapperInfo = { |
61 gin::kEmbedderNativeGin}; | 61 gin::kEmbedderNativeGin}; |
62 | 62 |
63 // static | 63 // static |
64 tracing::StartupPerformanceDataCollectorPtr StatsCollectionController::Install( | 64 tracing::StartupPerformanceDataCollectorPtr StatsCollectionController::Install( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 histogram->WriteJSON(&histogram_json); | 153 histogram->WriteJSON(&histogram_json); |
154 return histogram_json; | 154 return histogram_json; |
155 } | 155 } |
156 | 156 |
157 std::string StatsCollectionController::GetBrowserHistogram( | 157 std::string StatsCollectionController::GetBrowserHistogram( |
158 const std::string& histogram_name) { | 158 const std::string& histogram_name) { |
159 return GetHistogram(histogram_name); | 159 return GetHistogram(histogram_name); |
160 } | 160 } |
161 | 161 |
162 } // namespace html_viewer | 162 } // namespace html_viewer |
OLD | NEW |