| Index: third_party/WebKit/Source/platform/heap/Handle.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
|
| index 210d88ce413c81b611ce9894b149e7fc4646583b..e45d1e11019f4d08dc6f665dafdd01dff800d72e 100644
|
| --- a/third_party/WebKit/Source/platform/heap/Handle.h
|
| +++ b/third_party/WebKit/Source/platform/heap/Handle.h
|
| @@ -330,6 +330,33 @@ public:
|
| Parent::operator=(other);
|
| return *this;
|
| }
|
| +
|
| + // Requests that the thread state clear this handle when the thread shuts
|
| + // down. This is intended for use with ThreadSpecific<Persistent<T>>.
|
| + // It's important that the Persistent<T> exist until then, because this
|
| + // takes a raw pointer to that handle.
|
| + //
|
| + // Example:
|
| + // Foo& sharedFoo()
|
| + // {
|
| + // DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| + // ThreadSpecific<Persistent<Foo>>, threadSpecificFoo,
|
| + // new ThreadSpecific<Persistent<Foo>>);
|
| + // Persistent<Foo>& fooHandle = *threadSpecificFoo;
|
| + // if (!fooHandle) {
|
| + // fooHandle = new Foo;
|
| + // fooHandle.clearOnThreadShutdown();
|
| + // }
|
| + // return *fooHandle;
|
| + // }
|
| + void clearOnThreadShutdown()
|
| + {
|
| + void (*closure)(Persistent<T>*) = [](Persistent<T>* handle)
|
| + {
|
| + *handle = nullptr;
|
| + };
|
| + ThreadState::current()->registerThreadShutdownHook(WTF::bind(closure, this));
|
| + }
|
| };
|
|
|
| // WeakPersistent is a way to create a weak pointer from an off-heap object
|
|
|