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

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: handle ownership of WebServiceWorker Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (existingServiceWorker) { 149 if (existingServiceWorker) {
150 ASSERT(existingServiceWorker->executionContext() == executionContext); 150 ASSERT(existingServiceWorker->executionContext() == executionContext);
151 return existingServiceWorker; 151 return existingServiceWorker;
152 } 152 }
153 153
154 return create(executionContext, adoptPtr(worker)); 154 return create(executionContext, adoptPtr(worker));
155 } 155 }
156 156
157 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::from(ScriptPromiseResolver* resolver, WebType* worker) 157 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::from(ScriptPromiseResolver* resolver, WebType* worker)
158 { 158 {
159 if (resolver->scriptState()->contextIsEmpty()) {
haraken 2014/07/17 07:53:36 Shouldn't this check be if(!resolver->scriptState-
nhiroki 2014/07/17 08:30:02 ScriptState::executionContext() refers to V8::Cont
160 if (worker && !worker->proxy())
161 delete worker;
haraken 2014/07/17 07:53:36 I don't understand the memory management here eith
162 return nullptr;
163 }
164
159 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = ServiceWorker::from(resolv er->scriptState()->executionContext(), worker); 165 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = ServiceWorker::from(resolv er->scriptState()->executionContext(), worker);
160 ScriptState::Scope scope(resolver->scriptState()); 166 ScriptState::Scope scope(resolver->scriptState());
161 serviceWorker->waitOnPromise(resolver->promise()); 167 serviceWorker->waitOnPromise(resolver->promise());
162 return serviceWorker; 168 return serviceWorker;
163 } 169 }
164 170
165 void ServiceWorker::setProxyState(ProxyState state) 171 void ServiceWorker::setProxyState(ProxyState state)
166 { 172 {
167 if (m_proxyState == state) 173 if (m_proxyState == state)
168 return; 174 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 , WebServiceWorkerProxy(this) 238 , WebServiceWorkerProxy(this)
233 , m_outerWorker(worker) 239 , m_outerWorker(worker)
234 , m_proxyState(Initial) 240 , m_proxyState(Initial)
235 { 241 {
236 ScriptWrappable::init(this); 242 ScriptWrappable::init(this);
237 ASSERT(m_outerWorker); 243 ASSERT(m_outerWorker);
238 m_outerWorker->setProxy(this); 244 m_outerWorker->setProxy(this);
239 } 245 }
240 246
241 } // namespace WebCore 247 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698