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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 541943003: ServiceWorker: Remove navigator.serviceWorker.{installing,waiting,active} (Blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update expectations Created 6 years, 3 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void ServiceWorkerContainer::willBeDetachedFromFrame() 67 void ServiceWorkerContainer::willBeDetachedFromFrame()
68 { 68 {
69 if (m_provider) { 69 if (m_provider) {
70 m_provider->setClient(0); 70 m_provider->setClient(0);
71 m_provider = nullptr; 71 m_provider = nullptr;
72 } 72 }
73 } 73 }
74 74
75 void ServiceWorkerContainer::trace(Visitor* visitor) 75 void ServiceWorkerContainer::trace(Visitor* visitor)
76 { 76 {
77 visitor->trace(m_active);
78 visitor->trace(m_controller); 77 visitor->trace(m_controller);
79 visitor->trace(m_installing);
80 visitor->trace(m_waiting);
81 visitor->trace(m_readyRegistration); 78 visitor->trace(m_readyRegistration);
82 visitor->trace(m_ready); 79 visitor->trace(m_ready);
83 } 80 }
84 81
85 ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS tate, const String& url, const Dictionary& dictionary) 82 ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS tate, const String& url, const Dictionary& dictionary)
86 { 83 {
87 RegistrationOptionList options(dictionary); 84 RegistrationOptionList options(dictionary);
88 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); 85 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled());
89 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 86 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
90 ScriptPromise promise = resolver->promise(); 87 ScriptPromise promise = resolver->promise();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (serviceWorker && !serviceWorker->proxy()) 190 if (serviceWorker && !serviceWorker->proxy())
194 delete serviceWorker; 191 delete serviceWorker;
195 } 192 }
196 193
197 static void deleteIfNoExistingOwner(WebServiceWorkerRegistration* registration) 194 static void deleteIfNoExistingOwner(WebServiceWorkerRegistration* registration)
198 { 195 {
199 if (registration && !registration->proxy()) 196 if (registration && !registration->proxy())
200 delete registration; 197 delete registration;
201 } 198 }
202 199
200 void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker)
201 {
202 if (!executionContext()) {
203 deleteIfNoExistingOwner(serviceWorker);
204 return;
205 }
206 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
207 }
208
203 void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration) 209 void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
204 { 210 {
205 if (!executionContext()) { 211 if (!executionContext()) {
206 deleteIfNoExistingOwner(registration); 212 deleteIfNoExistingOwner(registration);
207 return; 213 return;
208 } 214 }
209 215
210 ServiceWorkerRegistration* readyRegistration = ServiceWorkerRegistration::fr om(executionContext(), registration); 216 ServiceWorkerRegistration* readyRegistration = ServiceWorkerRegistration::fr om(executionContext(), registration);
211 ASSERT(readyRegistration->active()); 217 ASSERT(readyRegistration->active());
212 218
213 if (m_readyRegistration) { 219 if (m_readyRegistration) {
214 ASSERT(m_readyRegistration == readyRegistration); 220 ASSERT(m_readyRegistration == readyRegistration);
215 ASSERT(m_ready->state() == ReadyProperty::Resolved); 221 ASSERT(m_ready->state() == ReadyProperty::Resolved);
216 return; 222 return;
217 } 223 }
218 224
219 m_readyRegistration = readyRegistration; 225 m_readyRegistration = readyRegistration;
220 m_ready->resolve(readyRegistration); 226 m_ready->resolve(readyRegistration);
221 } 227 }
222 228
223 void ServiceWorkerContainer::setActive(WebServiceWorker* serviceWorker)
224 {
225 if (!executionContext()) {
226 deleteIfNoExistingOwner(serviceWorker);
227 return;
228 }
229 m_active = ServiceWorker::from(executionContext(), serviceWorker);
230 }
231
232 void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker)
233 {
234 if (!executionContext()) {
235 deleteIfNoExistingOwner(serviceWorker);
236 return;
237 }
238 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
239 }
240
241 void ServiceWorkerContainer::setInstalling(WebServiceWorker* serviceWorker)
242 {
243 if (!executionContext()) {
244 deleteIfNoExistingOwner(serviceWorker);
245 return;
246 }
247 m_installing = ServiceWorker::from(executionContext(), serviceWorker);
248 }
249
250 void ServiceWorkerContainer::setWaiting(WebServiceWorker* serviceWorker)
251 {
252 if (!executionContext()) {
253 deleteIfNoExistingOwner(serviceWorker);
254 return;
255 }
256 m_waiting = ServiceWorker::from(executionContext(), serviceWorker);
257 }
258
259 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels) 229 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels)
260 { 230 {
261 if (!executionContext() || !executionContext()->executingWindow()) 231 if (!executionContext() || !executionContext()->executingWindow())
262 return; 232 return;
263 233
264 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); 234 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels);
265 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire( message); 235 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire( message);
266 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); 236 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value));
267 } 237 }
268 238
269 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 239 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
270 : ContextLifecycleObserver(executionContext) 240 : ContextLifecycleObserver(executionContext)
271 , m_provider(0) 241 , m_provider(0)
272 { 242 {
273 ScriptWrappable::init(this); 243 ScriptWrappable::init(this);
274 244
275 if (!executionContext) 245 if (!executionContext)
276 return; 246 return;
277 247
278 m_ready = createReadyProperty(); 248 m_ready = createReadyProperty();
279 249
280 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 250 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
281 m_provider = client->provider(); 251 m_provider = client->provider();
282 if (m_provider) 252 if (m_provider)
283 m_provider->setClient(this); 253 m_provider->setClient(this);
284 } 254 }
285 } 255 }
286 256
287 } // namespace blink 257 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698