OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "platform/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 touchstart_expected_soon(false), | 213 touchstart_expected_soon(false), |
214 have_seen_a_begin_main_frame(false), | 214 have_seen_a_begin_main_frame(false), |
215 have_reported_blocking_intervention_in_current_policy(false), | 215 have_reported_blocking_intervention_in_current_policy(false), |
216 have_reported_blocking_intervention_since_navigation(false), | 216 have_reported_blocking_intervention_since_navigation(false), |
217 has_visible_render_widget_with_touch_handler(false), | 217 has_visible_render_widget_with_touch_handler(false), |
218 begin_frame_not_expected_soon(false), | 218 begin_frame_not_expected_soon(false), |
219 in_idle_period_for_testing(false), | 219 in_idle_period_for_testing(false), |
220 use_virtual_time(false), | 220 use_virtual_time(false), |
221 is_audio_playing(false), | 221 is_audio_playing(false), |
222 virtual_time_paused(false), | 222 virtual_time_paused(false), |
| 223 has_navigated(false), |
223 rail_mode_observer(nullptr), | 224 rail_mode_observer(nullptr), |
224 wake_up_budget_pool(nullptr), | 225 wake_up_budget_pool(nullptr), |
225 task_duration_reporter("RendererScheduler.TaskDurationPerQueueType2"), | 226 task_duration_reporter("RendererScheduler.TaskDurationPerQueueType2"), |
226 foreground_task_duration_reporter( | 227 foreground_task_duration_reporter( |
227 "RendererScheduler.TaskDurationPerQueueType2.Foreground"), | 228 "RendererScheduler.TaskDurationPerQueueType2.Foreground"), |
228 background_task_duration_reporter( | 229 background_task_duration_reporter( |
229 "RendererScheduler.TaskDurationPerQueueType2.Background") { | 230 "RendererScheduler.TaskDurationPerQueueType2.Background") { |
230 foreground_main_thread_load_tracker.Resume(now); | 231 foreground_main_thread_load_tracker.Resume(now); |
231 } | 232 } |
232 | 233 |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 void RendererSchedulerImpl::RemovePendingNavigation(NavigatingFrameType type) { | 1640 void RendererSchedulerImpl::RemovePendingNavigation(NavigatingFrameType type) { |
1640 helper_.CheckOnValidThread(); | 1641 helper_.CheckOnValidThread(); |
1641 DCHECK_GT(GetMainThreadOnly().navigation_task_expected_count, 0); | 1642 DCHECK_GT(GetMainThreadOnly().navigation_task_expected_count, 0); |
1642 if (type == NavigatingFrameType::kMainFrame && | 1643 if (type == NavigatingFrameType::kMainFrame && |
1643 GetMainThreadOnly().navigation_task_expected_count > 0) { | 1644 GetMainThreadOnly().navigation_task_expected_count > 0) { |
1644 GetMainThreadOnly().navigation_task_expected_count--; | 1645 GetMainThreadOnly().navigation_task_expected_count--; |
1645 UpdatePolicy(); | 1646 UpdatePolicy(); |
1646 } | 1647 } |
1647 } | 1648 } |
1648 | 1649 |
| 1650 std::unique_ptr<base::SingleSampleMetric> |
| 1651 RendererSchedulerImpl::CreateMaxQueueingTimeMetric() { |
| 1652 return base::SingleSampleMetricsFactory::Get()->CreateCustomCountsMetric( |
| 1653 "RendererScheduler.MaxQueueingTime", 1, 10000, 50); |
| 1654 } |
| 1655 |
1649 void RendererSchedulerImpl::OnNavigationStarted() { | 1656 void RendererSchedulerImpl::OnNavigationStarted() { |
1650 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1657 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
1651 "RendererSchedulerImpl::OnNavigationStarted"); | 1658 "RendererSchedulerImpl::OnNavigationStarted"); |
1652 base::AutoLock lock(any_thread_lock_); | 1659 base::AutoLock lock(any_thread_lock_); |
1653 ResetForNavigationLocked(); | 1660 ResetForNavigationLocked(); |
1654 } | 1661 } |
1655 | 1662 |
| 1663 void RendererSchedulerImpl::OnCommitProvisionalLoad() { |
| 1664 // Initialize |max_queueing_time_metric| lazily so that |
| 1665 // |SingleSampleMetricsFactory::SetFactory()| is called before |
| 1666 // |SingleSampleMetricsFactory::Get()| |
| 1667 if (!GetMainThreadOnly().max_queueing_time_metric) { |
| 1668 GetMainThreadOnly().max_queueing_time_metric = |
| 1669 CreateMaxQueueingTimeMetric(); |
| 1670 } |
| 1671 GetMainThreadOnly().max_queueing_time_metric.reset(); |
| 1672 GetMainThreadOnly().max_queueing_time = base::TimeDelta(); |
| 1673 GetMainThreadOnly().has_navigated = true; |
| 1674 } |
| 1675 |
1656 void RendererSchedulerImpl::OnFirstMeaningfulPaint() { | 1676 void RendererSchedulerImpl::OnFirstMeaningfulPaint() { |
1657 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1677 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
1658 "RendererSchedulerImpl::OnFirstMeaningfulPaint"); | 1678 "RendererSchedulerImpl::OnFirstMeaningfulPaint"); |
1659 base::AutoLock lock(any_thread_lock_); | 1679 base::AutoLock lock(any_thread_lock_); |
1660 GetAnyThread().waiting_for_meaningful_paint = false; | 1680 GetAnyThread().waiting_for_meaningful_paint = false; |
1661 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 1681 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
1662 } | 1682 } |
1663 | 1683 |
1664 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { | 1684 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { |
1665 DCHECK(GetMainThreadOnly().renderer_backgrounded); | 1685 DCHECK(GetMainThreadOnly().renderer_backgrounded); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 } | 1927 } |
1908 | 1928 |
1909 void RendererSchedulerImpl::RemoveTaskTimeObserver( | 1929 void RendererSchedulerImpl::RemoveTaskTimeObserver( |
1910 TaskTimeObserver* task_time_observer) { | 1930 TaskTimeObserver* task_time_observer) { |
1911 helper_.RemoveTaskTimeObserver(task_time_observer); | 1931 helper_.RemoveTaskTimeObserver(task_time_observer); |
1912 } | 1932 } |
1913 | 1933 |
1914 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( | 1934 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( |
1915 base::TimeDelta queueing_time, | 1935 base::TimeDelta queueing_time, |
1916 base::TimeTicks window_start_time) { | 1936 base::TimeTicks window_start_time) { |
| 1937 if (GetMainThreadOnly().has_navigated) { |
| 1938 if (GetMainThreadOnly().max_queueing_time < queueing_time) { |
| 1939 if (!GetMainThreadOnly().max_queueing_time_metric) { |
| 1940 GetMainThreadOnly().max_queueing_time_metric = |
| 1941 CreateMaxQueueingTimeMetric(); |
| 1942 } |
| 1943 GetMainThreadOnly().max_queueing_time_metric->SetSample( |
| 1944 queueing_time.InMilliseconds()); |
| 1945 GetMainThreadOnly().max_queueing_time = queueing_time; |
| 1946 } |
| 1947 } |
| 1948 |
1917 // RendererScheduler reports the queueing time once per window's duration. | 1949 // RendererScheduler reports the queueing time once per window's duration. |
1918 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT| | 1950 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT| |
1919 // Report: |-------window EQT------| | 1951 // Report: |-------window EQT------| |
1920 // Discard: |-------window EQT------| | 1952 // Discard: |-------window EQT------| |
1921 // Discard: |-------window EQT------| | 1953 // Discard: |-------window EQT------| |
1922 // Report: |-------window EQT------| | 1954 // Report: |-------window EQT------| |
1923 if (window_start_time - | 1955 if (window_start_time - |
1924 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time < | 1956 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time < |
1925 kQueueingTimeWindowDuration) { | 1957 kQueueingTimeWindowDuration) { |
1926 return; | 1958 return; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 case TimeDomainType::VIRTUAL: | 2096 case TimeDomainType::VIRTUAL: |
2065 return "virtual"; | 2097 return "virtual"; |
2066 default: | 2098 default: |
2067 NOTREACHED(); | 2099 NOTREACHED(); |
2068 return nullptr; | 2100 return nullptr; |
2069 } | 2101 } |
2070 } | 2102 } |
2071 | 2103 |
2072 } // namespace scheduler | 2104 } // namespace scheduler |
2073 } // namespace blink | 2105 } // namespace blink |
OLD | NEW |