Commit 305c7176 authored by Greg Kraynov's avatar Greg Kraynov Committed by Commit Bot

Blink Scheduler: Remove TaskType references from schduler/base.

When scheduler/base will be moved to //base we can't use Blink types.

Bug: 783309
Change-Id: I1d9bada5a08129a885e9fe6d2f75a02c80e03183
Reviewed-on: https://chromium-review.googlesource.com/943565Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Greg Kraynov <kraynov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541408}
parent 596b64d7
......@@ -42,7 +42,7 @@ TaskQueue::PostedTask::PostedTask(base::OnceClosure callback,
base::Location posted_from,
base::TimeDelta delay,
base::Nestable nestable,
base::Optional<TaskType> task_type)
int task_type)
: callback(std::move(callback)),
posted_from(posted_from),
delay(delay),
......
......@@ -16,7 +16,6 @@
#include "platform/PlatformExport.h"
#include "platform/scheduler/base/graceful_queue_shutdown_helper.h"
#include "platform/scheduler/base/moveable_auto_lock.h"
#include "public/platform/TaskType.h"
namespace base {
namespace trace_event {
......@@ -62,13 +61,13 @@ class PLATFORM_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
base::Location posted_from,
base::TimeDelta delay = base::TimeDelta(),
base::Nestable nestable = base::Nestable::kNestable,
base::Optional<TaskType> task_type = base::nullopt);
int task_type = 0);
base::OnceClosure callback;
base::Location posted_from;
base::TimeDelta delay;
base::Nestable nestable;
base::Optional<TaskType> task_type;
int task_type;
};
// Unregisters the task queue after which no tasks posted to it will run and
......@@ -135,10 +134,10 @@ class PLATFORM_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
public:
Task(PostedTask posted_task, base::TimeTicks desired_run_time);
base::Optional<TaskType> task_type() const { return task_type_; }
int task_type() const { return task_type_; }
private:
base::Optional<TaskType> task_type_;
int task_type_;
};
// An interface that lets the owner vote on whether or not the associated
......
......@@ -16,7 +16,7 @@ namespace scheduler {
scoped_refptr<TaskRunnerImpl> TaskRunnerImpl::Create(
scoped_refptr<TaskQueue> task_queue,
base::Optional<TaskType> task_type) {
TaskType task_type) {
return base::WrapRefCounted(
new TaskRunnerImpl(std::move(task_queue), task_type));
}
......@@ -26,7 +26,7 @@ bool TaskRunnerImpl::RunsTasksInCurrentSequence() const {
}
TaskRunnerImpl::TaskRunnerImpl(scoped_refptr<TaskQueue> task_queue,
base::Optional<TaskType> task_type)
TaskType task_type)
: task_queue_(std::move(task_queue)), task_type_(task_type) {}
TaskRunnerImpl::~TaskRunnerImpl() = default;
......@@ -35,15 +35,16 @@ bool TaskRunnerImpl::PostDelayedTask(const base::Location& location,
base::OnceClosure task,
base::TimeDelta delay) {
return task_queue_->PostTaskWithMetadata(TaskQueue::PostedTask(
std::move(task), location, delay, base::Nestable::kNestable, task_type_));
std::move(task), location, delay, base::Nestable::kNestable,
static_cast<int>(task_type_)));
}
bool TaskRunnerImpl::PostNonNestableDelayedTask(const base::Location& location,
base::OnceClosure task,
base::TimeDelta delay) {
return task_queue_->PostTaskWithMetadata(
TaskQueue::PostedTask(std::move(task), location, delay,
base::Nestable::kNonNestable, task_type_));
return task_queue_->PostTaskWithMetadata(TaskQueue::PostedTask(
std::move(task), location, delay, base::Nestable::kNonNestable,
static_cast<int>(task_type_)));
}
} // namespace scheduler
......
......@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/optional.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "platform/PlatformExport.h"
......@@ -24,7 +23,7 @@ class PLATFORM_EXPORT TaskRunnerImpl : public base::SingleThreadTaskRunner {
public:
static scoped_refptr<TaskRunnerImpl> Create(
scoped_refptr<TaskQueue> task_queue,
base::Optional<TaskType> task_type);
TaskType task_type);
// base::SingleThreadTaskRunner implementation:
bool RunsTasksInCurrentSequence() const override;
......@@ -40,12 +39,11 @@ class PLATFORM_EXPORT TaskRunnerImpl : public base::SingleThreadTaskRunner {
base::TimeDelta) override;
private:
TaskRunnerImpl(scoped_refptr<TaskQueue> task_queue,
base::Optional<TaskType> task_type);
TaskRunnerImpl(scoped_refptr<TaskQueue> task_queue, TaskType task_type);
~TaskRunnerImpl() override;
scoped_refptr<TaskQueue> task_queue_;
base::Optional<TaskType> task_type_;
TaskType task_type_;
DISALLOW_COPY_AND_ASSIGN(TaskRunnerImpl);
};
......
......@@ -15,14 +15,15 @@
namespace blink {
namespace scheduler {
// TODO(kraynov): Ditch kDeprecatedNone here.
WebSchedulerImpl::WebSchedulerImpl(
ChildScheduler* child_scheduler,
scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner,
scoped_refptr<TaskQueue> v8_task_runner)
: child_scheduler_(child_scheduler),
idle_task_runner_(idle_task_runner),
v8_task_runner_(
TaskRunnerImpl::Create(std::move(v8_task_runner), base::nullopt)) {}
v8_task_runner_(TaskRunnerImpl::Create(std::move(v8_task_runner),
TaskType::kDeprecatedNone)) {}
WebSchedulerImpl::~WebSchedulerImpl() = default;
......
......@@ -31,6 +31,7 @@ void WorkerGlobalScopeScheduler::Dispose() {
scoped_refptr<base::SingleThreadTaskRunner>
WorkerGlobalScopeScheduler::GetTaskRunner(TaskType type) const {
switch (type) {
case TaskType::kDeprecatedNone:
case TaskType::kDOMManipulation:
case TaskType::kUserInteraction:
case TaskType::kNetworking:
......
......@@ -29,14 +29,12 @@ void WorkerMetricsHelper::RecordTaskMetrics(
thread_time);
if (thread_type_ == WebThreadType::kDedicatedWorkerThread) {
base::Optional<TaskType> task_type = task.task_type();
TaskType task_type = static_cast<TaskType>(task.task_type());
dedicated_worker_per_task_type_duration_reporter_.RecordTask(
task_type ? task_type.value() : static_cast<TaskType>(0),
end_time - start_time);
task_type, end_time - start_time);
if (thread_time) {
dedicated_worker_per_task_type_cpu_duration_reporter_.RecordTask(
task_type ? task_type.value() : static_cast<TaskType>(0),
thread_time.value());
task_type, thread_time.value());
}
}
}
......
......@@ -355,9 +355,8 @@ void RendererMetricsHelper::RecordTaskMetrics(
frame_status, FrameStatus::kCount);
}
base::Optional<TaskType> task_type = task.task_type();
per_task_type_duration_reporter.RecordTask(
task_type ? task_type.value() : static_cast<TaskType>(0), duration);
static_cast<TaskType>(task.task_type()), duration);
}
void RendererMetricsHelper::RecordMainThreadTaskLoad(base::TimeTicks time,
......
......@@ -14,6 +14,7 @@
#include "platform/scheduler/renderer/main_thread_task_queue.h"
#include "platform/scheduler/util/task_duration_metric_reporter.h"
#include "platform/scheduler/util/thread_load_tracker.h"
#include "public/platform/TaskType.h"
#include "public/platform/WebThreadType.h"
namespace blink {
......
......@@ -122,6 +122,8 @@ bool StopLoadingInBackgroundEnabled() {
const char* TaskTypeToString(TaskType task_type) {
switch (task_type) {
case TaskType::kDeprecatedNone:
return "None";
case TaskType::kDOMManipulation:
return "DOMManipultion";
case TaskType::kUserInteraction:
......@@ -195,8 +197,8 @@ const char* OptionalTaskDescriptionToString(
base::Optional<RendererSchedulerImpl::TaskDescriptionForTracing> opt_desc) {
if (!opt_desc)
return nullptr;
if (opt_desc->task_type)
return TaskTypeToString(opt_desc->task_type.value());
if (opt_desc->task_type != TaskType::kDeprecatedNone)
return TaskTypeToString(opt_desc->task_type);
return MainThreadTaskQueue::NameForQueueType(opt_desc->queue_type);
}
......@@ -2444,8 +2446,8 @@ void RendererSchedulerImpl::OnTaskStarted(MainThreadTaskQueue* queue,
seqlock_queueing_time_estimator_.seqlock.WriteBegin();
seqlock_queueing_time_estimator_.data.OnTopLevelTaskStarted(start, queue);
seqlock_queueing_time_estimator_.seqlock.WriteEnd();
main_thread_only().task_description_for_tracing =
TaskDescriptionForTracing{task.task_type(), queue->queue_type()};
main_thread_only().task_description_for_tracing = TaskDescriptionForTracing{
static_cast<TaskType>(task.task_type()), queue->queue_type()};
}
void RendererSchedulerImpl::OnTaskCompleted(
......
......@@ -93,7 +93,7 @@ class PLATFORM_EXPORT RendererSchedulerImpl
// Don't use except for tracing.
struct TaskDescriptionForTracing {
base::Optional<TaskType> task_type;
TaskType task_type;
MainThreadTaskQueue::QueueType queue_type;
// Required in order to wrap in TraceableState.
......
......@@ -16,6 +16,7 @@
namespace blink {
namespace scheduler {
// TODO(kraynov): Ditch kDeprecatedNone here.
RendererWebSchedulerImpl::RendererWebSchedulerImpl(
RendererSchedulerImpl* renderer_scheduler)
: WebSchedulerImpl(renderer_scheduler,
......@@ -24,7 +25,7 @@ RendererWebSchedulerImpl::RendererWebSchedulerImpl(
renderer_scheduler_(renderer_scheduler),
compositor_task_runner_(
TaskRunnerImpl::Create(renderer_scheduler_->CompositorTaskQueue(),
base::nullopt)) {}
TaskType::kDeprecatedNone)) {}
RendererWebSchedulerImpl::~RendererWebSchedulerImpl() = default;
......
......@@ -289,6 +289,7 @@ WebFrameSchedulerImpl::GetTaskRunner(TaskType type) {
case TaskType::kInternalWebCrypto:
case TaskType::kInternalIPC:
return TaskRunnerImpl::Create(UnpausableTaskQueue(), type);
case TaskType::kDeprecatedNone:
case TaskType::kCount:
NOTREACHED();
break;
......
......@@ -17,7 +17,9 @@ enum class TaskType : unsigned {
// Speced tasks and related internal tasks should be posted to one of
// the following task runners. These task runners may be throttled.
// 0 is reserved to represent that TaskType is not specified.
// This value is used as a default value in cases where TaskType
// isn't supported yet. Don't use outside platform/scheduler code.
kDeprecatedNone = 0,
// https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment