| 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 5214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5225 { | 5225 { |
| 5226 Persistent<HeapHashMap<int, WeakMember<IntWrapper>>> map = new HeapHashMap<i
nt, WeakMember<IntWrapper>>(); | 5226 Persistent<HeapHashMap<int, WeakMember<IntWrapper>>> map = new HeapHashMap<i
nt, WeakMember<IntWrapper>>(); |
| 5227 addElementsToWeakMap(map); | 5227 addElementsToWeakMap(map); |
| 5228 HeapHashMap<int, WeakMember<IntWrapper>>::AddResult result = map->add(800, n
ullptr); | 5228 HeapHashMap<int, WeakMember<IntWrapper>>::AddResult result = map->add(800, n
ullptr); |
| 5229 conservativelyCollectGarbage(); | 5229 conservativelyCollectGarbage(); |
| 5230 result.storedValue->value = IntWrapper::create(42); | 5230 result.storedValue->value = IntWrapper::create(42); |
| 5231 } | 5231 } |
| 5232 | 5232 |
| 5233 TEST(HeapTest, Bind) | 5233 TEST(HeapTest, Bind) |
| 5234 { | 5234 { |
| 5235 std::unique_ptr<SameThreadClosure> closure = bind(static_cast<void (Bar::*)(
Visitor*)>(&Bar::trace), Bar::create(), static_cast<Visitor*>(0)); | 5235 std::unique_ptr<SameThreadClosure> closure = bind(static_cast<void (Bar::*)(
Visitor*)>(&Bar::trace), wrapCrossThreadPersistent(Bar::create()), nullptr); |
| 5236 // OffHeapInt* should not make Persistent. | 5236 // OffHeapInt* should not make Persistent. |
| 5237 std::unique_ptr<SameThreadClosure> closure2 = bind(&OffHeapInt::voidFunction
, OffHeapInt::create(1)); | 5237 std::unique_ptr<SameThreadClosure> closure2 = bind(&OffHeapInt::voidFunction
, OffHeapInt::create(1)); |
| 5238 preciselyCollectGarbage(); | 5238 preciselyCollectGarbage(); |
| 5239 // The closure should have a persistent handle to the Bar. | 5239 // The closure should have a persistent handle to the Bar. |
| 5240 EXPECT_EQ(1u, Bar::s_live); | 5240 EXPECT_EQ(1u, Bar::s_live); |
| 5241 | 5241 |
| 5242 UseMixin::s_traceCount = 0; | 5242 UseMixin::s_traceCount = 0; |
| 5243 Mixin* mixin = UseMixin::create(); | 5243 Mixin* mixin = UseMixin::create(); |
| 5244 std::unique_ptr<SameThreadClosure> mixinClosure = bind(static_cast<void (Mix
in::*)(Visitor*)>(&Mixin::trace), mixin, static_cast<Visitor*>(0)); | 5244 std::unique_ptr<SameThreadClosure> mixinClosure = bind(static_cast<void (Mix
in::*)(Visitor*)>(&Mixin::trace), wrapCrossThreadPersistent(mixin), nullptr); |
| 5245 preciselyCollectGarbage(); | 5245 preciselyCollectGarbage(); |
| 5246 // The closure should have a persistent handle to the mixin. | 5246 // The closure should have a persistent handle to the mixin. |
| 5247 EXPECT_EQ(1, UseMixin::s_traceCount); | 5247 EXPECT_EQ(1, UseMixin::s_traceCount); |
| 5248 } | 5248 } |
| 5249 | 5249 |
| 5250 typedef HeapHashSet<WeakMember<IntWrapper>> WeakSet; | 5250 typedef HeapHashSet<WeakMember<IntWrapper>> WeakSet; |
| 5251 | 5251 |
| 5252 // These special traits will remove a set from a map when the set is empty. | 5252 // These special traits will remove a set from a map when the set is empty. |
| 5253 struct EmptyClearingHashSetTraits : HashTraits<WeakSet> { | 5253 struct EmptyClearingHashSetTraits : HashTraits<WeakSet> { |
| 5254 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; | 5254 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6924 static_assert(WTF::IsGarbageCollectedType<HeapLinkedHashSet<Member<IntWrappe
r>>>::value, "HeapLinkedHashSet"); | 6924 static_assert(WTF::IsGarbageCollectedType<HeapLinkedHashSet<Member<IntWrappe
r>>>::value, "HeapLinkedHashSet"); |
| 6925 static_assert(WTF::IsGarbageCollectedType<HeapListHashSet<Member<IntWrapper>
>>::value, "HeapListHashSet"); | 6925 static_assert(WTF::IsGarbageCollectedType<HeapListHashSet<Member<IntWrapper>
>>::value, "HeapListHashSet"); |
| 6926 static_assert(WTF::IsGarbageCollectedType<HeapHashCountedSet<Member<IntWrapp
er>>>::value, "HeapHashCountedSet"); | 6926 static_assert(WTF::IsGarbageCollectedType<HeapHashCountedSet<Member<IntWrapp
er>>>::value, "HeapHashCountedSet"); |
| 6927 static_assert(WTF::IsGarbageCollectedType<HeapHashMap<int, Member<IntWrapper
>>>::value, "HeapHashMap"); | 6927 static_assert(WTF::IsGarbageCollectedType<HeapHashMap<int, Member<IntWrapper
>>>::value, "HeapHashMap"); |
| 6928 static_assert(WTF::IsGarbageCollectedType<HeapVector<Member<IntWrapper>>>::v
alue, "HeapVector"); | 6928 static_assert(WTF::IsGarbageCollectedType<HeapVector<Member<IntWrapper>>>::v
alue, "HeapVector"); |
| 6929 static_assert(WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::va
lue, "HeapDeque"); | 6929 static_assert(WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::va
lue, "HeapDeque"); |
| 6930 static_assert(WTF::IsGarbageCollectedType<HeapTerminatedArray<Member<IntWrap
per>>>::value, "HeapTerminatedArray"); | 6930 static_assert(WTF::IsGarbageCollectedType<HeapTerminatedArray<Member<IntWrap
per>>>::value, "HeapTerminatedArray"); |
| 6931 } | 6931 } |
| 6932 | 6932 |
| 6933 } // namespace blink | 6933 } // namespace blink |
| OLD | NEW |