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

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: 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::ExtendableMessage, eventID);
112
113 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(EventTypeName s::extendablemessage, 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 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); 119 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext());
108 bool defaultPrevented = false; 120 bool defaultPrevented = false;
109 Request* request = Request::create(workerGlobalScope(), webRequest); 121 Request* request = Request::create(workerGlobalScope(), webRequest);
110 request->headers()->setGuard(Headers::ImmutableGuard); 122 request->headers()->setGuard(Headers::ImmutableGuard);
111 FetchEventInit eventInit; 123 FetchEventInit eventInit;
112 eventInit.setCancelable(true); 124 eventInit.setCancelable(true);
113 eventInit.setRequest(request); 125 eventInit.setRequest(request);
114 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 126 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return *m_document; 281 return *m_document;
270 } 282 }
271 283
272 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st 284 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st
273 { 285 {
274 ASSERT(m_workerGlobalScope); 286 ASSERT(m_workerGlobalScope);
275 return m_workerGlobalScope; 287 return m_workerGlobalScope;
276 } 288 }
277 289
278 } // namespace blink 290 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698