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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
67 #include "public/web/WebSerializedScriptValue.h" 67 #include "public/web/WebSerializedScriptValue.h"
68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
69 #include "web/WebEmbeddedWorkerImpl.h" 69 #include "web/WebEmbeddedWorkerImpl.h"
70 #include "wtf/Assertions.h" 70 #include "wtf/Assertions.h"
71 #include "wtf/Functional.h" 71 #include "wtf/Functional.h"
72 #include "wtf/PassOwnPtr.h" 72 #include "wtf/PassOwnPtr.h"
73 73
74 namespace blink { 74 namespace blink {
75 75
76 PassOwnPtrWillBeRawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopePr oxy::create(WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServic eWorkerContextClient& client) 76 RawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create(WebE mbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerContextCl ient& client)
77 { 77 {
78 return adoptPtrWillBeNoop(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client)); 78 return (new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client)) ;
79 } 79 }
80 80
81 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() 81 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy()
82 { 82 {
83 // Verify that the proxy has been detached. 83 // Verify that the proxy has been detached.
84 ASSERT(!m_embeddedWorker); 84 ASSERT(!m_embeddedWorker);
85 } 85 }
86 86
87 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy) 87 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy)
88 { 88 {
89 visitor->trace(m_document); 89 visitor->trace(m_document);
90 visitor->trace(m_workerGlobalScope); 90 visitor->trace(m_workerGlobalScope);
91 } 91 }
92 92
93 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork erRegistration::Handle> handle) 93 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork erRegistration::Handle> handle)
94 { 94 {
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 RawPtr<Event> event(ExtendableEvent::create(EventTypeNames::activate, Extend ableEventInit(), 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)
106 { 106 {
107 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ; 107 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
108 108
109 ExtendableMessageEventInit initializer; 109 ExtendableMessageEventInit initializer;
110 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 110 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
111 111
112 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(EventTypeName s::message, initializer, observer)); 112 RawPtr<Event> event(ExtendableMessageEvent::create(EventTypeNames::message, initializer, observer));
113 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 113 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
114 } 114 }
115 115
116 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) 116 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest)
117 { 117 {
118 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); 118 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch);
119 } 119 }
120 120
121 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) 121 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest)
122 { 122 {
123 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); 123 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch);
124 } 124 }
125 125
126 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region) 126 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region)
127 { 127 {
128 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave; 128 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave;
129 workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region))); 129 workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region)));
130 } 130 }
131 131
132 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) 132 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID)
133 { 133 {
134 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID); 134 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID);
135 RefPtrWillBeRawPtr<Event> event; 135 RawPtr<Event> event;
136 if (RuntimeEnabledFeatures::foreignFetchEnabled()) 136 if (RuntimeEnabledFeatures::foreignFetchEnabled())
137 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer); 137 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer);
138 else 138 else
139 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer); 139 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer);
140 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 140 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
141 } 141 }
142 142
143 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) 143 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels)
144 { 144 {
145 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); 145 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels);
146 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 146 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
147 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value)); 147 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value));
148 } 148 }
149 149
150 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) 150 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex)
151 { 151 {
152 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); 152 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID);
153 NotificationEventInit eventInit; 153 NotificationEventInit eventInit;
154 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */)); 154 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */));
155 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) 155 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size()))
156 eventInit.setAction(data.actions[actionIndex].action); 156 eventInit.setAction(data.actions[actionIndex].action);
157 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); 157 RawPtr<Event> event(NotificationEvent::create(EventTypeNames::notificationcl ick, eventInit, observer));
158 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 158 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
159 } 159 }
160 160
161 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, int64_t notificationID, const WebNotificationData& data) 161 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, int64_t notificationID, const WebNotificationData& data)
162 { 162 {
163 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID); 163 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID);
164 NotificationEventInit eventInit; 164 NotificationEventInit eventInit;
165 eventInit.setAction(WTF::String()); // initialize as null. 165 eventInit.setAction(WTF::String()); // initialize as null.
166 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, false /* showing */)); 166 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, false /* showing */));
167 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclose, eventInit, observer)); 167 RawPtr<Event> event(NotificationEvent::create(EventTypeNames::notificationcl ose, eventInit, observer));
168 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 168 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
169 } 169 }
170 170
171 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 171 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
172 { 172 {
173 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); 173 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID);
174 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 174 RawPtr<Event> event(PushEvent::create(EventTypeNames::push, PushMessageData: :create(data), observer));
175 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 175 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
176 } 176 }
177 177
178 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) 178 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID)
179 { 179 {
180 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); 180 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s);
181 ServicePortCollection* collection = WorkerNavigatorServices::services(worker GlobalScope(), *workerGlobalScope()->navigator()); 181 ServicePortCollection* collection = WorkerNavigatorServices::services(worker GlobalScope(), *workerGlobalScope()->navigator());
182 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID); 182 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID);
183 } 183 }
184 184
185 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync Registration& registration, LastChanceOption lastChance) 185 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync Registration& registration, LastChanceOption lastChance)
186 { 186 {
187 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { 187 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) {
188 ServiceWorkerGlobalScopeClient::from(workerGlobalScope())->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); 188 ServiceWorkerGlobalScopeClient::from(workerGlobalScope())->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted);
189 return; 189 return;
190 } 190 }
191 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Sync, eventID); 191 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Sync, eventID);
192 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, regi stration.tag, lastChance == IsLastChance, observer)); 192 RawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, registration.tag , lastChance == IsLastChance, observer));
193 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 193 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
194 } 194 }
195 195
196 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels) 196 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels)
197 { 197 {
198 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); 198 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels);
199 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 199 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
200 // FIXME: Have proper source for this MessageEvent. 200 // FIXME: Have proper source for this MessageEvent.
201 RefPtrWillBeRawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.origin.string()); 201 RawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.or igin.string());
202 event->setType(EventTypeNames::crossoriginmessage); 202 event->setType(EventTypeNames::crossoriginmessage);
203 workerGlobalScope()->dispatchEvent(event); 203 workerGlobalScope()->dispatchEvent(event);
204 } 204 }
205 205
206 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, int) 206 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, int)
207 { 207 {
208 client().reportException(errorMessage, lineNumber, columnNumber, sourceURL); 208 client().reportException(errorMessage, lineNumber, columnNumber, sourceURL);
209 } 209 }
210 210
211 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(PassRefPtrWillBeRawPtr< ConsoleMessage> consoleMessage) 211 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(RawPtr<ConsoleMessage> consoleMessage)
212 { 212 {
213 client().reportConsoleMessage(consoleMessage->source(), consoleMessage->leve l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur l()); 213 client().reportConsoleMessage(consoleMessage->source(), consoleMessage->leve l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur l());
214 } 214 }
215 215
216 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes sage) 216 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes sage)
217 { 217 {
218 ASSERT(m_embeddedWorker); 218 ASSERT(m_embeddedWorker);
219 document().postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbe ddedWorkerImpl::postMessageToPageInspector, m_embeddedWorker, message)); 219 document().postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbe ddedWorkerImpl::postMessageToPageInspector, m_embeddedWorker, message));
220 } 220 }
221 221
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 { 294 {
295 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); 295 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext());
296 bool defaultPrevented = false; 296 bool defaultPrevented = false;
297 Request* request = Request::create(workerGlobalScope(), webRequest); 297 Request* request = Request::create(workerGlobalScope(), webRequest);
298 request->headers()->setGuard(Headers::ImmutableGuard); 298 request->headers()->setGuard(Headers::ImmutableGuard);
299 FetchEventInit eventInit; 299 FetchEventInit eventInit;
300 eventInit.setCancelable(true); 300 eventInit.setCancelable(true);
301 eventInit.setRequest(request); 301 eventInit.setRequest(request);
302 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 302 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
303 eventInit.setIsReload(webRequest.isReload()); 303 eventInit.setIsReload(webRequest.isReload());
304 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer)); 304 RawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, o bserver));
305 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ; 305 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ;
306 observer->didDispatchEvent(defaultPrevented); 306 observer->didDispatchEvent(defaultPrevented);
307 } 307 }
308 308
309 } // namespace blink 309 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698