| 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 "chrome/renderer/page_load_metrics/metrics_render_frame_observer.h" | 5 #include "chrome/renderer/page_load_metrics/metrics_render_frame_observer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 PageLoadTiming MetricsRenderFrameObserver::GetTiming() const { | 103 PageLoadTiming MetricsRenderFrameObserver::GetTiming() const { |
| 104 const blink::WebPerformance& perf = | 104 const blink::WebPerformance& perf = |
| 105 render_frame()->GetWebFrame()->Performance(); | 105 render_frame()->GetWebFrame()->Performance(); |
| 106 | 106 |
| 107 PageLoadTiming timing; | 107 PageLoadTiming timing; |
| 108 double start = perf.NavigationStart(); | 108 double start = perf.NavigationStart(); |
| 109 timing.navigation_start = base::Time::FromDoubleT(start); | 109 timing.navigation_start = base::Time::FromDoubleT(start); |
| 110 if (perf.ResponseStart() > 0.0) | 110 if (perf.ResponseStart() > 0.0) |
| 111 timing.response_start = ClampDelta(perf.ResponseStart(), start); | 111 timing.response_start = ClampDelta(perf.ResponseStart(), start); |
| 112 if (perf.DomContentLoadedEventStart() > 0.0) { | 112 if (perf.DomContentLoadedEventStart() > 0.0) { |
| 113 timing.dom_content_loaded_event_start = | 113 timing.document_timing.dom_content_loaded_event_start = |
| 114 ClampDelta(perf.DomContentLoadedEventStart(), start); | 114 ClampDelta(perf.DomContentLoadedEventStart(), start); |
| 115 } | 115 } |
| 116 if (perf.LoadEventStart() > 0.0) | 116 if (perf.LoadEventStart() > 0.0) { |
| 117 timing.load_event_start = ClampDelta(perf.LoadEventStart(), start); | 117 timing.document_timing.load_event_start = |
| 118 ClampDelta(perf.LoadEventStart(), start); |
| 119 } |
| 118 if (perf.FirstLayout() > 0.0) | 120 if (perf.FirstLayout() > 0.0) |
| 119 timing.first_layout = ClampDelta(perf.FirstLayout(), start); | 121 timing.document_timing.first_layout = ClampDelta(perf.FirstLayout(), start); |
| 120 if (perf.FirstPaint() > 0.0) | 122 if (perf.FirstPaint() > 0.0) |
| 121 timing.first_paint = ClampDelta(perf.FirstPaint(), start); | 123 timing.paint_timing.first_paint = ClampDelta(perf.FirstPaint(), start); |
| 122 if (perf.FirstTextPaint() > 0.0) | 124 if (perf.FirstTextPaint() > 0.0) { |
| 123 timing.first_text_paint = ClampDelta(perf.FirstTextPaint(), start); | 125 timing.paint_timing.first_text_paint = |
| 124 if (perf.FirstImagePaint() > 0.0) | 126 ClampDelta(perf.FirstTextPaint(), start); |
| 125 timing.first_image_paint = ClampDelta(perf.FirstImagePaint(), start); | 127 } |
| 128 if (perf.FirstImagePaint() > 0.0) { |
| 129 timing.paint_timing.first_image_paint = |
| 130 ClampDelta(perf.FirstImagePaint(), start); |
| 131 } |
| 126 if (perf.FirstContentfulPaint() > 0.0) { | 132 if (perf.FirstContentfulPaint() > 0.0) { |
| 127 timing.first_contentful_paint = | 133 timing.paint_timing.first_contentful_paint = |
| 128 ClampDelta(perf.FirstContentfulPaint(), start); | 134 ClampDelta(perf.FirstContentfulPaint(), start); |
| 129 } | 135 } |
| 130 if (perf.FirstMeaningfulPaint() > 0.0) { | 136 if (perf.FirstMeaningfulPaint() > 0.0) { |
| 131 timing.first_meaningful_paint = | 137 timing.paint_timing.first_meaningful_paint = |
| 132 ClampDelta(perf.FirstMeaningfulPaint(), start); | 138 ClampDelta(perf.FirstMeaningfulPaint(), start); |
| 133 } | 139 } |
| 134 if (perf.ParseStart() > 0.0) | 140 if (perf.ParseStart() > 0.0) |
| 135 timing.parse_start = ClampDelta(perf.ParseStart(), start); | 141 timing.parse_timing.parse_start = ClampDelta(perf.ParseStart(), start); |
| 136 if (perf.ParseStop() > 0.0) | 142 if (perf.ParseStop() > 0.0) |
| 137 timing.parse_stop = ClampDelta(perf.ParseStop(), start); | 143 timing.parse_timing.parse_stop = ClampDelta(perf.ParseStop(), start); |
| 138 if (timing.parse_start) { | 144 if (timing.parse_timing.parse_start) { |
| 139 // If we started parsing, record all parser durations such as the amount of | 145 // If we started parsing, record all parser durations such as the amount of |
| 140 // time blocked on script load, even if those values are zero. | 146 // time blocked on script load, even if those values are zero. |
| 141 timing.parse_blocked_on_script_load_duration = | 147 timing.parse_timing.parse_blocked_on_script_load_duration = |
| 142 base::TimeDelta::FromSecondsD(perf.ParseBlockedOnScriptLoadDuration()); | 148 base::TimeDelta::FromSecondsD(perf.ParseBlockedOnScriptLoadDuration()); |
| 143 timing.parse_blocked_on_script_load_from_document_write_duration = | 149 timing.parse_timing |
| 150 .parse_blocked_on_script_load_from_document_write_duration = |
| 144 base::TimeDelta::FromSecondsD( | 151 base::TimeDelta::FromSecondsD( |
| 145 perf.ParseBlockedOnScriptLoadFromDocumentWriteDuration()); | 152 perf.ParseBlockedOnScriptLoadFromDocumentWriteDuration()); |
| 146 timing.parse_blocked_on_script_execution_duration = | 153 timing.parse_timing.parse_blocked_on_script_execution_duration = |
| 147 base::TimeDelta::FromSecondsD( | 154 base::TimeDelta::FromSecondsD( |
| 148 perf.ParseBlockedOnScriptExecutionDuration()); | 155 perf.ParseBlockedOnScriptExecutionDuration()); |
| 149 timing.parse_blocked_on_script_execution_from_document_write_duration = | 156 timing.parse_timing |
| 157 .parse_blocked_on_script_execution_from_document_write_duration = |
| 150 base::TimeDelta::FromSecondsD( | 158 base::TimeDelta::FromSecondsD( |
| 151 perf.ParseBlockedOnScriptExecutionFromDocumentWriteDuration()); | 159 perf.ParseBlockedOnScriptExecutionFromDocumentWriteDuration()); |
| 152 } | 160 } |
| 153 | 161 |
| 154 if (perf.AuthorStyleSheetParseDurationBeforeFCP() > 0.0) { | 162 if (perf.AuthorStyleSheetParseDurationBeforeFCP() > 0.0) { |
| 155 timing.style_sheet_timing.author_style_sheet_parse_duration_before_fcp = | 163 timing.style_sheet_timing.author_style_sheet_parse_duration_before_fcp = |
| 156 base::TimeDelta::FromSecondsD( | 164 base::TimeDelta::FromSecondsD( |
| 157 perf.AuthorStyleSheetParseDurationBeforeFCP()); | 165 perf.AuthorStyleSheetParseDurationBeforeFCP()); |
| 158 } | 166 } |
| 159 if (perf.UpdateStyleDurationBeforeFCP() > 0.0) { | 167 if (perf.UpdateStyleDurationBeforeFCP() > 0.0) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 175 | 183 |
| 176 void MetricsRenderFrameObserver::OnDestruct() { | 184 void MetricsRenderFrameObserver::OnDestruct() { |
| 177 delete this; | 185 delete this; |
| 178 } | 186 } |
| 179 | 187 |
| 180 bool MetricsRenderFrameObserver::IsMainFrame() const { | 188 bool MetricsRenderFrameObserver::IsMainFrame() const { |
| 181 return render_frame()->IsMainFrame(); | 189 return render_frame()->IsMainFrame(); |
| 182 } | 190 } |
| 183 | 191 |
| 184 } // namespace page_load_metrics | 192 } // namespace page_load_metrics |
| OLD | NEW |