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

Side by Side Diff: Source/wtf/WeakPtr.h

Issue 876623002: Adds a CancellableTaskFactory and exposes postLoadingTasks to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 WeakPtr<T> createWeakPtr() { return WeakPtr<T>(m_ref); } 133 WeakPtr<T> createWeakPtr() { return WeakPtr<T>(m_ref); }
134 134
135 void revokeAll() 135 void revokeAll()
136 { 136 {
137 T* ptr = m_ref->get(); 137 T* ptr = m_ref->get();
138 m_ref->clear(); 138 m_ref->clear();
139 // We create a new WeakReference so that future calls to createWeakPtr() create nonzero WeakPtrs. 139 // We create a new WeakReference so that future calls to createWeakPtr() create nonzero WeakPtrs.
140 m_ref = WeakReference<T>::create(ptr); 140 m_ref = WeakReference<T>::create(ptr);
141 } 141 }
142 142
143 bool hasWeakPtrs() const
144 {
145 return m_ref->refCount() > 1;
146 }
147
143 private: 148 private:
144 RefPtr<WeakReference<T>> m_ref; 149 RefPtr<WeakReference<T>> m_ref;
145 }; 150 };
146 151
147 } // namespace WTF 152 } // namespace WTF
148 153
149 using WTF::WeakPtr; 154 using WTF::WeakPtr;
150 using WTF::WeakPtrFactory; 155 using WTF::WeakPtrFactory;
151 using WTF::WeakReference; 156 using WTF::WeakReference;
152 157
153 #endif 158 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698