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

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

Issue 1148383012: Oilpan: prefer eager finalization over prefinalizers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expand&improve comments Created 5 years, 6 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 | Annotate | Revision Log
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker))); 143 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker)));
144 worker->suspendIfNeeded(); 144 worker->suspendIfNeeded();
145 return worker.release(); 145 return worker.release();
146 } 146 }
147 147
148 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) 148 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker)
149 : AbstractWorker(executionContext) 149 : AbstractWorker(executionContext)
150 , m_outerWorker(worker) 150 , m_outerWorker(worker)
151 , m_wasStopped(false) 151 , m_wasStopped(false)
152 { 152 {
153 #if ENABLE(OILPAN)
154 ThreadState::current()->registerPreFinalizer(*this);
155 #endif
156 ASSERT(m_outerWorker); 153 ASSERT(m_outerWorker);
157 m_outerWorker->setProxy(this); 154 m_outerWorker->setProxy(this);
158 } 155 }
159 156
160 ServiceWorker::~ServiceWorker() 157 ServiceWorker::~ServiceWorker()
161 { 158 {
162 #if ENABLE(OILPAN)
163 ASSERT(!m_outerWorker);
164 #endif
165 }
166
167 void ServiceWorker::dispose()
168 {
169 // With Oilpan enabled, the observable lifetime of a ServiceWorker
170 // must not extend beyond when it has been deemed to be unreachable
171 // by the garbage collector. The embedder must be detached before
172 // it is eventually (lazily) swept, so as to prevent that. Otherwise
173 // the embedder might risk accessing a to-be-finalized object that
174 // is not in a valid state.
175 //
176 // The dispose() method is hooked up to the garbage collector by
177 // way of a "pre finalizer", a method that is run after marking
178 // has completed, but before any sweeping takes place.
179 m_outerWorker.clear();
180 } 159 }
181 160
182 } // namespace blink 161 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorker.h ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698