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

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

Issue 1658073002: ServiceWorker: Implement attributes of ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address falken's comments 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 { 100 {
101 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); 101 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID);
102 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer)); 102 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer));
103 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 103 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
104 } 104 }
105 105
106 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels) 106 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels)
107 { 107 {
108 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ; 108 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
109 109
110 ExtendableMessageEventInit initializer; 110 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
111 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels);
112 // TODO(nhiroki): Support |origin| and |source| attributes.
113 // (http://crbug.com/543198)
114
111 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 115 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
112 116
113 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(EventTypeName s::message, initializer, observer)); 117 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, String (), ports, observer));
114 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 118 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
115 } 119 }
116 120
117 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) 121 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest)
118 { 122 {
119 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); 123 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch);
120 } 124 }
121 125
122 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) 126 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest)
123 { 127 {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 eventInit.setCancelable(true); 295 eventInit.setCancelable(true);
292 eventInit.setRequest(request); 296 eventInit.setRequest(request);
293 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 297 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
294 eventInit.setIsReload(webRequest.isReload()); 298 eventInit.setIsReload(webRequest.isReload());
295 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer)); 299 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer));
296 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ; 300 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ;
297 observer->didDispatchEvent(defaultPrevented); 301 observer->didDispatchEvent(defaultPrevented);
298 } 302 }
299 303
300 } // namespace blink 304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698