Commit e4d30f28 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Add TaskType to EventTarget::EnqueueAsyncEvent

Events and task sources are orthogonal things, and it would not make
sense to determine a task source (task type) from an event. This CL adds
a TaskType argument to specify the task source explicitly.

Bug: 846618
Change-Id: I2c3c5d51e8d94ee12905bc8b850162f10433ad76
Reviewed-on: https://chromium-review.googlesource.com/1114529Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570360}
parent 648ee420
......@@ -42,8 +42,6 @@ class CORE_EXPORT EventQueue final
USING_GARBAGE_COLLECTED_MIXIN(EventQueue);
public:
// TODO(hajimehoshi): TaskType should be determined based on an event instead
// of specifying here.
static EventQueue* Create(ExecutionContext*, TaskType);
~EventQueue();
......
......@@ -870,17 +870,15 @@ void EventTarget::RemoveAllEventListeners() {
}
}
void EventTarget::EnqueueAsyncEvent(Event* event) {
void EventTarget::EnqueueAsyncEvent(Event* event, TaskType task_type) {
ExecutionContext* context = GetExecutionContext();
if (!context)
return;
probe::AsyncTaskScheduled(context, event->type(), event);
// TODO(hajimehoshi): Specify better task type based on the event.
context->GetTaskRunner(TaskType::kInternalDefault)
->PostTask(
FROM_HERE,
WTF::Bind(&EventTarget::DispatchAsyncEvent, WrapPersistent(this),
WrapPersistent(event), WrapPersistent(context)));
context->GetTaskRunner(task_type)->PostTask(
FROM_HERE,
WTF::Bind(&EventTarget::DispatchAsyncEvent, WrapPersistent(this),
WrapPersistent(event), WrapPersistent(context)));
}
void EventTarget::DispatchAsyncEvent(Event* event, ExecutionContext* context) {
......
......@@ -35,6 +35,7 @@
#include <memory>
#include "base/macros.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/add_event_listener_options_resolved.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatch_result.h"
......@@ -154,7 +155,7 @@ class CORE_EXPORT EventTarget : public ScriptWrappable {
DispatchEventResult DispatchEvent(Event*);
void EnqueueAsyncEvent(Event*);
void EnqueueAsyncEvent(Event*, TaskType);
// dispatchEventForBindings is intended to only be called from
// javascript originated calls. This method will validate and may adjust
......
......@@ -460,7 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent(
const WebDOMMessageEvent& event) {
if (!element_->GetExecutionContext())
return;
element_->EnqueueAsyncEvent(event);
element_->EnqueueAsyncEvent(event, TaskType::kInternalDefault);
}
void WebPluginContainerImpl::Invalidate() {
......
......@@ -1427,11 +1427,12 @@ void ContentSecurityPolicy::DispatchViolationEvents(
if (execution_context_->IsDocument()) {
Document* document = ToDocument(execution_context_);
if (element && element->isConnected() && element->GetDocument() == document)
element->EnqueueAsyncEvent(event);
element->EnqueueAsyncEvent(event, TaskType::kInternalDefault);
else
document->EnqueueAsyncEvent(event);
document->EnqueueAsyncEvent(event, TaskType::kInternalDefault);
} else if (execution_context_->IsWorkerGlobalScope()) {
ToWorkerGlobalScope(execution_context_)->EnqueueAsyncEvent(event);
ToWorkerGlobalScope(execution_context_)
->EnqueueAsyncEvent(event, TaskType::kInternalDefault);
}
}
......
......@@ -339,12 +339,12 @@ Document* LocalDOMWindow::InstallNewDocument(const String& mime_type,
}
void LocalDOMWindow::EnqueueWindowEvent(Event* event) {
EnqueueAsyncEvent(event);
EnqueueAsyncEvent(event, TaskType::kInternalDefault);
}
void LocalDOMWindow::EnqueueDocumentEvent(Event* event) {
if (document_)
document_->EnqueueAsyncEvent(event);
document_->EnqueueAsyncEvent(event, TaskType::kInternalDefault);
}
void LocalDOMWindow::DispatchWindowLoadEvent() {
......
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