Commit 1f8391bb authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

EventQueue(Impl) for each user instead of ExecutionContext

To decouple the relationships between EventQueue(Impl) and
ExecutionContext, make each user have their own EventQueueImpl object.

For ContentSecurityPolicy class, I'll make a follow-up CL later.

Design Doc: https://docs.google.com/document/d/1BBtBPTarOF4NeVKSWZe3XaDHo4yTGhdlqYm35yVzPs4/edit#

Bug: 846618
Change-Id: I3177bf1e69ef1db61cb8056c2309e93ad5539b94
Reviewed-on: https://chromium-review.googlesource.com/1088534
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564865}
parent 9b5dab32
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#include "third_party/blink/renderer/core/clipboard/data_object.h" #include "third_party/blink/renderer/core/clipboard/data_object.h"
#include "third_party/blink/renderer/core/clipboard/data_transfer.h" #include "third_party/blink/renderer/core/clipboard/data_transfer.h"
#include "third_party/blink/renderer/core/clipboard/system_clipboard.h" #include "third_party/blink/renderer/core/clipboard/system_clipboard.h"
#include "third_party/blink/renderer/core/dom/events/event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/dom/user_gesture_indicator.h" #include "third_party/blink/renderer/core/dom/user_gesture_indicator.h"
#include "third_party/blink/renderer/core/events/drag_event.h" #include "third_party/blink/renderer/core/events/drag_event.h"
#include "third_party/blink/renderer/core/events/gesture_event.h" #include "third_party/blink/renderer/core/events/gesture_event.h"
...@@ -460,8 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent( ...@@ -460,8 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent(
static_cast<Event*>(event)->SetTarget(element_); static_cast<Event*>(event)->SetTarget(element_);
if (!element_->GetExecutionContext()) if (!element_->GetExecutionContext())
return; return;
element_->GetExecutionContext()->GetEventQueue()->EnqueueEvent(FROM_HERE, event_queue_->EnqueueEvent(FROM_HERE, event);
event);
} }
void WebPluginContainerImpl::Invalidate() { void WebPluginContainerImpl::Invalidate() {
...@@ -752,6 +751,9 @@ WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement& element, ...@@ -752,6 +751,9 @@ WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement& element,
WebPlugin* web_plugin) WebPlugin* web_plugin)
: ContextClient(element.GetDocument().GetFrame()), : ContextClient(element.GetDocument().GetFrame()),
element_(element), element_(element),
event_queue_(
EventQueueImpl::Create(element.GetDocument().GetExecutionContext(),
TaskType::kInternalDefault)),
web_plugin_(web_plugin), web_plugin_(web_plugin),
layer_(nullptr), layer_(nullptr),
touch_event_request_type_(kTouchEventRequestTypeNone), touch_event_request_type_(kTouchEventRequestTypeNone),
...@@ -797,6 +799,7 @@ void WebPluginContainerImpl::Dispose() { ...@@ -797,6 +799,7 @@ void WebPluginContainerImpl::Dispose() {
void WebPluginContainerImpl::Trace(blink::Visitor* visitor) { void WebPluginContainerImpl::Trace(blink::Visitor* visitor) {
visitor->Trace(element_); visitor->Trace(element_);
visitor->Trace(event_queue_);
ContextClient::Trace(visitor); ContextClient::Trace(visitor);
} }
......
...@@ -237,6 +237,7 @@ class CORE_EXPORT WebPluginContainerImpl final ...@@ -237,6 +237,7 @@ class CORE_EXPORT WebPluginContainerImpl final
friend class WebPluginContainerTest; friend class WebPluginContainerTest;
Member<HTMLPlugInElement> element_; Member<HTMLPlugInElement> element_;
Member<EventQueue> event_queue_;
WebPlugin* web_plugin_; WebPlugin* web_plugin_;
cc::Layer* layer_; cc::Layer* layer_;
IntRect frame_rect_; IntRect frame_rect_;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "third_party/blink/public/platform/interface_provider.h" #include "third_party/blink/public/platform/interface_provider.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h" #include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/core/dom/events/event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/dom/exception_code.h" #include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/core/events/message_event.h" #include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/platform/mojo/mojo_helper.h" #include "third_party/blink/renderer/platform/mojo/mojo_helper.h"
...@@ -91,6 +91,7 @@ void BroadcastChannel::ContextDestroyed(ExecutionContext*) { ...@@ -91,6 +91,7 @@ void BroadcastChannel::ContextDestroyed(ExecutionContext*) {
} }
void BroadcastChannel::Trace(blink::Visitor* visitor) { void BroadcastChannel::Trace(blink::Visitor* visitor) {
visitor->Trace(event_queue_);
ContextLifecycleObserver::Trace(visitor); ContextLifecycleObserver::Trace(visitor);
EventTargetWithInlineData::Trace(visitor); EventTargetWithInlineData::Trace(visitor);
} }
...@@ -101,8 +102,7 @@ void BroadcastChannel::OnMessage(BlinkCloneableMessage message) { ...@@ -101,8 +102,7 @@ void BroadcastChannel::OnMessage(BlinkCloneableMessage message) {
nullptr, std::move(message.message), nullptr, std::move(message.message),
GetExecutionContext()->GetSecurityOrigin()->ToString()); GetExecutionContext()->GetSecurityOrigin()->ToString());
event->SetTarget(this); event->SetTarget(this);
bool success = bool success = event_queue_->EnqueueEvent(FROM_HERE, event);
GetExecutionContext()->GetEventQueue()->EnqueueEvent(FROM_HERE, event);
DCHECK(success); DCHECK(success);
ALLOW_UNUSED_LOCAL(success); ALLOW_UNUSED_LOCAL(success);
} }
...@@ -115,6 +115,8 @@ BroadcastChannel::BroadcastChannel(ExecutionContext* execution_context, ...@@ -115,6 +115,8 @@ BroadcastChannel::BroadcastChannel(ExecutionContext* execution_context,
const String& name) const String& name)
: ContextLifecycleObserver(execution_context), : ContextLifecycleObserver(execution_context),
origin_(execution_context->GetSecurityOrigin()), origin_(execution_context->GetSecurityOrigin()),
event_queue_(
EventQueueImpl::Create(execution_context, TaskType::kInternalMedia)),
name_(name), name_(name),
binding_(this) { binding_(this) {
mojom::blink::BroadcastChannelProviderPtr& provider = mojom::blink::BroadcastChannelProviderPtr& provider =
......
...@@ -63,6 +63,7 @@ class BroadcastChannel final : public EventTargetWithInlineData, ...@@ -63,6 +63,7 @@ class BroadcastChannel final : public EventTargetWithInlineData,
void OnError(); void OnError();
scoped_refptr<const SecurityOrigin> origin_; scoped_refptr<const SecurityOrigin> origin_;
Member<EventQueue> event_queue_;
String name_; String name_;
mojo::AssociatedBinding<mojom::blink::BroadcastChannelClient> binding_; mojo::AssociatedBinding<mojom::blink::BroadcastChannelClient> binding_;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "third_party/blink/renderer/bindings/core/v8/exception_state.h" #include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/dom/exception_code.h" #include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/modules/indexed_db_names.h" #include "third_party/blink/renderer/modules/indexed_db_names.h"
...@@ -90,7 +90,9 @@ IDBTransaction::IDBTransaction(ExecutionContext* execution_context, ...@@ -90,7 +90,9 @@ IDBTransaction::IDBTransaction(ExecutionContext* execution_context,
database_(db), database_(db),
mode_(kWebIDBTransactionModeReadOnly), mode_(kWebIDBTransactionModeReadOnly),
scope_(scope), scope_(scope),
state_(kActive) { state_(kActive),
event_queue_(EventQueueImpl::Create(execution_context,
TaskType::kInternalIndexedDB)) {
DCHECK(database_); DCHECK(database_);
DCHECK(!scope_.IsEmpty()) << "Observer transactions must operate " DCHECK(!scope_.IsEmpty()) << "Observer transactions must operate "
"on a well-defined set of stores"; "on a well-defined set of stores";
...@@ -106,7 +108,9 @@ IDBTransaction::IDBTransaction(ScriptState* script_state, ...@@ -106,7 +108,9 @@ IDBTransaction::IDBTransaction(ScriptState* script_state,
id_(id), id_(id),
database_(db), database_(db),
mode_(mode), mode_(mode),
scope_(scope) { scope_(scope),
event_queue_(EventQueueImpl::Create(ExecutionContext::From(script_state),
TaskType::kInternalIndexedDB)) {
DCHECK(database_); DCHECK(database_);
DCHECK(!scope_.IsEmpty()) << "Non-versionchange transactions must operate " DCHECK(!scope_.IsEmpty()) << "Non-versionchange transactions must operate "
"on a well-defined set of stores"; "on a well-defined set of stores";
...@@ -133,7 +137,9 @@ IDBTransaction::IDBTransaction(ExecutionContext* execution_context, ...@@ -133,7 +137,9 @@ IDBTransaction::IDBTransaction(ExecutionContext* execution_context,
open_db_request_(open_db_request), open_db_request_(open_db_request),
mode_(kWebIDBTransactionModeVersionChange), mode_(kWebIDBTransactionModeVersionChange),
state_(kInactive), state_(kInactive),
old_database_metadata_(old_metadata) { old_database_metadata_(old_metadata),
event_queue_(EventQueueImpl::Create(execution_context,
TaskType::kInternalIndexedDB)) {
DCHECK(database_); DCHECK(database_);
DCHECK(open_db_request_); DCHECK(open_db_request_);
DCHECK(scope_.IsEmpty()); DCHECK(scope_.IsEmpty());
...@@ -157,6 +163,7 @@ void IDBTransaction::Trace(blink::Visitor* visitor) { ...@@ -157,6 +163,7 @@ void IDBTransaction::Trace(blink::Visitor* visitor) {
visitor->Trace(object_store_map_); visitor->Trace(object_store_map_);
visitor->Trace(old_store_metadata_); visitor->Trace(old_store_metadata_);
visitor->Trace(deleted_indexes_); visitor->Trace(deleted_indexes_);
visitor->Trace(event_queue_);
EventTargetWithInlineData::Trace(visitor); EventTargetWithInlineData::Trace(visitor);
ContextLifecycleObserver::Trace(visitor); ContextLifecycleObserver::Trace(visitor);
} }
...@@ -546,9 +553,8 @@ void IDBTransaction::EnqueueEvent(Event* event) { ...@@ -546,9 +553,8 @@ void IDBTransaction::EnqueueEvent(Event* event) {
if (!GetExecutionContext()) if (!GetExecutionContext())
return; return;
EventQueue* event_queue = GetExecutionContext()->GetEventQueue();
event->SetTarget(this); event->SetTarget(this);
event_queue->EnqueueEvent(FROM_HERE, event); event_queue_->EnqueueEvent(FROM_HERE, event);
} }
void IDBTransaction::AbortOutstandingRequests() { void IDBTransaction::AbortOutstandingRequests() {
......
...@@ -280,6 +280,8 @@ class MODULES_EXPORT IDBTransaction final ...@@ -280,6 +280,8 @@ class MODULES_EXPORT IDBTransaction final
// //
// Only valid for versionchange transactions. // Only valid for versionchange transactions.
IDBDatabaseMetadata old_database_metadata_; IDBDatabaseMetadata old_database_metadata_;
Member<EventQueue> event_queue_;
}; };
} // namespace blink } // namespace blink
......
...@@ -184,7 +184,6 @@ TEST_F(IDBTransactionTest, ContextDestroyedAfterDone) { ...@@ -184,7 +184,6 @@ TEST_F(IDBTransactionTest, ContextDestroyedAfterDone) {
// The request completed, so it has enqueued a success event. Discard the // The request completed, so it has enqueued a success event. Discard the
// event, so that the transaction can go away. // event, so that the transaction can go away.
EXPECT_EQ(1U, live_transactions.size()); EXPECT_EQ(1U, live_transactions.size());
scope.GetExecutionContext()->GetEventQueue()->Close();
ThreadState::Current()->CollectAllGarbage(); ThreadState::Current()->CollectAllGarbage();
EXPECT_EQ(0U, live_transactions.size()); EXPECT_EQ(0U, live_transactions.size());
......
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