Changeset 180528 in webkit
- Timestamp:
- Feb 23, 2015 3:44:02 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r180457 r180528 1 2015-02-23 Brent Fulgham <bfulgham@apple.com> 2 3 WTF::WeakPtr should have a 'forget' method 4 https://bugs.webkit.org/show_bug.cgi?id=141923 5 6 Reviewed by Myles C. Maxfield. 7 8 * wtf/WeakPtr.h: 9 (WTF::WeakPtr::forget): Added. 10 1 11 2015-02-20 Geoffrey Garen <ggaren@apple.com> 2 12 -
trunk/Source/WTF/wtf/WeakPtr.h
r178615 r180528 1 1 /* 2 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2015 Apple Inc. All Rights Reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 41 42 template<typename T> class WeakPtrFactory; 42 43 44 // Note: WeakReference is an implementation detail, and should not be used directly. 43 45 template<typename T> 44 46 class WeakReference : public ThreadSafeRefCounted<WeakReference<T>> { … … 102 104 T* operator->() const { return m_ref->get(); } 103 105 106 void forget() { m_ref = WeakReference<T>::create(nullptr); } 107 104 108 private: 105 109 friend class WeakPtrFactory<T>; -
trunk/Tools/ChangeLog
r180525 r180528 1 2015-02-23 Brent Fulgham <bfulgham@apple.com> 2 3 WTF::WeakPtr should have a 'forget' method. 4 https://bugs.webkit.org/show_bug.cgi?id=141923 5 6 Reviewed by Myles C. Maxfield. 7 8 * TestWebKitAPI/Tests/WTF/WeakPtr.cpp: 9 (TestWebKitAPI::TEST): Added 'Forget' tests case. 10 1 11 2015-02-23 Alexey Proskuryakov <ap@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
r178615 r180528 120 120 } 121 121 122 TEST(WTF_WeakPtr, Forget) 123 { 124 int dummy = 5; 125 int dummy2 = 7; 126 127 WeakPtrFactory<int> outerFactory(&dummy2); 128 WeakPtr<int> weakPtr1, weakPtr2, weakPtr4; 129 { 130 WeakPtrFactory<int> innerFactory(&dummy); 131 weakPtr1 = innerFactory.createWeakPtr(); 132 weakPtr2 = innerFactory.createWeakPtr(); 133 EXPECT_EQ(weakPtr1.get(), &dummy); 134 EXPECT_EQ(weakPtr2.get(), &dummy); 135 weakPtr1.forget(); 136 EXPECT_NULL(weakPtr1.get()); 137 EXPECT_EQ(weakPtr2.get(), &dummy); 138 weakPtr1.forget(); 139 EXPECT_NULL(weakPtr1.get()); 140 EXPECT_EQ(weakPtr2.get(), &dummy); 141 WeakPtr<int> weakPtr3 = weakPtr2; 142 EXPECT_EQ(weakPtr2.get(), &dummy); 143 EXPECT_EQ(weakPtr3.get(), &dummy); 144 weakPtr3.forget(); 145 EXPECT_NULL(weakPtr3.get()); 146 EXPECT_EQ(weakPtr2.get(), &dummy); 147 weakPtr4 = weakPtr2; 148 EXPECT_EQ(weakPtr2.get(), &dummy); 149 EXPECT_EQ(weakPtr4.get(), &dummy); 150 151 weakPtr4 = outerFactory.createWeakPtr(); 152 EXPECT_EQ(weakPtr2.get(), &dummy); 153 EXPECT_EQ(weakPtr4.get(), &dummy2); 154 } 155 156 EXPECT_NULL(weakPtr1.get()); 157 EXPECT_NULL(weakPtr2.get()); 158 EXPECT_EQ(weakPtr4.get(), &dummy2); 159 160 WeakPtr<int> weakPtr5 = weakPtr4; 161 EXPECT_EQ(weakPtr4.get(), &dummy2); 162 EXPECT_EQ(weakPtr5.get(), &dummy2); 163 weakPtr5.forget(); 164 EXPECT_NULL(weakPtr5.get()); 165 WeakPtr<int> weakPtr6 = weakPtr5; 166 EXPECT_NULL(weakPtr6.get()); 167 EXPECT_EQ(weakPtr5.get(), weakPtr6.get()); 168 } 169 122 170 } // namespace TestWebKitAPI
Note: See TracChangeset
for help on using the changeset viewer.