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

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

Issue 874003002: Oilpan: dispose ServiceWorker (and registration) objects earlier. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker))); 253 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker)));
254 worker->suspendIfNeeded(); 254 worker->suspendIfNeeded();
255 return worker.release(); 255 return worker.release();
256 } 256 }
257 257
258 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) 258 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker)
259 : AbstractWorker(executionContext) 259 : AbstractWorker(executionContext)
260 , m_outerWorker(worker) 260 , m_outerWorker(worker)
261 , m_proxyState(Initial) 261 , m_proxyState(Initial)
262 { 262 {
263 WILL_REGISTER_PREFINALIZER(this);
263 ASSERT(m_outerWorker); 264 ASSERT(m_outerWorker);
264 m_outerWorker->setProxy(this); 265 m_outerWorker->setProxy(this);
265 } 266 }
266 267
268 ServiceWorker::~ServiceWorker()
269 {
haraken 2015/01/26 01:39:42 Can we add ASSERT(!m_outerWorker)?
sof 2015/01/26 06:32:46 Non-Oilpan you clearly could.
270 }
271
272 void ServiceWorker::dispose()
273 {
274 // With Oilpan enabled, the observable lifetime of a ServiceWorker
275 // must not extend beyond when it has been deemed to be unreachable
276 // by the garbage collector. The embedder must be detached before
277 // it is eventually (lazily) swept, so as to prevent that. Otherwise
278 // the embedder might risk accessing a to-be-finalized object that
279 // is not in a valid state.
280 //
281 // The dispose() method is hooked up to the garbage collector by
282 // way of a "pre finalizer", a method that is run after marking
283 // has completed, but before any sweeping takes place.
284 m_outerWorker.clear();
285 }
286
267 } // namespace blink 287 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698