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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1850413002: Improve DEFINE_STATIC_LOCAL()'s handling of Blink GCed objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address compilation failure Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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 2afa6e335e6fe03034c568ec8832434908bd0515..f2ef207db2a11cd69ba6a5a1e814ad90153d4fdb 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -6497,4 +6497,25 @@ TEST(HeapTest, TestPersistentHeapVectorWithUnusedSlots)
#endif
}
+TEST(HeapTest, TestStaticLocals)
+{
+ // Sanity check DEFINE_STATIC_LOCAL()s over heap allocated objects and collections.
+
+ DEFINE_STATIC_LOCAL(IntWrapper, intWrapper, (new IntWrapper(33)));
+ DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<IntWrapper>>, persistentHeapVectorIntWrapper, ());
+ DEFINE_STATIC_LOCAL(HeapVector<Member<IntWrapper>>, heapVectorIntWrapper, (new HeapVector<Member<IntWrapper>>));
+
+ EXPECT_EQ(33, intWrapper.value());
+ EXPECT_EQ(0u, persistentHeapVectorIntWrapper.size());
+ EXPECT_EQ(0u, heapVectorIntWrapper.size());
+
+ persistentHeapVectorIntWrapper.append(&intWrapper);
+ heapVectorIntWrapper.append(&intWrapper);
+ EXPECT_EQ(1u, persistentHeapVectorIntWrapper.size());
+ EXPECT_EQ(1u, heapVectorIntWrapper.size());
+
+ EXPECT_EQ(persistentHeapVectorIntWrapper[0], heapVectorIntWrapper[0]);
+ EXPECT_EQ(33, heapVectorIntWrapper[0]->value());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.cpp ('k') | third_party/WebKit/Source/web/InspectorOverlay.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698