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

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

Issue 1701843002: ServiceWorker: Implement 'source' and 'origin' attributes of ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_focus_into_utils
Patch Set: Created 4 years, 9 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 workerGlobalScope()->setRegistration(handle); 95 workerGlobalScope()->setRegistration(handle);
96 } 96 }
97 97
98 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) 98 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
99 { 99 {
100 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); 100 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID);
101 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer)); 101 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer));
102 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 102 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
103 } 103 }
104 104
105 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels) 105 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels, const W ebServiceWorkerClientInfo& client)
106 { 106 {
107 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ; 107 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
108 108
109 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 109 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
110 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 110 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
111 // TODO(nhiroki): Support |origin| and |source| attributes. 111 ServiceWorkerClient* source = ServiceWorkerClient::create(client);
112 // (http://crbug.com/543198) 112 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(KURL(KURL(), source-> url()));
113
114 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 113 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
115 114
116 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, String (), ports, observer)); 115 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin ->toString(), ports, source, observer));
117 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 116 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
118 } 117 }
119 118
119 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels, WebPass OwnPtr<WebServiceWorker::Handle> handle)
120 {
121 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
122
123 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
124 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
125 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->executionCo ntext(), handle.release());
126 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(KURL(KURL(), source-> scriptURL()));
127 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
128
129 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin ->toString(), ports, source, observer));
130 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
131 }
132
120 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) 133 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest)
121 { 134 {
122 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); 135 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch);
123 } 136 }
124 137
125 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) 138 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest)
126 { 139 {
127 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); 140 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch);
128 } 141 }
129 142
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 eventInit.setCancelable(true); 316 eventInit.setCancelable(true);
304 eventInit.setRequest(request); 317 eventInit.setRequest(request);
305 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 318 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
306 eventInit.setIsReload(webRequest.isReload()); 319 eventInit.setIsReload(webRequest.isReload());
307 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer)); 320 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer));
308 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent.release()); 321 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent.release());
309 observer->didDispatchEvent(dispatchResult); 322 observer->didDispatchEvent(dispatchResult);
310 } 323 }
311 324
312 } // namespace blink 325 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698