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

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

Issue 396963002: ServiceWorker: Bypass resolving a promise when ExecutionContext is gone (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 4 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::from(ScriptPromiseResolver* resolver, WebType* worker) 157 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::from(ScriptPromiseResolver* resolver, WebType* worker)
158 { 158 {
159 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = ServiceWorker::from(resolv er->scriptState()->executionContext(), worker); 159 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = ServiceWorker::from(resolv er->scriptState()->executionContext(), worker);
160 ScriptState::Scope scope(resolver->scriptState()); 160 ScriptState::Scope scope(resolver->scriptState());
161 if (serviceWorker->m_proxyState == Initial) 161 if (serviceWorker->m_proxyState == Initial)
162 serviceWorker->waitOnPromise(resolver->promise()); 162 serviceWorker->waitOnPromise(resolver->promise());
163 return serviceWorker; 163 return serviceWorker;
164 } 164 }
165 165
166 void ServiceWorker::dispose(WebType* worker)
167 {
168 if (worker && !worker->proxy())
169 delete worker;
170 }
171
166 void ServiceWorker::setProxyState(ProxyState state) 172 void ServiceWorker::setProxyState(ProxyState state)
167 { 173 {
168 if (m_proxyState == state) 174 if (m_proxyState == state)
169 return; 175 return;
170 switch (m_proxyState) { 176 switch (m_proxyState) {
171 case Initial: 177 case Initial:
172 ASSERT(state == RegisterPromisePending || state == ContextStopped); 178 ASSERT(state == RegisterPromisePending || state == ContextStopped);
173 break; 179 break;
174 case RegisterPromisePending: 180 case RegisterPromisePending:
175 ASSERT(state == Ready || state == ContextStopped); 181 ASSERT(state == Ready || state == ContextStopped);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 , WebServiceWorkerProxy(this) 239 , WebServiceWorkerProxy(this)
234 , m_outerWorker(worker) 240 , m_outerWorker(worker)
235 , m_proxyState(Initial) 241 , m_proxyState(Initial)
236 { 242 {
237 ScriptWrappable::init(this); 243 ScriptWrappable::init(this);
238 ASSERT(m_outerWorker); 244 ASSERT(m_outerWorker);
239 m_outerWorker->setProxy(this); 245 m_outerWorker->setProxy(this);
240 } 246 }
241 247
242 } // namespace blink 248 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorker.h ('k') | Source/modules/serviceworkers/ServiceWorkerClients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698