diff --git a/AUTHORS b/AUTHORS index a0d8a0a..be619ba 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -727,7 +727,6 @@ William Xie <william.xie@intel.com> Xiang Long <xiang.long@intel.com> Xiangze Zhang <xiangze.zhang@intel.com> -Xiaofeng Zhang <xiaofeng.zhang@intel.com> Xiaolei Yu <dreifachstein@gmail.com> Xiaoyin Liu <xiaoyin.l@outlook.com> Xinchao He <hexinchao@gmail.com>
diff --git a/chrome/VERSION b/chrome/VERSION index e29efbfa..6f50fc0 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=57 MINOR=0 -BUILD=2963 +BUILD=2964 PATCH=0
diff --git a/content/browser/push_messaging/push_messaging_router.cc b/content/browser/push_messaging/push_messaging_router.cc index c512cff..f6ff797ff 100644 --- a/content/browser/push_messaging/push_messaging_router.cc +++ b/content/browser/push_messaging/push_messaging_router.cc
@@ -123,10 +123,8 @@ deliver_message_callback, service_worker_registration), base::TimeDelta::FromSeconds(kPushMessageTimeoutSeconds), ServiceWorkerVersion::KILL_ON_TIMEOUT); - - service_worker->event_dispatcher()->DispatchPushEvent( - payload, base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished, - service_worker, request_id)); + service_worker->DispatchSimpleEvent<ServiceWorkerHostMsg_PushEventFinished>( + request_id, ServiceWorkerMsg_PushEvent(request_id, payload)); } // static
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc index 004f9e4..3b14438 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.cc +++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -179,13 +179,6 @@ std::move(preload_handle), callback); } - void DispatchPushEvent(const PushEventPayload& payload, - const DispatchPushEventCallback& callback) override { - if (!helper_) - return; - helper_->OnPushEventStub(payload, callback); - } - void DispatchSyncEvent( const std::string& tag, blink::mojom::BackgroundSyncEventLastChance last_chance, @@ -332,6 +325,7 @@ IPC_BEGIN_MESSAGE_MAP(EmbeddedWorkerTestHelper, message) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEventStub) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEventStub) + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEventStub) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() // Record all messages directed to inner script context. @@ -392,11 +386,12 @@ callback.Run(SERVICE_WORKER_OK, base::Time::Now()); } -void EmbeddedWorkerTestHelper::OnPushEvent( - const PushEventPayload& payload, - const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& - callback) { - callback.Run(SERVICE_WORKER_OK, base::Time::Now()); +void EmbeddedWorkerTestHelper::OnPushEvent(int embedded_worker_id, + int request_id, + const PushEventPayload& payload) { + SimulateSend(new ServiceWorkerHostMsg_PushEventFinished( + embedded_worker_id, request_id, + blink::WebServiceWorkerEventResultCompleted, base::Time::Now())); } void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( @@ -548,12 +543,11 @@ } void EmbeddedWorkerTestHelper::OnPushEventStub( - const PushEventPayload& payload, - const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& - callback) { + int request_id, + const PushEventPayload& payload) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnPushEvent, AsWeakPtr(), - payload, callback)); + current_embedded_worker_id_, request_id, payload)); } EmbeddedWorkerRegistry* EmbeddedWorkerTestHelper::registry() {
diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index f2dc0c7..6a1216d 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h
@@ -197,10 +197,9 @@ const ServiceWorkerFetchRequest& request, mojom::FetchEventPreloadHandlePtr preload_handle, const FetchCallback& callback); - virtual void OnPushEvent( - const PushEventPayload& payload, - const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& - callback); + virtual void OnPushEvent(int embedded_worker_id, + int request_id, + const PushEventPayload& payload); // These functions simulate sending an EmbeddedHostMsg message to the // browser. @@ -240,10 +239,7 @@ const ServiceWorkerFetchRequest& request, mojom::FetchEventPreloadHandlePtr preload_handle, const FetchCallback& callback); - void OnPushEventStub( - const PushEventPayload& payload, - const mojom::ServiceWorkerEventDispatcher::DispatchPushEventCallback& - callback); + void OnPushEventStub(int request_id, const PushEventPayload& payload); MessagePortMessageFilter* NewMessagePortMessageFilter();
diff --git a/content/common/service_worker/service_worker_event_dispatcher.mojom b/content/common/service_worker/service_worker_event_dispatcher.mojom index 6d11ed8b0..d878916e 100644 --- a/content/common/service_worker/service_worker_event_dispatcher.mojom +++ b/content/common/service_worker/service_worker_event_dispatcher.mojom
@@ -12,9 +12,6 @@ import "url/mojo/origin.mojom"; [Native] -struct PushEventPayload; - -[Native] struct ServiceWorkerFetchRequest; [Native] @@ -42,9 +39,6 @@ FetchEventPreloadHandle? preload_handle) => (blink.mojom.ServiceWorkerEventStatus status, mojo.common.mojom.Time dispatch_event_time); - DispatchPushEvent(PushEventPayload payload) - => (blink.mojom.ServiceWorkerEventStatus status, - mojo.common.mojom.Time dispatch_event_time); // Arguments are passed to the event handler as parameters of SyncEvent. // Ref: https://wicg.github.io/BackgroundSync/spec/#sync-event DispatchSyncEvent(string tag,
diff --git a/content/common/service_worker/service_worker_event_dispatcher.typemap b/content/common/service_worker/service_worker_event_dispatcher.typemap index b46220c..e191392 100644 --- a/content/common/service_worker/service_worker_event_dispatcher.typemap +++ b/content/common/service_worker/service_worker_event_dispatcher.typemap
@@ -6,7 +6,6 @@ public_headers = [ "//content/common/service_worker/service_worker_status_code.h", "//content/common/service_worker/service_worker_types.h", - "//content/public/common/push_event_payload.h", ] sources = [ "//content/common/service_worker/service_worker_status_code_traits.cc", @@ -16,8 +15,7 @@ "//content/common/service_worker/service_worker_status_code_traits.h", ] type_mappings = [ - "blink.mojom.ServiceWorkerEventStatus=::content::ServiceWorkerStatusCode", "content.mojom.ExtendableMessageEventSource=::content::ExtendableMessageEventSource", - "content.mojom.PushEventPayload=::content::PushEventPayload", "content.mojom.ServiceWorkerFetchRequest=::content::ServiceWorkerFetchRequest", + "blink.mojom.ServiceWorkerEventStatus=::content::ServiceWorkerStatusCode", ]
diff --git a/content/common/service_worker/service_worker_messages.h b/content/common/service_worker/service_worker_messages.h index 603bc02..27ba8d19 100644 --- a/content/common/service_worker/service_worker_messages.h +++ b/content/common/service_worker/service_worker_messages.h
@@ -299,6 +299,10 @@ int /* request_id */, blink::WebServiceWorkerEventResult, base::Time /* dispatch_event_time */) +IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PushEventFinished, + int /* request_id */, + blink::WebServiceWorkerEventResult, + base::Time /* dispatch_event_time */) // Responds to a Ping from the browser. // Routed to the target ServiceWorkerVersion. @@ -532,6 +536,9 @@ int /* request_id */, std::string /* notification_id */, content::PlatformNotificationData /* notification_data */) +IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_PushEvent, + int /* request_id */, + content::PushEventPayload /* data */) IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_DidSkipWaiting, int /* request_id */)
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index 61dfdc7..d44cf1d 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -166,15 +166,6 @@ return web_client_info; } -// Use this template in willDestroyWorkerContext to abort all the pending -// events callbacks. -template <typename T> -void AbortPendingEventCallbacks(T& callbacks) { - for (typename T::iterator it(&callbacks); !it.IsAtEnd(); it.Advance()) { - it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now()); - } -} - } // namespace // Holding data that needs to be bound to the worker context on the @@ -189,8 +180,6 @@ using SkipWaitingCallbacksMap = IDMap<std::unique_ptr<blink::WebServiceWorkerSkipWaitingCallbacks>>; using SyncEventCallbacksMap = IDMap<std::unique_ptr<const SyncCallback>>; - using PushEventCallbacksMap = - IDMap<std::unique_ptr<const DispatchPushEventCallback>>; using FetchEventCallbacksMap = IDMap<std::unique_ptr<const FetchCallback>>; using ExtendableMessageEventCallbacksMap = IDMap<std::unique_ptr<const DispatchExtendableMessageEventCallback>>; @@ -223,9 +212,6 @@ // Pending callbacks for Background Sync Events. SyncEventCallbacksMap sync_event_callbacks; - // Pending callbacks for Push Events. - PushEventCallbacksMap push_event_callbacks; - // Pending callbacks for Fetch Events. FetchEventCallbacksMap fetch_event_callbacks; @@ -425,6 +411,7 @@ OnNotificationClickEvent) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationCloseEvent, OnNotificationCloseEvent) + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClient, OnDidGetClient) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients, OnDidGetClients) IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse, @@ -586,11 +573,24 @@ // (while we're still on the worker thread). proxy_ = NULL; - // Aborts all the pending events callbacks. - AbortPendingEventCallbacks(context_->sync_event_callbacks); - AbortPendingEventCallbacks(context_->push_event_callbacks); - AbortPendingEventCallbacks(context_->fetch_event_callbacks); - AbortPendingEventCallbacks(context_->message_event_callbacks); + // Aborts the all pending sync event callbacks. + for (WorkerContextData::SyncEventCallbacksMap::iterator it( + &context_->sync_event_callbacks); + !it.IsAtEnd(); it.Advance()) { + it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now()); + } + // Aborts the all pending fetch event callbacks. + for (WorkerContextData::FetchEventCallbacksMap::iterator it( + &context_->fetch_event_callbacks); + !it.IsAtEnd(); it.Advance()) { + it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now()); + } + // Aborts the all pending extendable message event callbacks. + for (WorkerContextData::ExtendableMessageEventCallbacksMap::iterator it( + &context_->message_event_callbacks); + !it.IsAtEnd(); it.Advance()) { + it.GetCurrentValue()->Run(SERVICE_WORKER_ERROR_ABORT, base::Time::Now()); + } // We have to clear callbacks now, as they need to be freed on the // same thread. @@ -766,14 +766,9 @@ int request_id, blink::WebServiceWorkerEventResult result, double event_dispatch_time) { - const DispatchPushEventCallback* callback = - context_->push_event_callbacks.Lookup(request_id); - DCHECK(callback); - callback->Run(result == blink::WebServiceWorkerEventResultCompleted - ? SERVICE_WORKER_OK - : SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED, - base::Time::FromDoubleT(event_dispatch_time)); - context_->push_event_callbacks.Remove(request_id); + Send(new ServiceWorkerHostMsg_PushEventFinished( + GetRoutingID(), request_id, result, + base::Time::FromDoubleT(event_dispatch_time))); } void ServiceWorkerContextClient::didHandleSyncEvent( @@ -1066,14 +1061,10 @@ ToWebNotificationData(notification_data)); } -void ServiceWorkerContextClient::DispatchPushEvent( - const PushEventPayload& payload, - const DispatchPushEventCallback& callback) { +void ServiceWorkerContextClient::OnPushEvent(int request_id, + const PushEventPayload& payload) { TRACE_EVENT0("ServiceWorker", - "ServiceWorkerContextClient::DispatchPushEvent"); - int request_id = context_->push_event_callbacks.Add( - base::MakeUnique<DispatchPushEventCallback>(callback)); - + "ServiceWorkerContextClient::OnPushEvent"); // Only set data to be a valid string if the payload had decrypted data. blink::WebString data; if (!payload.is_null)
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h index 79410a6..2686e31 100644 --- a/content/renderer/service_worker/service_worker_context_client.h +++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -220,8 +220,6 @@ const ServiceWorkerFetchRequest& request, mojom::FetchEventPreloadHandlePtr preload_handle, const DispatchFetchEventCallback& callback) override; - void DispatchPushEvent(const PushEventPayload& payload, - const DispatchPushEventCallback& callback) override; void DispatchSyncEvent( const std::string& tag, blink::mojom::BackgroundSyncEventLastChance last_chance, @@ -235,6 +233,7 @@ const PlatformNotificationData& notification_data, int action_index, const base::NullableString16& reply); + void OnPushEvent(int request_id, const PushEventPayload& payload); void OnNotificationCloseEvent( int request_id, const std::string& notification_id,
diff --git a/third_party/WebKit/Source/core/css/StyleMedia.cpp b/third_party/WebKit/Source/core/css/StyleMedia.cpp index c666546..65213fe 100644 --- a/third_party/WebKit/Source/core/css/StyleMedia.cpp +++ b/third_party/WebKit/Source/core/css/StyleMedia.cpp
@@ -33,7 +33,7 @@ namespace blink { -StyleMedia::StyleMedia(LocalFrame* frame) : DOMWindowProperty(frame) {} +StyleMedia::StyleMedia(LocalFrame* frame) : ContextClient(frame) {} AtomicString StyleMedia::type() const { FrameView* view = frame() ? frame()->view() : nullptr; @@ -62,7 +62,7 @@ } DEFINE_TRACE(StyleMedia) { - DOMWindowProperty::trace(visitor); + ContextClient::trace(visitor); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/css/StyleMedia.h b/third_party/WebKit/Source/core/css/StyleMedia.h index 9df973e..55d69535 100644 --- a/third_party/WebKit/Source/core/css/StyleMedia.h +++ b/third_party/WebKit/Source/core/css/StyleMedia.h
@@ -28,7 +28,7 @@ #define StyleMedia_h #include "bindings/core/v8/ScriptWrappable.h" -#include "core/frame/DOMWindowProperty.h" +#include "core/dom/ContextLifecycleObserver.h" #include "platform/heap/Handle.h" #include "wtf/text/WTFString.h" @@ -37,7 +37,7 @@ class LocalFrame; class StyleMedia final : public GarbageCollected<StyleMedia>, - public DOMWindowProperty, + public ContextClient, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(StyleMedia);
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp index e7c2c90..17eb72c 100644 --- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp +++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -59,7 +59,7 @@ } DOMSelection::DOMSelection(const TreeScope* treeScope) - : DOMWindowProperty(treeScope->rootNode().document().frame()), + : ContextClient(treeScope->rootNode().document().frame()), m_treeScope(treeScope) {} void DOMSelection::clearTreeScope() { @@ -669,7 +669,7 @@ DEFINE_TRACE(DOMSelection) { visitor->trace(m_treeScope); - DOMWindowProperty::trace(visitor); + ContextClient::trace(visitor); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.h b/third_party/WebKit/Source/core/editing/DOMSelection.h index 2b3e182..b1a7dac 100644 --- a/third_party/WebKit/Source/core/editing/DOMSelection.h +++ b/third_party/WebKit/Source/core/editing/DOMSelection.h
@@ -31,9 +31,9 @@ #define DOMSelection_h #include "bindings/core/v8/ScriptWrappable.h" +#include "core/dom/ContextLifecycleObserver.h" #include "core/editing/Position.h" #include "core/editing/VisibleSelection.h" -#include "core/frame/DOMWindowProperty.h" #include "platform/heap/Handle.h" #include "wtf/Forward.h" @@ -46,7 +46,7 @@ class CORE_EXPORT DOMSelection final : public GarbageCollected<DOMSelection>, public ScriptWrappable, - public DOMWindowProperty { + public ContextClient { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(DOMSelection);
diff --git a/third_party/WebKit/Source/core/frame/History.cpp b/third_party/WebKit/Source/core/frame/History.cpp index 56494e9..d6f76e68 100644 --- a/third_party/WebKit/Source/core/frame/History.cpp +++ b/third_party/WebKit/Source/core/frame/History.cpp
@@ -56,10 +56,10 @@ } // namespace History::History(LocalFrame* frame) - : DOMWindowProperty(frame), m_lastStateObjectRequested(nullptr) {} + : ContextClient(frame), m_lastStateObjectRequested(nullptr) {} DEFINE_TRACE(History) { - DOMWindowProperty::trace(visitor); + ContextClient::trace(visitor); } unsigned History::length() const {
diff --git a/third_party/WebKit/Source/core/frame/History.h b/third_party/WebKit/Source/core/frame/History.h index 5c30f08..6a3715f 100644 --- a/third_party/WebKit/Source/core/frame/History.h +++ b/third_party/WebKit/Source/core/frame/History.h
@@ -29,8 +29,8 @@ #include "base/gtest_prod_util.h" #include "bindings/core/v8/ScriptWrappable.h" #include "bindings/core/v8/SerializedScriptValue.h" +#include "core/dom/ContextLifecycleObserver.h" #include "core/loader/FrameLoaderTypes.h" -#include "core/frame/DOMWindowProperty.h" #include "platform/heap/Handle.h" #include "wtf/Forward.h" @@ -45,7 +45,7 @@ // This class corresponds to the History interface. class CORE_EXPORT History final : public GarbageCollectedFinalized<History>, public ScriptWrappable, - public DOMWindowProperty { + public ContextClient { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(History);
diff --git a/third_party/WebKit/Source/core/frame/Screen.cpp b/third_party/WebKit/Source/core/frame/Screen.cpp index 53843195..5e750f4 100644 --- a/third_party/WebKit/Source/core/frame/Screen.cpp +++ b/third_party/WebKit/Source/core/frame/Screen.cpp
@@ -38,7 +38,7 @@ namespace blink { -Screen::Screen(LocalFrame* frame) : DOMWindowProperty(frame) {} +Screen::Screen(LocalFrame* frame) : ContextClient(frame) {} int Screen::height() const { if (!frame()) @@ -135,7 +135,7 @@ } DEFINE_TRACE(Screen) { - DOMWindowProperty::trace(visitor); + ContextClient::trace(visitor); Supplementable<Screen>::trace(visitor); }
diff --git a/third_party/WebKit/Source/core/frame/Screen.h b/third_party/WebKit/Source/core/frame/Screen.h index 2fe302d..7b4eeb4 100644 --- a/third_party/WebKit/Source/core/frame/Screen.h +++ b/third_party/WebKit/Source/core/frame/Screen.h
@@ -30,7 +30,7 @@ #define Screen_h #include "bindings/core/v8/ScriptWrappable.h" -#include "core/frame/DOMWindowProperty.h" +#include "core/dom/ContextLifecycleObserver.h" #include "platform/Supplementable.h" #include "platform/heap/Handle.h" @@ -40,7 +40,7 @@ class Screen final : public GarbageCollected<Screen>, public ScriptWrappable, - public DOMWindowProperty, + public ContextClient, public Supplementable<Screen> { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(Screen);
diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp index 95957ef3b..dd53e83e 100644 --- a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp +++ b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp
@@ -20,7 +20,7 @@ PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isolate) : WorkletGlobalScope(url, userAgent, std::move(securityOrigin), isolate), - DOMWindowProperty(frame) {} + ContextClient(frame) {} MainThreadWorkletGlobalScope::~MainThreadWorkletGlobalScope() {}
diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.h b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.h index 90505f6..8d0ab53f8 100644 --- a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.h +++ b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.h
@@ -6,8 +6,8 @@ #define MainThreadWorkletGlobalScope_h #include "core/CoreExport.h" +#include "core/dom/ContextLifecycleObserver.h" #include "core/dom/ExecutionContext.h" -#include "core/frame/DOMWindowProperty.h" #include "core/workers/WorkletGlobalScope.h" #include "core/workers/WorkletGlobalScopeProxy.h" @@ -19,7 +19,7 @@ class CORE_EXPORT MainThreadWorkletGlobalScope : public WorkletGlobalScope, public WorkletGlobalScopeProxy, - public DOMWindowProperty { + public ContextClient { USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorkletGlobalScope); public: @@ -45,7 +45,7 @@ DEFINE_INLINE_VIRTUAL_TRACE() { WorkletGlobalScope::trace(visitor); - DOMWindowProperty::trace(visitor); + ContextClient::trace(visitor); } };