Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / scheduler / renderer / renderer_scheduler.cc
blob20d663437a961ce27d4ff5dd8bc90dc52a13247f
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
3 // found in the LICENSE file.
5 #include "components/scheduler/renderer/renderer_scheduler.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/trace_event/trace_event.h"
9 #include "base/trace_event/trace_event_impl.h"
10 #include "components/scheduler/child/scheduler_task_runner_delegate_impl.h"
11 #include "components/scheduler/renderer/renderer_scheduler_impl.h"
13 namespace scheduler {
15 RendererScheduler::RendererScheduler() {
18 RendererScheduler::~RendererScheduler() {
21 // static
22 scoped_ptr<RendererScheduler> RendererScheduler::Create() {
23 // Ensure worker.scheduler, worker.scheduler.debug and
24 // renderer.scheduler.debug appear as an option in about://tracing
25 base::trace_event::TraceLog::GetCategoryGroupEnabled(
26 TRACE_DISABLED_BY_DEFAULT("worker.scheduler"));
27 base::trace_event::TraceLog::GetCategoryGroupEnabled(
28 TRACE_DISABLED_BY_DEFAULT("worker.scheduler.debug"));
29 base::trace_event::TraceLog::GetCategoryGroupEnabled(
30 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug"));
32 base::MessageLoop* message_loop = base::MessageLoop::current();
33 return make_scoped_ptr(new RendererSchedulerImpl(
34 SchedulerTaskRunnerDelegateImpl::Create(message_loop)));
37 // static
38 const char* RendererScheduler::UseCaseToString(UseCase use_case) {
39 switch (use_case) {
40 case UseCase::NONE:
41 return "none";
42 case UseCase::COMPOSITOR_GESTURE:
43 return "compositor_gesture";
44 case UseCase::MAIN_THREAD_GESTURE:
45 return "main_thread_gesture";
46 case UseCase::TOUCHSTART:
47 return "touchstart";
48 case UseCase::LOADING:
49 return "loading";
50 default:
51 NOTREACHED();
52 return nullptr;
56 // static
57 const char* RendererScheduler::InputEventStateToString(
58 InputEventState input_event_state) {
59 switch (input_event_state) {
60 case InputEventState::EVENT_CONSUMED_BY_COMPOSITOR:
61 return "event_consumed_by_compositor";
62 case InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD:
63 return "event_forwarded_to_main_thread";
64 default:
65 NOTREACHED();
66 return nullptr;
70 } // namespace scheduler