Allow configurable idle period names in tracing, so the schedulers
[chromium-blink-merge.git] / content / renderer / scheduler / renderer_scheduler.cc
blob0ecba8c1bc90076d9852f34f968ba1001d37bf21
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 "content/renderer/scheduler/renderer_scheduler.h"
7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_impl.h"
11 #include "content/child/scheduler/scheduler_message_loop_delegate.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/renderer/scheduler/null_renderer_scheduler.h"
14 #include "content/renderer/scheduler/renderer_scheduler_impl.h"
16 namespace content {
18 RendererScheduler::RendererScheduler() {
21 RendererScheduler::~RendererScheduler() {
24 // static
25 scoped_ptr<RendererScheduler> RendererScheduler::Create() {
26 // Ensure worker.scheduler appears as an option in about://tracing
27 base::trace_event::TraceLog::GetCategoryGroupEnabled(
28 TRACE_DISABLED_BY_DEFAULT("worker.scheduler"));
30 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
31 if (command_line->HasSwitch(switches::kDisableBlinkScheduler)) {
32 return make_scoped_ptr(new NullRendererScheduler());
33 } else {
34 base::MessageLoop* message_loop = base::MessageLoop::current();
35 return make_scoped_ptr(new RendererSchedulerImpl(
36 SchedulerMessageLoopDelegate::Create(message_loop)));
40 } // namespace content