| Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| index 66e9220f27561f0d36387cb1317592a45d316076..c3e3884f35ca6d57d53a6b204603bb0a65a9dcea 100644
|
| --- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| @@ -497,6 +497,10 @@ private:
|
| }
|
| };
|
|
|
| +// Needed to give this variable a definition (the initializer above is only a
|
| +// declaration), so that subclasses can use it.
|
| +const int ThreadedTesterBase::numberOfThreads;
|
| +
|
| class ThreadedHeapTester : public ThreadedTesterBase {
|
| public:
|
| static void test()
|
| @@ -6483,4 +6487,45 @@ TEST(HeapTest, TestStaticLocals)
|
| EXPECT_EQ(33, heapVectorIntWrapper[0]->value());
|
| }
|
|
|
| +namespace {
|
| +
|
| +class ThreadedClearOnShutdownTester : public ThreadedTesterBase {
|
| +public:
|
| + static void test()
|
| + {
|
| + IntWrapper::s_destructorCalls = 0;
|
| + ThreadedTesterBase::test(new ThreadedClearOnShutdownTester);
|
| + EXPECT_EQ(numberOfThreads, IntWrapper::s_destructorCalls);
|
| + }
|
| +
|
| +private:
|
| + void runThread() override
|
| + {
|
| + ThreadState::attach();
|
| + EXPECT_EQ(42, threadSpecificIntWrapper().value());
|
| + ThreadState::detach();
|
| + atomicDecrement(&m_threadsToFinish);
|
| + }
|
| +
|
| + static IntWrapper& threadSpecificIntWrapper()
|
| + {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(
|
| + ThreadSpecific<Persistent<IntWrapper>>, intWrapper,
|
| + new ThreadSpecific<Persistent<IntWrapper>>);
|
| + Persistent<IntWrapper>& handle = *intWrapper;
|
| + if (!handle) {
|
| + handle = new IntWrapper(42);
|
| + handle.clearOnThreadShutdown();
|
| + }
|
| + return *handle;
|
| + }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +TEST(HeapTest, TestClearOnShutdown)
|
| +{
|
| + ThreadedClearOnShutdownTester::test();
|
| +}
|
| +
|
| } // namespace blink
|
|
|