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

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

Issue 912443002: ServiceWorker: Make "ready" fetches registration from browser process(3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add cleanup Created 5 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 { 112 {
113 if (m_provider) { 113 if (m_provider) {
114 m_provider->setClient(0); 114 m_provider->setClient(0);
115 m_provider = nullptr; 115 m_provider = nullptr;
116 } 116 }
117 } 117 }
118 118
119 DEFINE_TRACE(ServiceWorkerContainer) 119 DEFINE_TRACE(ServiceWorkerContainer)
120 { 120 {
121 visitor->trace(m_controller); 121 visitor->trace(m_controller);
122 visitor->trace(m_readyRegistration);
123 visitor->trace(m_ready); 122 visitor->trace(m_ready);
124 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerContainer>: :trace(visitor); 123 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerContainer>: :trace(visitor);
125 ContextLifecycleObserver::trace(visitor); 124 ContextLifecycleObserver::trace(visitor);
126 } 125 }
127 126
128 ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS tate, const String& url, const RegistrationOptions& options) 127 ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS tate, const String& url, const RegistrationOptions& options)
129 { 128 {
130 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); 129 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled());
131 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 130 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
132 ScriptPromise promise = resolver->promise(); 131 ScriptPromise promise = resolver->promise();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 { 271 {
273 if (!executionContext()) { 272 if (!executionContext()) {
274 deleteIfNoExistingOwner(serviceWorker); 273 deleteIfNoExistingOwner(serviceWorker);
275 return; 274 return;
276 } 275 }
277 m_controller = ServiceWorker::from(executionContext(), serviceWorker); 276 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
278 if (shouldNotifyControllerChange) 277 if (shouldNotifyControllerChange)
279 dispatchEvent(Event::create(EventTypeNames::controllerchange)); 278 dispatchEvent(Event::create(EventTypeNames::controllerchange));
280 } 279 }
281 280
282 // FIXME: Remove this after Chrome side CL landed.
283 void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
284 {
285 if (!executionContext()) {
286 ServiceWorkerRegistration::dispose(registration);
287 return;
288 }
289
290 ServiceWorkerRegistration* readyRegistration = ServiceWorkerRegistration::fr om(executionContext(), registration);
291 ASSERT(readyRegistration->active());
292
293 if (m_readyRegistration) {
294 ASSERT(m_readyRegistration == readyRegistration);
295 ASSERT(m_ready->state() == ReadyProperty::Resolved);
296 return;
297 }
298
299 m_readyRegistration = readyRegistration;
300 m_ready->resolve(readyRegistration);
301 }
302
303 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels) 281 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels)
304 { 282 {
305 if (!executionContext() || !executionContext()->executingWindow()) 283 if (!executionContext() || !executionContext()->executingWindow())
306 return; 284 return;
307 285
308 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); 286 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels);
309 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message); 287 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message);
310 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); 288 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value));
311 } 289 }
312 290
(...skipping 22 matching lines...) Expand all
335 } 313 }
336 314
337 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 315 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
338 : ContextLifecycleObserver(executionContext) 316 : ContextLifecycleObserver(executionContext)
339 , m_provider(0) 317 , m_provider(0)
340 { 318 {
341 319
342 if (!executionContext) 320 if (!executionContext)
343 return; 321 return;
344 322
345 // FIXME: Remove this after Chrome side CL landed.
346 m_ready = createReadyProperty();
347
348 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 323 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
349 m_provider = client->provider(); 324 m_provider = client->provider();
350 if (m_provider) 325 if (m_provider)
351 m_provider->setClient(this); 326 m_provider->setClient(this);
352 } 327 }
353 } 328 }
354 329
355 } // namespace blink 330 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | public/platform/WebServiceWorkerProviderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698