Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1632113004: ServiceWorker: Add initial implementation of ExtendableMessageEvent behind a flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "modules/navigatorconnect/AcceptConnectionObserver.h" 47 #include "modules/navigatorconnect/AcceptConnectionObserver.h"
48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" 48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h"
49 #include "modules/navigatorconnect/ServicePortCollection.h" 49 #include "modules/navigatorconnect/ServicePortCollection.h"
50 #include "modules/navigatorconnect/WorkerNavigatorServices.h" 50 #include "modules/navigatorconnect/WorkerNavigatorServices.h"
51 #include "modules/notifications/Notification.h" 51 #include "modules/notifications/Notification.h"
52 #include "modules/notifications/NotificationEvent.h" 52 #include "modules/notifications/NotificationEvent.h"
53 #include "modules/notifications/NotificationEventInit.h" 53 #include "modules/notifications/NotificationEventInit.h"
54 #include "modules/push_messaging/PushEvent.h" 54 #include "modules/push_messaging/PushEvent.h"
55 #include "modules/push_messaging/PushMessageData.h" 55 #include "modules/push_messaging/PushMessageData.h"
56 #include "modules/serviceworkers/ExtendableEvent.h" 56 #include "modules/serviceworkers/ExtendableEvent.h"
57 #include "modules/serviceworkers/ExtendableMessageEvent.h"
57 #include "modules/serviceworkers/FetchEvent.h" 58 #include "modules/serviceworkers/FetchEvent.h"
58 #include "modules/serviceworkers/InstallEvent.h" 59 #include "modules/serviceworkers/InstallEvent.h"
59 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 60 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
60 #include "modules/serviceworkers/WaitUntilObserver.h" 61 #include "modules/serviceworkers/WaitUntilObserver.h"
61 #include "platform/RuntimeEnabledFeatures.h" 62 #include "platform/RuntimeEnabledFeatures.h"
62 #include "public/platform/WebCrossOriginServiceWorkerClient.h" 63 #include "public/platform/WebCrossOriginServiceWorkerClient.h"
63 #include "public/platform/modules/background_sync/WebSyncRegistration.h" 64 #include "public/platform/modules/background_sync/WebSyncRegistration.h"
64 #include "public/platform/modules/notifications/WebNotificationData.h" 65 #include "public/platform/modules/notifications/WebNotificationData.h"
65 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" 66 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 67 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
(...skipping 28 matching lines...) Expand all
95 workerGlobalScope()->setRegistration(handle); 96 workerGlobalScope()->setRegistration(handle);
96 } 97 }
97 98
98 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) 99 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
99 { 100 {
100 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); 101 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID);
101 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer)); 102 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer));
102 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 103 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
103 } 104 }
104 105
106 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels)
107 {
108 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
109
110 ExtendableMessageEventInit initializer;
111 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
112
113 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(EventTypeName s::message, initializer, observer));
114 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
115 }
116
105 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) 117 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest)
106 { 118 {
107 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); 119 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch);
108 } 120 }
109 121
110 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) 122 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest)
111 { 123 {
112 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); 124 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch);
113 } 125 }
114 126
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 eventInit.setCancelable(true); 291 eventInit.setCancelable(true);
280 eventInit.setRequest(request); 292 eventInit.setRequest(request);
281 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 293 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
282 eventInit.setIsReload(webRequest.isReload()); 294 eventInit.setIsReload(webRequest.isReload());
283 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer)); 295 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer));
284 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ; 296 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ;
285 observer->didDispatchEvent(defaultPrevented); 297 observer->didDispatchEvent(defaultPrevented);
286 } 298 }
287 299
288 } // namespace blink 300 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698