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 "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 3350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3361 | 3361 |
3362 scheduler_->SetAllRenderWidgetsHidden(true); | 3362 scheduler_->SetAllRenderWidgetsHidden(true); |
3363 EXPECT_EQ(UseCase::NONE, ForceUpdatePolicyAndGetCurrentUseCase()); | 3363 EXPECT_EQ(UseCase::NONE, ForceUpdatePolicyAndGetCurrentUseCase()); |
3364 EXPECT_EQ(v8::PERFORMANCE_IDLE, RAILMode()); | 3364 EXPECT_EQ(v8::PERFORMANCE_IDLE, RAILMode()); |
3365 scheduler_->SetAllRenderWidgetsHidden(false); | 3365 scheduler_->SetAllRenderWidgetsHidden(false); |
3366 EXPECT_EQ(UseCase::NONE, ForceUpdatePolicyAndGetCurrentUseCase()); | 3366 EXPECT_EQ(UseCase::NONE, ForceUpdatePolicyAndGetCurrentUseCase()); |
3367 EXPECT_EQ(v8::PERFORMANCE_ANIMATION, RAILMode()); | 3367 EXPECT_EQ(v8::PERFORMANCE_ANIMATION, RAILMode()); |
3368 scheduler_->SetRAILModeObserver(nullptr); | 3368 scheduler_->SetRAILModeObserver(nullptr); |
3369 } | 3369 } |
3370 | 3370 |
| 3371 TEST_F(RendererSchedulerImplTest, UnthrottledTaskRunner) { |
| 3372 // Ensure neither suspension nor timer task throttling affects an unthrottled |
| 3373 // task runner. |
| 3374 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); |
| 3375 scoped_refptr<TaskQueue> unthrottled_task_runner = |
| 3376 scheduler_->NewUnthrottledTaskRunner("unthrottled_tq"); |
| 3377 |
| 3378 size_t timer_count = 0; |
| 3379 size_t unthrottled_count = 0; |
| 3380 scheduler_->TimerTaskRunner()->PostTask( |
| 3381 FROM_HERE, base::Bind(SlowCountingTask, &timer_count, clock_.get(), 7, |
| 3382 scheduler_->TimerTaskRunner())); |
| 3383 unthrottled_task_runner->PostTask( |
| 3384 FROM_HERE, base::Bind(SlowCountingTask, &unthrottled_count, clock_.get(), |
| 3385 7, unthrottled_task_runner)); |
| 3386 scheduler_->SuspendTimerQueue(); |
| 3387 |
| 3388 for (int i = 0; i < 1000; i++) { |
| 3389 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( |
| 3390 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(), |
| 3391 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL); |
| 3392 begin_frame_args.on_critical_path = true; |
| 3393 scheduler_->WillBeginFrame(begin_frame_args); |
| 3394 scheduler_->DidHandleInputEventOnCompositorThread( |
| 3395 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate), |
| 3396 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR); |
| 3397 |
| 3398 simulate_compositor_task_ran_ = false; |
| 3399 compositor_task_runner_->PostTask( |
| 3400 FROM_HERE, |
| 3401 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask, |
| 3402 base::Unretained(this), |
| 3403 base::TimeDelta::FromMilliseconds(10))); |
| 3404 |
| 3405 mock_task_runner_->RunTasksWhile( |
| 3406 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending, |
| 3407 base::Unretained(this))); |
| 3408 EXPECT_EQ(UseCase::SYNCHRONIZED_GESTURE, CurrentUseCase()) << "i = " << i; |
| 3409 } |
| 3410 |
| 3411 EXPECT_EQ(0u, timer_count); |
| 3412 EXPECT_EQ(500u, unthrottled_count); |
| 3413 } |
| 3414 |
3371 } // namespace scheduler | 3415 } // namespace scheduler |
OLD | NEW |