Commit 88e97d50 authored by Yuzu Saijo's avatar Yuzu Saijo Committed by Commit Bot

Post IPC tasks to freezable per-frame task runner

This CL makes the task runners for IPC messages freezable.
In the follow up CL, I will filter out some messages that should not be
frozen. ( https://bugs.chromium.org/p/chromium/issues/detail?id=970080 )

Change-Id: I444f8db6377f2524f2a4f7c876af78e901be865d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627834
Commit-Queue: Yuzu Saijo <yuzus@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665788}
parent cc536d3f
...@@ -1065,8 +1065,7 @@ void RenderThreadImpl::AddRoute(int32_t routing_id, IPC::Listener* listener) { ...@@ -1065,8 +1065,7 @@ void RenderThreadImpl::AddRoute(int32_t routing_id, IPC::Listener* listener) {
return; return;
GetChannel()->AddListenerTaskRunner( GetChannel()->AddListenerTaskRunner(
routing_id, routing_id, frame->GetTaskRunner(blink::TaskType::kInternalFreezableIPC));
frame->GetTaskRunner(blink::TaskType::kInternalNavigationAssociated));
scoped_refptr<PendingFrameCreate> create(it->second); scoped_refptr<PendingFrameCreate> create(it->second);
frame->BindFrame(it->second->browser_info(), it->second->TakeFrameRequest()); frame->BindFrame(it->second->browser_info(), it->second->TakeFrameRequest());
......
...@@ -210,6 +210,9 @@ enum class TaskType : unsigned char { ...@@ -210,6 +210,9 @@ enum class TaskType : unsigned char {
// when one of the frames is frozen. // when one of the frames is frozen.
kInternalNavigationAssociated = 63, kInternalNavigationAssociated = 63,
// Legacy IPCs that are freezable.
kInternalFreezableIPC = 64,
/////////////////////////////////////// ///////////////////////////////////////
// The following task types are only for thread-local queues. // The following task types are only for thread-local queues.
/////////////////////////////////////// ///////////////////////////////////////
...@@ -233,7 +236,7 @@ enum class TaskType : unsigned char { ...@@ -233,7 +236,7 @@ enum class TaskType : unsigned char {
kWorkerThreadTaskQueueV8 = 47, kWorkerThreadTaskQueueV8 = 47,
kWorkerThreadTaskQueueCompositor = 48, kWorkerThreadTaskQueueCompositor = 48,
kCount = 64, kCount = 65,
}; };
} // namespace blink } // namespace blink
......
...@@ -459,6 +459,8 @@ base::Optional<QueueTraits> FrameSchedulerImpl::CreateQueueTraitsForTaskType( ...@@ -459,6 +459,8 @@ base::Optional<QueueTraits> FrameSchedulerImpl::CreateQueueTraitsForTaskType(
case TaskType::kInternalUserInteraction: case TaskType::kInternalUserInteraction:
case TaskType::kInternalIntersectionObserver: case TaskType::kInternalIntersectionObserver:
return PausableTaskQueueTraits(); return PausableTaskQueueTraits();
case TaskType::kInternalFreezableIPC:
return FreezableTaskQueueTraits();
case TaskType::kInternalIPC: case TaskType::kInternalIPC:
// The TaskType of Inspector tasks needs to be unpausable because they need // The TaskType of Inspector tasks needs to be unpausable because they need
// to run even on a paused page. // to run even on a paused page.
...@@ -1119,6 +1121,14 @@ MainThreadTaskQueue::QueueTraits FrameSchedulerImpl::PausableTaskQueueTraits() { ...@@ -1119,6 +1121,14 @@ MainThreadTaskQueue::QueueTraits FrameSchedulerImpl::PausableTaskQueueTraits() {
.SetCanBePaused(true); .SetCanBePaused(true);
} }
// static
MainThreadTaskQueue::QueueTraits
FrameSchedulerImpl::FreezableTaskQueueTraits() {
// Should not use VirtualTime because using VirtualTime would make the task
// execution non-deterministic and produce timeouts failures.
return QueueTraits().SetCanBeFrozen(true).SetShouldUseVirtualTime(false);
}
// static // static
MainThreadTaskQueue::QueueTraits MainThreadTaskQueue::QueueTraits
FrameSchedulerImpl::UnpausableTaskQueueTraits() { FrameSchedulerImpl::UnpausableTaskQueueTraits() {
......
...@@ -275,6 +275,7 @@ class PLATFORM_EXPORT FrameSchedulerImpl : public FrameScheduler, ...@@ -275,6 +275,7 @@ class PLATFORM_EXPORT FrameSchedulerImpl : public FrameScheduler,
static MainThreadTaskQueue::QueueTraits DeferrableTaskQueueTraits(); static MainThreadTaskQueue::QueueTraits DeferrableTaskQueueTraits();
static MainThreadTaskQueue::QueueTraits PausableTaskQueueTraits(); static MainThreadTaskQueue::QueueTraits PausableTaskQueueTraits();
static MainThreadTaskQueue::QueueTraits UnpausableTaskQueueTraits(); static MainThreadTaskQueue::QueueTraits UnpausableTaskQueueTraits();
static MainThreadTaskQueue::QueueTraits FreezableTaskQueueTraits();
static MainThreadTaskQueue::QueueTraits ForegroundOnlyTaskQueueTraits(); static MainThreadTaskQueue::QueueTraits ForegroundOnlyTaskQueueTraits();
static MainThreadTaskQueue::QueueTraits static MainThreadTaskQueue::QueueTraits
DoesNotUseVirtualTimeTaskQueueTraits(); DoesNotUseVirtualTimeTaskQueueTraits();
......
...@@ -131,6 +131,8 @@ const char* TaskTypeNames::TaskTypeToString(TaskType task_type) { ...@@ -131,6 +131,8 @@ const char* TaskTypeNames::TaskTypeToString(TaskType task_type) {
return "InternalContentCapture"; return "InternalContentCapture";
case TaskType::kInternalNavigationAssociated: case TaskType::kInternalNavigationAssociated:
return "InternalNavigationAssociated"; return "InternalNavigationAssociated";
case TaskType::kInternalFreezableIPC:
return "InternalFreezableIPC";
case TaskType::kCount: case TaskType::kCount:
return "Count"; return "Count";
} }
......
...@@ -156,6 +156,7 @@ scoped_refptr<base::SingleThreadTaskRunner> WorkerScheduler::GetTaskRunner( ...@@ -156,6 +156,7 @@ scoped_refptr<base::SingleThreadTaskRunner> WorkerScheduler::GetTaskRunner(
case TaskType::kInternalMediaRealTime: case TaskType::kInternalMediaRealTime:
case TaskType::kInternalUserInteraction: case TaskType::kInternalUserInteraction:
case TaskType::kInternalIntersectionObserver: case TaskType::kInternalIntersectionObserver:
case TaskType::kInternalFreezableIPC:
// UnthrottledTaskRunner is generally discouraged in future. // UnthrottledTaskRunner is generally discouraged in future.
// TODO(nhiroki): Identify which tasks can be throttled / suspendable and // TODO(nhiroki): Identify which tasks can be throttled / suspendable and
// move them into other task runners. See also comments in // move them into other task runners. See also comments in
......
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