Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2909293002: Allow tasks scheduled for the instant virtual time budges expires to run (Closed)
Patch Set: Fix Fix DevTools test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 timer_tasks_seem_expensive(false), 212 timer_tasks_seem_expensive(false),
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_suspended(false),
222 rail_mode_observer(nullptr), 223 rail_mode_observer(nullptr),
223 wake_up_budget_pool(nullptr), 224 wake_up_budget_pool(nullptr),
224 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet( 225 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet(
225 "RendererScheduler.TaskDurationPerQueueType2", 226 "RendererScheduler.TaskDurationPerQueueType2",
226 1, 227 1,
227 static_cast<int>(TaskQueue::QueueType::COUNT), 228 static_cast<int>(TaskQueue::QueueType::COUNT),
228 static_cast<int>(TaskQueue::QueueType::COUNT) + 1, 229 static_cast<int>(TaskQueue::QueueType::COUNT) + 1,
229 base::HistogramBase::kUmaTargetedHistogramFlag)) { 230 base::HistogramBase::kUmaTargetedHistogramFlag)) {
230 foreground_main_thread_load_tracker.Resume(now); 231 foreground_main_thread_load_tracker.Resume(now);
231 } 232 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 auto insert_result = timer_task_runners_.insert(std::make_pair( 364 auto insert_result = timer_task_runners_.insert(std::make_pair(
364 timer_task_queue, timer_task_queue->CreateQueueEnabledVoter())); 365 timer_task_queue, timer_task_queue->CreateQueueEnabledVoter()));
365 insert_result.first->second->SetQueueEnabled( 366 insert_result.first->second->SetQueueEnabled(
366 GetMainThreadOnly().current_policy.timer_queue_policy.is_enabled); 367 GetMainThreadOnly().current_policy.timer_queue_policy.is_enabled);
367 timer_task_queue->SetQueuePriority( 368 timer_task_queue->SetQueuePriority(
368 GetMainThreadOnly().current_policy.timer_queue_policy.priority); 369 GetMainThreadOnly().current_policy.timer_queue_policy.priority);
369 if (GetMainThreadOnly().current_policy.timer_queue_policy.time_domain_type == 370 if (GetMainThreadOnly().current_policy.timer_queue_policy.time_domain_type ==
370 TimeDomainType::THROTTLED) { 371 TimeDomainType::THROTTLED) {
371 task_queue_throttler_->IncreaseThrottleRefCount(timer_task_queue.get()); 372 task_queue_throttler_->IncreaseThrottleRefCount(timer_task_queue.get());
372 } 373 }
374 if (GetMainThreadOnly().virtual_time_suspended)
altimin 2017/05/31 11:44:06 Is virtual_time_expired a better name?
alex clarke (OOO till 29th) 2017/05/31 15:11:36 virtual_time_paused is possibly the most accurate
alex clarke (OOO till 29th) 2017/05/31 16:48:48 I understand Alexander has a strong preference for
altimin 2017/05/31 16:51:24 Yes, it makes sense, thanks for the explanation.
375 timer_task_queue->InsertFence(TaskQueue::InsertFencePosition::NOW);
373 timer_task_queue->AddTaskObserver( 376 timer_task_queue->AddTaskObserver(
374 &GetMainThreadOnly().timer_task_cost_estimator); 377 &GetMainThreadOnly().timer_task_cost_estimator);
375 AddQueueToWakeUpBudgetPool(timer_task_queue.get()); 378 AddQueueToWakeUpBudgetPool(timer_task_queue.get());
376 return timer_task_queue; 379 return timer_task_queue;
377 } 380 }
378 381
379 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewUnthrottledTaskQueue( 382 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewUnthrottledTaskQueue(
380 TaskQueue::QueueType queue_type) { 383 TaskQueue::QueueType queue_type) {
381 helper_.CheckOnValidThread(); 384 helper_.CheckOnValidThread();
382 scoped_refptr<TaskQueue> unthrottled_task_queue(helper_.NewTaskQueue( 385 scoped_refptr<TaskQueue> unthrottled_task_queue(helper_.NewTaskQueue(
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 } 1409 }
1407 #endif 1410 #endif
1408 } 1411 }
1409 1412
1410 void RendererSchedulerImpl::ResumeTimerQueue() { 1413 void RendererSchedulerImpl::ResumeTimerQueue() {
1411 GetMainThreadOnly().timer_queue_suspend_count--; 1414 GetMainThreadOnly().timer_queue_suspend_count--;
1412 DCHECK_GE(GetMainThreadOnly().timer_queue_suspend_count, 0); 1415 DCHECK_GE(GetMainThreadOnly().timer_queue_suspend_count, 0);
1413 ForceUpdatePolicy(); 1416 ForceUpdatePolicy();
1414 } 1417 }
1415 1418
1419 void RendererSchedulerImpl::InsertTimerFence() {
1420 GetMainThreadOnly().virtual_time_suspended = true;
1421 for (const auto& pair : timer_task_runners_) {
1422 DCHECK(!task_queue_throttler_->IsThrottled(pair.first.get()));
altimin 2017/05/31 11:44:06 Also DCHECK for not having a fence already and vir
alex clarke (OOO till 29th) 2017/05/31 15:11:36 Done.
1423 pair.first->InsertFence(TaskQueue::InsertFencePosition::NOW);
1424 }
1425 }
1426
1427 void RendererSchedulerImpl::RemoveTimerFence() {
1428 GetMainThreadOnly().virtual_time_suspended = false;
1429 for (const auto& pair : timer_task_runners_) {
1430 DCHECK(!task_queue_throttler_->IsThrottled(pair.first.get()));
1431 pair.first->RemoveFence();
1432 }
1433 }
1434
1416 void RendererSchedulerImpl::SetTimerQueueSuspensionWhenBackgroundedEnabled( 1435 void RendererSchedulerImpl::SetTimerQueueSuspensionWhenBackgroundedEnabled(
1417 bool enabled) { 1436 bool enabled) {
1418 // Note that this will only take effect for the next backgrounded signal. 1437 // Note that this will only take effect for the next backgrounded signal.
1419 GetMainThreadOnly().timer_queue_suspension_when_backgrounded_enabled = 1438 GetMainThreadOnly().timer_queue_suspension_when_backgrounded_enabled =
1420 enabled; 1439 enabled;
1421 } 1440 }
1422 1441
1423 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1442 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1424 RendererSchedulerImpl::AsValue(base::TimeTicks optional_now) const { 1443 RendererSchedulerImpl::AsValue(base::TimeTicks optional_now) const {
1425 base::AutoLock lock(any_thread_lock_); 1444 base::AutoLock lock(any_thread_lock_);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 GetAnyThread().default_gesture_prevented); 1539 GetAnyThread().default_gesture_prevented);
1521 state->SetDouble("expected_loading_task_duration", 1540 state->SetDouble("expected_loading_task_duration",
1522 GetMainThreadOnly() 1541 GetMainThreadOnly()
1523 .loading_task_cost_estimator.expected_task_duration() 1542 .loading_task_cost_estimator.expected_task_duration()
1524 .InMillisecondsF()); 1543 .InMillisecondsF());
1525 state->SetDouble("expected_timer_task_duration", 1544 state->SetDouble("expected_timer_task_duration",
1526 GetMainThreadOnly() 1545 GetMainThreadOnly()
1527 .timer_task_cost_estimator.expected_task_duration() 1546 .timer_task_cost_estimator.expected_task_duration()
1528 .InMillisecondsF()); 1547 .InMillisecondsF());
1529 state->SetBoolean("is_audio_playing", GetMainThreadOnly().is_audio_playing); 1548 state->SetBoolean("is_audio_playing", GetMainThreadOnly().is_audio_playing);
1549 state->SetBoolean("virtual_time_suspended",
1550 GetMainThreadOnly().virtual_time_suspended);
1530 1551
1531 state->BeginDictionary("web_view_schedulers"); 1552 state->BeginDictionary("web_view_schedulers");
1532 for (WebViewSchedulerImpl* web_view_scheduler : 1553 for (WebViewSchedulerImpl* web_view_scheduler :
1533 GetMainThreadOnly().web_view_schedulers) { 1554 GetMainThreadOnly().web_view_schedulers) {
1534 state->BeginDictionaryWithCopiedName( 1555 state->BeginDictionaryWithCopiedName(
1535 trace_helper::PointerToString(web_view_scheduler)); 1556 trace_helper::PointerToString(web_view_scheduler));
1536 web_view_scheduler->AsValueInto(state.get()); 1557 web_view_scheduler->AsValueInto(state.get());
1537 state->EndDictionary(); 1558 state->EndDictionary();
1538 } 1559 }
1539 state->EndDictionary(); 1560 state->EndDictionary();
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 case TimeDomainType::VIRTUAL: 2078 case TimeDomainType::VIRTUAL:
2058 return "virtual"; 2079 return "virtual";
2059 default: 2080 default:
2060 NOTREACHED(); 2081 NOTREACHED();
2061 return nullptr; 2082 return nullptr;
2062 } 2083 }
2063 } 2084 }
2064 2085
2065 } // namespace scheduler 2086 } // namespace scheduler
2066 } // namespace blink 2087 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698