| OLD | NEW |
| 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 Loading... |
| 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 #if ENABLE(OILPAN) |
| 264 ThreadState::current()->registerPreFinalizer(*this); |
| 265 #endif |
| 263 ASSERT(m_outerWorker); | 266 ASSERT(m_outerWorker); |
| 264 m_outerWorker->setProxy(this); | 267 m_outerWorker->setProxy(this); |
| 265 } | 268 } |
| 266 | 269 |
| 270 ServiceWorker::~ServiceWorker() |
| 271 { |
| 272 #if ENABLE(OILPAN) |
| 273 ASSERT(!m_outerWorker); |
| 274 #endif |
| 275 } |
| 276 |
| 277 void ServiceWorker::dispose() |
| 278 { |
| 279 // With Oilpan enabled, the observable lifetime of a ServiceWorker |
| 280 // must not extend beyond when it has been deemed to be unreachable |
| 281 // by the garbage collector. The embedder must be detached before |
| 282 // it is eventually (lazily) swept, so as to prevent that. Otherwise |
| 283 // the embedder might risk accessing a to-be-finalized object that |
| 284 // is not in a valid state. |
| 285 // |
| 286 // The dispose() method is hooked up to the garbage collector by |
| 287 // way of a "pre finalizer", a method that is run after marking |
| 288 // has completed, but before any sweeping takes place. |
| 289 m_outerWorker.clear(); |
| 290 } |
| 291 |
| 267 } // namespace blink | 292 } // namespace blink |
| OLD | NEW |