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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_IMPL_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_IMPL_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_IMPL_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_IMPL_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
9 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
13 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
14 #include "base/trace_event/trace_log.h" | 16 #include "base/trace_event/trace_log.h" |
15 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" | 17 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" |
16 #include "platform/scheduler/base/pollable_thread_safe_flag.h" | 18 #include "platform/scheduler/base/pollable_thread_safe_flag.h" |
17 #include "platform/scheduler/base/queueing_time_estimator.h" | 19 #include "platform/scheduler/base/queueing_time_estimator.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // A continuous gesture (e.g., scroll) which is being handled by the main | 78 // A continuous gesture (e.g., scroll) which is being handled by the main |
77 // thread. | 79 // thread. |
78 MAIN_THREAD_GESTURE, | 80 MAIN_THREAD_GESTURE, |
79 // Must be the last entry. | 81 // Must be the last entry. |
80 USE_CASE_COUNT, | 82 USE_CASE_COUNT, |
81 FIRST_USE_CASE = NONE, | 83 FIRST_USE_CASE = NONE, |
82 }; | 84 }; |
83 static const char* UseCaseToString(UseCase use_case); | 85 static const char* UseCaseToString(UseCase use_case); |
84 static const char* RAILModeToString(v8::RAILMode rail_mode); | 86 static const char* RAILModeToString(v8::RAILMode rail_mode); |
85 | 87 |
86 RendererSchedulerImpl(scoped_refptr<SchedulerTqmDelegate> main_task_runner); | 88 RendererSchedulerImpl( |
| 89 scoped_refptr<SchedulerTqmDelegate> main_task_runner, |
| 90 RendererType type = RendererType::kForegroundAndBackground); |
87 ~RendererSchedulerImpl() override; | 91 ~RendererSchedulerImpl() override; |
88 | 92 |
89 // RendererScheduler implementation: | 93 // RendererScheduler implementation: |
90 std::unique_ptr<WebThread> CreateMainThread() override; | 94 std::unique_ptr<WebThread> CreateMainThread() override; |
91 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; | 95 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; |
92 std::unique_ptr<RenderWidgetSchedulingState> NewRenderWidgetSchedulingState() | 96 std::unique_ptr<RenderWidgetSchedulingState> NewRenderWidgetSchedulingState() |
93 override; | 97 override; |
94 void WillBeginFrame(const cc::BeginFrameArgs& args) override; | 98 void WillBeginFrame(const cc::BeginFrameArgs& args) override; |
95 void BeginFrameNotExpectedSoon() override; | 99 void BeginFrameNotExpectedSoon() override; |
96 void BeginMainFrameNotExpectedUntil(base::TimeTicks time) override; | 100 void BeginMainFrameNotExpectedUntil(base::TimeTicks time) override; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 452 |
449 SeqLockQueueingTimeEstimator seqlock_queueing_time_estimator_; | 453 SeqLockQueueingTimeEstimator seqlock_queueing_time_estimator_; |
450 | 454 |
451 // We have decided to improve thread safety at the cost of some boilerplate | 455 // We have decided to improve thread safety at the cost of some boilerplate |
452 // (the accessors) for the following data members. | 456 // (the accessors) for the following data members. |
453 | 457 |
454 struct MainThreadOnly { | 458 struct MainThreadOnly { |
455 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl, | 459 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl, |
456 const scoped_refptr<TaskQueue>& compositor_task_runner, | 460 const scoped_refptr<TaskQueue>& compositor_task_runner, |
457 base::TickClock* time_source, | 461 base::TickClock* time_source, |
458 base::TimeTicks now); | 462 base::TimeTicks now, |
| 463 RendererType type); |
459 ~MainThreadOnly(); | 464 ~MainThreadOnly(); |
460 | 465 |
461 TaskCostEstimator loading_task_cost_estimator; | 466 TaskCostEstimator loading_task_cost_estimator; |
462 TaskCostEstimator timer_task_cost_estimator; | 467 TaskCostEstimator timer_task_cost_estimator; |
463 IdleTimeEstimator idle_time_estimator; | 468 IdleTimeEstimator idle_time_estimator; |
464 ThreadLoadTracker background_main_thread_load_tracker; | 469 std::unique_ptr<ThreadLoadTracker> background_main_thread_load_tracker; |
465 ThreadLoadTracker foreground_main_thread_load_tracker; | 470 std::unique_ptr<ThreadLoadTracker> foreground_main_thread_load_tracker; |
| 471 std::unique_ptr<ThreadLoadTracker> foreground_only_main_thread_load_tracker; |
466 UseCase current_use_case; | 472 UseCase current_use_case; |
467 Policy current_policy; | 473 Policy current_policy; |
468 base::TimeTicks current_policy_expiration_time; | 474 base::TimeTicks current_policy_expiration_time; |
469 base::TimeTicks estimated_next_frame_begin; | 475 base::TimeTicks estimated_next_frame_begin; |
470 base::TimeTicks current_task_start_time; | 476 base::TimeTicks current_task_start_time; |
471 base::TimeTicks uma_last_queueing_time_report_window_start_time; | 477 base::TimeTicks uma_last_queueing_time_report_window_start_time; |
472 base::TimeDelta compositor_frame_interval; | 478 base::TimeDelta compositor_frame_interval; |
473 base::TimeDelta longest_jank_free_task_duration; | 479 base::TimeDelta longest_jank_free_task_duration; |
474 base::Optional<base::TimeTicks> last_audio_state_change; | 480 base::Optional<base::TimeTicks> last_audio_state_change; |
475 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. | 481 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 #if DCHECK_IS_ON() | 536 #if DCHECK_IS_ON() |
531 // We don't actually care which thread this called from, just so long as | 537 // We don't actually care which thread this called from, just so long as |
532 // its consistent. | 538 // its consistent. |
533 if (!compositor_thread_checker) | 539 if (!compositor_thread_checker) |
534 compositor_thread_checker.reset(new base::ThreadChecker()); | 540 compositor_thread_checker.reset(new base::ThreadChecker()); |
535 DCHECK(compositor_thread_checker->CalledOnValidThread()); | 541 DCHECK(compositor_thread_checker->CalledOnValidThread()); |
536 #endif | 542 #endif |
537 } | 543 } |
538 }; | 544 }; |
539 | 545 |
| 546 RendererType type_; |
| 547 |
540 // Don't access main_thread_only_, instead use MainThreadOnly(). | 548 // Don't access main_thread_only_, instead use MainThreadOnly(). |
541 MainThreadOnly main_thread_only_; | 549 MainThreadOnly main_thread_only_; |
542 MainThreadOnly& GetMainThreadOnly() { | 550 MainThreadOnly& GetMainThreadOnly() { |
543 helper_.CheckOnValidThread(); | 551 helper_.CheckOnValidThread(); |
544 return main_thread_only_; | 552 return main_thread_only_; |
545 } | 553 } |
546 const struct MainThreadOnly& GetMainThreadOnly() const { | 554 const struct MainThreadOnly& GetMainThreadOnly() const { |
547 helper_.CheckOnValidThread(); | 555 helper_.CheckOnValidThread(); |
548 return main_thread_only_; | 556 return main_thread_only_; |
549 } | 557 } |
(...skipping 21 matching lines...) Expand all Loading... |
571 | 579 |
572 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 580 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
573 | 581 |
574 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 582 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
575 }; | 583 }; |
576 | 584 |
577 } // namespace scheduler | 585 } // namespace scheduler |
578 } // namespace blink | 586 } // namespace blink |
579 | 587 |
580 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ | 588 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ |
OLD | NEW |