Chromium Code Reviews| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 timer_tasks_seem_expensive(false), | 210 timer_tasks_seem_expensive(false), |
| 211 touchstart_expected_soon(false), | 211 touchstart_expected_soon(false), |
| 212 have_seen_a_begin_main_frame(false), | 212 have_seen_a_begin_main_frame(false), |
| 213 have_reported_blocking_intervention_in_current_policy(false), | 213 have_reported_blocking_intervention_in_current_policy(false), |
| 214 have_reported_blocking_intervention_since_navigation(false), | 214 have_reported_blocking_intervention_since_navigation(false), |
| 215 has_visible_render_widget_with_touch_handler(false), | 215 has_visible_render_widget_with_touch_handler(false), |
| 216 begin_frame_not_expected_soon(false), | 216 begin_frame_not_expected_soon(false), |
| 217 in_idle_period_for_testing(false), | 217 in_idle_period_for_testing(false), |
| 218 use_virtual_time(false), | 218 use_virtual_time(false), |
| 219 is_audio_playing(false), | 219 is_audio_playing(false), |
| 220 during_navigation(false), | |
| 220 rail_mode_observer(nullptr), | 221 rail_mode_observer(nullptr), |
| 221 wake_up_budget_pool(nullptr), | 222 wake_up_budget_pool(nullptr), |
| 222 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet( | 223 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet( |
| 223 "RendererScheduler.TaskDurationPerQueueType", | 224 "RendererScheduler.TaskDurationPerQueueType", |
| 224 1, | 225 1, |
| 225 static_cast<int>(TaskQueue::QueueType::COUNT), | 226 static_cast<int>(TaskQueue::QueueType::COUNT), |
| 226 static_cast<int>(TaskQueue::QueueType::COUNT) + 1, | 227 static_cast<int>(TaskQueue::QueueType::COUNT) + 1, |
| 227 base::HistogramBase::kUmaTargetedHistogramFlag)) { | 228 base::HistogramBase::kUmaTargetedHistogramFlag)) { |
| 228 foreground_main_thread_load_tracker.Resume(now); | 229 foreground_main_thread_load_tracker.Resume(now); |
| 229 } | 230 } |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1628 GetMainThreadOnly().navigation_task_expected_count > 0) { | 1629 GetMainThreadOnly().navigation_task_expected_count > 0) { |
| 1629 GetMainThreadOnly().navigation_task_expected_count--; | 1630 GetMainThreadOnly().navigation_task_expected_count--; |
| 1630 UpdatePolicy(); | 1631 UpdatePolicy(); |
| 1631 } | 1632 } |
| 1632 } | 1633 } |
| 1633 | 1634 |
| 1634 void RendererSchedulerImpl::OnNavigationStarted() { | 1635 void RendererSchedulerImpl::OnNavigationStarted() { |
| 1635 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1636 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 1636 "RendererSchedulerImpl::OnNavigationStarted"); | 1637 "RendererSchedulerImpl::OnNavigationStarted"); |
| 1637 base::AutoLock lock(any_thread_lock_); | 1638 base::AutoLock lock(any_thread_lock_); |
| 1639 GetMainThreadOnly().during_navigation = true; | |
| 1638 ResetForNavigationLocked(); | 1640 ResetForNavigationLocked(); |
| 1639 } | 1641 } |
| 1640 | 1642 |
| 1641 void RendererSchedulerImpl::OnFirstMeaningfulPaint() { | 1643 void RendererSchedulerImpl::OnFirstMeaningfulPaint() { |
| 1642 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1644 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 1643 "RendererSchedulerImpl::OnFirstMeaningfulPaint"); | 1645 "RendererSchedulerImpl::OnFirstMeaningfulPaint"); |
| 1644 base::AutoLock lock(any_thread_lock_); | 1646 base::AutoLock lock(any_thread_lock_); |
| 1645 GetAnyThread().waiting_for_meaningful_paint = false; | 1647 GetAnyThread().waiting_for_meaningful_paint = false; |
| 1646 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 1648 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
| 1647 } | 1649 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1673 GetAnyThread().user_model.Reset(helper_.scheduler_tqm_delegate()->NowTicks()); | 1675 GetAnyThread().user_model.Reset(helper_.scheduler_tqm_delegate()->NowTicks()); |
| 1674 GetAnyThread().have_seen_a_potentially_blocking_gesture = false; | 1676 GetAnyThread().have_seen_a_potentially_blocking_gesture = false; |
| 1675 GetAnyThread().waiting_for_meaningful_paint = true; | 1677 GetAnyThread().waiting_for_meaningful_paint = true; |
| 1676 GetAnyThread().have_seen_input_since_navigation = false; | 1678 GetAnyThread().have_seen_input_since_navigation = false; |
| 1677 GetMainThreadOnly().loading_task_cost_estimator.Clear(); | 1679 GetMainThreadOnly().loading_task_cost_estimator.Clear(); |
| 1678 GetMainThreadOnly().timer_task_cost_estimator.Clear(); | 1680 GetMainThreadOnly().timer_task_cost_estimator.Clear(); |
| 1679 GetMainThreadOnly().idle_time_estimator.Clear(); | 1681 GetMainThreadOnly().idle_time_estimator.Clear(); |
| 1680 GetMainThreadOnly().have_seen_a_begin_main_frame = false; | 1682 GetMainThreadOnly().have_seen_a_begin_main_frame = false; |
| 1681 GetMainThreadOnly().have_reported_blocking_intervention_since_navigation = | 1683 GetMainThreadOnly().have_reported_blocking_intervention_since_navigation = |
| 1682 false; | 1684 false; |
| 1685 GetMainThreadOnly().max_queuing_time_histogram.reset(); | |
| 1686 GetMainThreadOnly().max_queuing_time = base::TimeDelta(); | |
| 1687 | |
| 1683 for (WebViewSchedulerImpl* web_view_scheduler : | 1688 for (WebViewSchedulerImpl* web_view_scheduler : |
| 1684 GetMainThreadOnly().web_view_schedulers) { | 1689 GetMainThreadOnly().web_view_schedulers) { |
| 1685 web_view_scheduler->OnNavigation(); | 1690 web_view_scheduler->OnNavigation(); |
| 1686 } | 1691 } |
| 1687 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 1692 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
| 1688 } | 1693 } |
| 1689 | 1694 |
| 1690 void RendererSchedulerImpl::SetTopLevelBlameContext( | 1695 void RendererSchedulerImpl::SetTopLevelBlameContext( |
| 1691 base::trace_event::BlameContext* blame_context) { | 1696 base::trace_event::BlameContext* blame_context) { |
| 1692 // Any task that runs in the default task runners belongs to the context of | 1697 // Any task that runs in the default task runners belongs to the context of |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 } | 1902 } |
| 1898 | 1903 |
| 1899 void RendererSchedulerImpl::RemoveTaskTimeObserver( | 1904 void RendererSchedulerImpl::RemoveTaskTimeObserver( |
| 1900 TaskTimeObserver* task_time_observer) { | 1905 TaskTimeObserver* task_time_observer) { |
| 1901 helper_.RemoveTaskTimeObserver(task_time_observer); | 1906 helper_.RemoveTaskTimeObserver(task_time_observer); |
| 1902 } | 1907 } |
| 1903 | 1908 |
| 1904 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( | 1909 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( |
| 1905 base::TimeDelta queueing_time, | 1910 base::TimeDelta queueing_time, |
| 1906 base::TimeTicks window_start_time) { | 1911 base::TimeTicks window_start_time) { |
| 1912 if (GetMainThreadOnly().during_navigation) { | |
| 1913 if (!GetMainThreadOnly().max_queuing_time_histogram) { | |
|
tdresser
2017/05/23 14:57:51
Add a comment about why we're instantiating this h
Liquan (Max) Gu
2017/05/25 16:27:28
Done.
| |
| 1914 GetMainThreadOnly().max_queuing_time_histogram = | |
| 1915 base::SingleSampleMetricsFactory::Get()->CreateCustomCountsMetric( | |
| 1916 "RendererScheduler.MaxQueueingTime", 1, 10000, 50); | |
| 1917 } | |
| 1918 if (GetMainThreadOnly().max_queuing_time < queueing_time) { | |
| 1919 GetMainThreadOnly().max_queuing_time_histogram->SetSample( | |
| 1920 GetMainThreadOnly().max_queuing_time.InMilliseconds()); | |
| 1921 GetMainThreadOnly().max_queuing_time = queueing_time; | |
| 1922 } | |
| 1923 } | |
| 1907 // RendererScheduler reports the queueing time once per window's duration. | 1924 // RendererScheduler reports the queueing time once per window's duration. |
| 1908 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT| | 1925 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT| |
| 1909 // Report: |-------window EQT------| | 1926 // Report: |-------window EQT------| |
| 1910 // Discard: |-------window EQT------| | 1927 // Discard: |-------window EQT------| |
| 1911 // Discard: |-------window EQT------| | 1928 // Discard: |-------window EQT------| |
| 1912 // Report: |-------window EQT------| | 1929 // Report: |-------window EQT------| |
| 1913 if (window_start_time - | 1930 if (window_start_time - |
| 1914 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time < | 1931 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time < |
| 1915 kQueueingTimeWindowDuration) { | 1932 kQueueingTimeWindowDuration) { |
| 1916 return; | 1933 return; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2054 case TimeDomainType::VIRTUAL: | 2071 case TimeDomainType::VIRTUAL: |
| 2055 return "virtual"; | 2072 return "virtual"; |
| 2056 default: | 2073 default: |
| 2057 NOTREACHED(); | 2074 NOTREACHED(); |
| 2058 return nullptr; | 2075 return nullptr; |
| 2059 } | 2076 } |
| 2060 } | 2077 } |
| 2061 | 2078 |
| 2062 } // namespace scheduler | 2079 } // namespace scheduler |
| 2063 } // namespace blink | 2080 } // namespace blink |
| OLD | NEW |