Skip to content

Commit

Permalink
Move blink scheduler implementation into a component
Browse files Browse the repository at this point in the history
R=jam@chromium.org,skyostil@chromium.org,rmcilroy@chromium.org
BUG=477690

Review URL: https://codereview.chromium.org/1058873010

Cr-Commit-Position: refs/heads/master@{#326320}
  • Loading branch information
jeisinger authored and Commit bot committed Apr 22, 2015
1 parent 96b8a24 commit 83c639f
Show file tree
Hide file tree
Showing 111 changed files with 882 additions and 652 deletions.
1 change: 1 addition & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ exec_script_whitelist = [
"//clank/native/framework/BUILD.gn",

"//components/domain_reliability/BUILD.gn",
"//components/scheduler/scheduler.gni",
"//components/webui_generator/generator/wug.gni",
"//content/browser/browser.gni",
"//content/child/child.gni",
Expand Down
2 changes: 1 addition & 1 deletion WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
},
'scheduler': {
'filepath': 'cc/scheduler'\
'|content/child/scheduler'\
'|components/scheduler'\
'|content/renderer/scheduler'
},
'search': {
Expand Down
7 changes: 7 additions & 0 deletions components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ group("all_components") {
deps += [
"//components/app_modal",
"//components/browsing_data",
"//components/scheduler",
]
}

Expand Down Expand Up @@ -306,6 +307,10 @@ test("components_unittests") {
if (is_ios) {
deps -= [ "//components/devtools_http_handler:unit_tests" ]
}

if (!is_ios) {
deps += [ "//components/scheduler:unit_tests" ]
}
}

repack("components_tests_pak") {
Expand Down Expand Up @@ -379,6 +384,7 @@ test("components_browsertests") {

test("components_perftests") {
sources = [
"scheduler/child/task_queue_manager_perftest.cc",
"visitedlink/test/visitedlink_perftest.cc",
]

Expand All @@ -389,6 +395,7 @@ test("components_perftests") {
"//base",
"//base/test:test_support_perf",
"//testing/gtest",
"//testing/perf",
"//content/test:test_support",
"//components/visitedlink/browser",
]
Expand Down
17 changes: 17 additions & 0 deletions components/components_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@
'rappor/rappor_service_unittest.cc',
'rappor/rappor_utils_unittest.cc',
],
'scheduler_unittest_sources': [
'scheduler/child/nestable_task_runner_for_test.cc',
'scheduler/child/nestable_task_runner_for_test.h',
'scheduler/child/prioritizing_task_queue_selector_unittest.cc',
'scheduler/child/scheduler_helper_unittest.cc',
'scheduler/child/task_queue_manager_unittest.cc',
'scheduler/child/test_time_source.cc',
'scheduler/child/test_time_source.h',
'scheduler/child/worker_scheduler_impl_unittest.cc',
'scheduler/renderer/deadline_task_runner_unittest.cc',
'scheduler/renderer/renderer_scheduler_impl_unittest.cc',
],
'search_unittest_sources': [
'search/search_android_unittest.cc',
'search/search_unittest.cc',
Expand Down Expand Up @@ -815,6 +827,7 @@
'<@(navigation_interception_unittest_sources)',
'<@(network_hints_unittest_sources)',
'<@(power_unittest_sources)',
'<@(scheduler_unittest_sources)',
'<@(storage_monitor_unittest_sources)',
'<@(ui_unittest_sources)',
'<@(visitedlink_unittest_sources)',
Expand Down Expand Up @@ -849,6 +862,7 @@
'components.gyp:web_cache_browser',
'components.gyp:web_modal',
'components.gyp:web_modal_test_support',
'scheduler/scheduler.gyp:scheduler',
'webcrypto/webcrypto.gyp:webcrypto',
'../third_party/re2/re2.gyp:re2',
],
Expand Down Expand Up @@ -1120,12 +1134,15 @@
'../base/base.gyp:test_support_perf',
'../content/content_shell_and_tests.gyp:test_support_content',
'../testing/gtest.gyp:gtest',
'../testing/perf/perf_test.gyp:perf_test',
'components.gyp:visitedlink_browser',
'scheduler/scheduler.gyp:scheduler',
],
'include_dirs': [
'..',
],
'sources': [
'scheduler/child/task_queue_manager_perftest.cc',
'visitedlink/test/visitedlink_perftest.cc',
],
'conditions': [
Expand Down
56 changes: 56 additions & 0 deletions components/scheduler/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//components/scheduler/scheduler.gni")

# GYP version: components/scheduler.gypi:scheduler
component("scheduler") {
sources = rebase_path(scheduler_gypi_values.scheduler_sources,
".",
"//components/scheduler")

defines = [ "SCHEDULER_IMPLEMENTATION" ]

# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

deps = [
":common",
"//base",
"//cc:cc",
"//third_party/WebKit/public:blink",
"//ui/gfx:gfx",
]
}

# GYP version: components/scheduler.gypi:scheduler_common
source_set("common") {
sources = rebase_path(scheduler_gypi_values.scheduler_common_sources,
".",
"//components/scheduler")
}

source_set("unit_tests") {
testonly = true

sources = [
"child/nestable_task_runner_for_test.cc",
"child/nestable_task_runner_for_test.h",
"child/prioritizing_task_queue_selector_unittest.cc",
"child/scheduler_helper_unittest.cc",
"child/task_queue_manager_unittest.cc",
"child/test_time_source.cc",
"child/test_time_source.h",
"child/worker_scheduler_impl_unittest.cc",
"renderer/deadline_task_runner_unittest.cc",
"renderer/renderer_scheduler_impl_unittest.cc",
]

deps = [
":scheduler",
"//cc:test_support",
"//testing/gmock",
"//testing/gtest",
]
}
4 changes: 4 additions & 0 deletions components/scheduler/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"-components/scheduler",
"+components/scheduler/common",
]
File renamed without changes.
12 changes: 12 additions & 0 deletions components/scheduler/child/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include_rules = [
"+components/scheduler/common",
"+components/scheduler/scheduler_export.h",
"+third_party/WebKit/public/platform",
]

specific_include_rules = {
"(test_time_source|.*test)\.cc": [
"+cc/test",
"+content/test",
],
}
3 changes: 3 additions & 0 deletions components/scheduler/child/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alexclarke@chromium.org
rmcilroy@chromium.org
skyostil@chromium.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/child/scheduler/cancelable_closure_holder.h"
#include "components/scheduler/child/cancelable_closure_holder.h"

namespace content {
namespace scheduler {

CancelableClosureHolder::CancelableClosureHolder() {
}
Expand All @@ -27,4 +27,4 @@ const base::Closure& CancelableClosureHolder::callback() const {
return cancelable_callback_.callback();
}

} // namespace content
} // namespace scheduler
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_SCHEDULER_CANCELABLE_CLOSURE_HOLDER_H_
#define CONTENT_CHILD_SCHEDULER_CANCELABLE_CLOSURE_HOLDER_H_
#ifndef COMPONENTS_SCHEDULER_CHILD_CANCELABLE_CLOSURE_HOLDER_H_
#define COMPONENTS_SCHEDULER_CHILD_CANCELABLE_CLOSURE_HOLDER_H_

#include "base/cancelable_callback.h"

namespace content {
namespace scheduler {

// A CancelableClosureHolder is a CancelableCallback which resets its wrapped
// callback with a cached closure whenever it is canceled.
Expand All @@ -34,6 +34,6 @@ class CancelableClosureHolder {
DISALLOW_COPY_AND_ASSIGN(CancelableClosureHolder);
};

} // namespace content
} // namespace scheduler

#endif // CONTENT_CHILD_SCHEDULER_CANCELABLE_CLOSURE_HOLDER_H_
#endif // COMPONENTS_SCHEDULER_CHILD_CANCELABLE_CLOSURE_HOLDER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
#define CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
#ifndef COMPONENTS_SCHEDULER_CHILD_CHILD_SCHEDULER_H_
#define COMPONENTS_SCHEDULER_CHILD_CHILD_SCHEDULER_H_

#include "base/message_loop/message_loop.h"
#include "content/child/scheduler/single_thread_idle_task_runner.h"
#include "content/common/content_export.h"
#include "components/scheduler/child/single_thread_idle_task_runner.h"
#include "components/scheduler/scheduler_export.h"

namespace base {
class MessageLoop;
}

namespace content {
namespace scheduler {

class CONTENT_EXPORT ChildScheduler {
class SCHEDULER_EXPORT ChildScheduler {
public:
virtual ~ChildScheduler() { }
virtual ~ChildScheduler() {}

// Returns the default task runner.
virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0;
Expand Down Expand Up @@ -58,10 +58,10 @@ class CONTENT_EXPORT ChildScheduler {
virtual void Shutdown() = 0;

protected:
ChildScheduler() { }
ChildScheduler() {}
DISALLOW_COPY_AND_ASSIGN(ChildScheduler);
};

} // namespace content
} // namespace scheduler

#endif // CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
#endif // COMPONENTS_SCHEDULER_CHILD_CHILD_SCHEDULER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_SCHEDULER_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_
#define CONTENT_CHILD_SCHEDULER_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_
#ifndef COMPONENTS_SCHEDULER_CHILD_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_
#define COMPONENTS_SCHEDULER_CHILD_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_

#include "base/single_thread_task_runner.h"
#include "content/common/content_export.h"
#include "components/scheduler/scheduler_export.h"

namespace content {
namespace scheduler {

// A single thread task runner which exposes whether it is running nested.
class CONTENT_EXPORT NestableSingleThreadTaskRunner
class SCHEDULER_EXPORT NestableSingleThreadTaskRunner
: public base::SingleThreadTaskRunner {
public:
NestableSingleThreadTaskRunner() {}
Expand All @@ -26,6 +26,6 @@ class CONTENT_EXPORT NestableSingleThreadTaskRunner
DISALLOW_COPY_AND_ASSIGN(NestableSingleThreadTaskRunner);
};

} // namespace content
} // namespace scheduler

#endif // CONTENT_CHILD_SCHEDULER_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_
#endif // COMPONENTS_SCHEDULER_CHILD_NESTABLE_SINGLE_THREAD_TASK_RUNNER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/child/scheduler/nestable_task_runner_for_test.h"
#include "components/scheduler/child/nestable_task_runner_for_test.h"

namespace content {
namespace scheduler {

// static
scoped_refptr<NestableTaskRunnerForTest> NestableTaskRunnerForTest::Create(
Expand Down Expand Up @@ -46,4 +46,4 @@ void NestableTaskRunnerForTest::SetNested(bool is_nested) {
is_nested_ = is_nested;
}

} // namespace content
} // namespace scheduler
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#ifndef CONTENT_RENDERER_SCHEDULER_NESTABLE_TASK_RUNNER_FOR_TEST_H_
#define CONTENT_RENDERER_SCHEDULER_NESTABLE_TASK_RUNNER_FOR_TEST_H_

#include "content/child/scheduler/nestable_single_thread_task_runner.h"
#include "components/scheduler/child/nestable_single_thread_task_runner.h"

namespace content {
namespace scheduler {

class NestableTaskRunnerForTest : public NestableSingleThreadTaskRunner {
public:
Expand Down Expand Up @@ -39,6 +39,6 @@ class NestableTaskRunnerForTest : public NestableSingleThreadTaskRunner {
DISALLOW_COPY_AND_ASSIGN(NestableTaskRunnerForTest);
};

} // namespace content
} // namespace scheduler

#endif // CONTENT_RENDERER_SCHEDULER_NESTABLE_TASK_RUNNER_FOR_TEST_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/child/scheduler/null_idle_task_runner.h"
#include "components/scheduler/child/null_idle_task_runner.h"

namespace content {
namespace scheduler {

NullIdleTaskRunner::NullIdleTaskRunner()
: SingleThreadIdleTaskRunner(nullptr,
Expand All @@ -27,8 +27,8 @@ void NullIdleTaskRunner::PostNonNestableIdleTask(
}

void NullIdleTaskRunner::PostIdleTaskAfterWakeup(
const tracked_objects::Location& from_here,
const IdleTask& idle_task) {
const tracked_objects::Location& from_here,
const IdleTask& idle_task) {
}

} // namespace content
} // namespace scheduler
33 changes: 33 additions & 0 deletions components/scheduler/child/null_idle_task_runner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SCHEDULER_CHILD_NULL_IDLE_TASK_RUNNER_H_
#define COMPONENTS_SCHEDULER_CHILD_NULL_IDLE_TASK_RUNNER_H_

#include "components/scheduler/child/single_thread_idle_task_runner.h"

namespace scheduler {

class NullIdleTaskRunner : public SingleThreadIdleTaskRunner {
public:
NullIdleTaskRunner();
void PostIdleTask(const tracked_objects::Location& from_here,
const IdleTask& idle_task) override;

void PostNonNestableIdleTask(const tracked_objects::Location& from_here,
const IdleTask& idle_task) override;

void PostIdleTaskAfterWakeup(const tracked_objects::Location& from_here,
const IdleTask& idle_task) override;

protected:
~NullIdleTaskRunner() override;

private:
DISALLOW_COPY_AND_ASSIGN(NullIdleTaskRunner);
};

} // namespace scheduler

#endif // COMPONENTS_SCHEDULER_CHILD_NULL_IDLE_TASK_RUNNER_H_
Loading

0 comments on commit 83c639f

Please sign in to comment.