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

Unified Diff: third_party/WebKit/Source/wtf/RetainPtr.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/RefVector.h ('k') | third_party/WebKit/Source/wtf/SaturatedArithmetic.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/RetainPtr.h
diff --git a/third_party/WebKit/Source/wtf/RetainPtr.h b/third_party/WebKit/Source/wtf/RetainPtr.h
index 53b4d424cdd709eebd9f49593695f8d787db12e9..fcc397c1c6d62b3b788cda84e3976a25bea1eb64 100644
--- a/third_party/WebKit/Source/wtf/RetainPtr.h
+++ b/third_party/WebKit/Source/wtf/RetainPtr.h
@@ -53,264 +53,281 @@ enum AdoptCFTag { AdoptCF };
enum AdoptNSTag { AdoptNS };
#ifdef __OBJC__
-inline void adoptNSReference(id ptr)
-{
- if (ptr) {
- CFRetain(ptr);
- [ptr release];
- }
+inline void adoptNSReference(id ptr) {
+ if (ptr) {
+ CFRetain(ptr);
+ [ptr release];
+ }
}
#endif
-template <typename T> class RetainPtr {
-public:
- typedef typename std::remove_pointer<T>::type ValueType;
- typedef ValueType* PtrType;
+template <typename T>
+class RetainPtr {
+ public:
+ typedef typename std::remove_pointer<T>::type ValueType;
+ typedef ValueType* PtrType;
- RetainPtr() : m_ptr(nullptr) {}
- RetainPtr(PtrType ptr) : m_ptr(ptr)
- {
- if (ptr)
- CFRetain(ptr);
- }
+ RetainPtr() : m_ptr(nullptr) {}
+ RetainPtr(PtrType ptr) : m_ptr(ptr) {
+ if (ptr)
+ CFRetain(ptr);
+ }
- RetainPtr(AdoptCFTag, PtrType ptr) : m_ptr(ptr) {}
- RetainPtr(AdoptNSTag, PtrType ptr) : m_ptr(ptr) { adoptNSReference(ptr); }
+ RetainPtr(AdoptCFTag, PtrType ptr) : m_ptr(ptr) {}
+ RetainPtr(AdoptNSTag, PtrType ptr) : m_ptr(ptr) { adoptNSReference(ptr); }
- RetainPtr(const RetainPtr& o) : m_ptr(o.m_ptr)
- {
- if (PtrType ptr = m_ptr)
- CFRetain(ptr);
- }
+ RetainPtr(const RetainPtr& o) : m_ptr(o.m_ptr) {
+ if (PtrType ptr = m_ptr)
+ CFRetain(ptr);
+ }
- RetainPtr(RetainPtr&& o) : m_ptr(o.leakRef()) {}
+ RetainPtr(RetainPtr&& o) : m_ptr(o.leakRef()) {}
- // Hash table deleted values, which are only constructed and never copied or
- // destroyed.
- RetainPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
- bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
+ // Hash table deleted values, which are only constructed and never copied or
+ // destroyed.
+ RetainPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) {}
+ bool isHashTableDeletedValue() const {
+ return m_ptr == hashTableDeletedValue();
+ }
- ~RetainPtr()
- {
- if (PtrType ptr = m_ptr)
- CFRelease(ptr);
- }
+ ~RetainPtr() {
+ if (PtrType ptr = m_ptr)
+ CFRelease(ptr);
+ }
- template <typename U> RetainPtr(const RetainPtr<U>&);
+ template <typename U>
+ RetainPtr(const RetainPtr<U>&);
- void clear();
- PtrType leakRef() WARN_UNUSED_RETURN;
+ void clear();
+ PtrType leakRef() WARN_UNUSED_RETURN;
- PtrType get() const { return m_ptr; }
- PtrType operator->() const { return m_ptr; }
+ PtrType get() const { return m_ptr; }
+ PtrType operator->() const { return m_ptr; }
- bool operator!() const { return !m_ptr; }
+ bool operator!() const { return !m_ptr; }
- // This conversion operator allows implicit conversion to bool but not to
- // other integer types.
- typedef PtrType RetainPtr::*UnspecifiedBoolType;
- operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : 0; }
+ // This conversion operator allows implicit conversion to bool but not to
+ // other integer types.
+ typedef PtrType RetainPtr::*UnspecifiedBoolType;
+ operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : 0; }
- RetainPtr& operator=(const RetainPtr&);
- template <typename U> RetainPtr& operator=(const RetainPtr<U>&);
- RetainPtr& operator=(PtrType);
- template <typename U> RetainPtr& operator=(U*);
+ RetainPtr& operator=(const RetainPtr&);
+ template <typename U>
+ RetainPtr& operator=(const RetainPtr<U>&);
+ RetainPtr& operator=(PtrType);
+ template <typename U>
+ RetainPtr& operator=(U*);
- RetainPtr& operator=(RetainPtr&&);
- template <typename U> RetainPtr& operator=(RetainPtr<U>&&);
+ RetainPtr& operator=(RetainPtr&&);
+ template <typename U>
+ RetainPtr& operator=(RetainPtr<U>&&);
- RetainPtr& operator=(std::nullptr_t)
- {
- clear();
- return *this;
- }
+ RetainPtr& operator=(std::nullptr_t) {
+ clear();
+ return *this;
+ }
- void adoptCF(PtrType);
- void adoptNS(PtrType);
+ void adoptCF(PtrType);
+ void adoptNS(PtrType);
- void swap(RetainPtr&);
+ void swap(RetainPtr&);
-private:
- static PtrType hashTableDeletedValue() { return reinterpret_cast<PtrType>(-1); }
+ private:
+ static PtrType hashTableDeletedValue() {
+ return reinterpret_cast<PtrType>(-1);
+ }
- PtrType m_ptr;
+ PtrType m_ptr;
};
template <typename T>
-template <typename U> inline RetainPtr<T>::RetainPtr(const RetainPtr<U>& o)
- : m_ptr(o.get())
-{
- if (PtrType ptr = m_ptr)
- CFRetain(ptr);
+template <typename U>
+inline RetainPtr<T>::RetainPtr(const RetainPtr<U>& o) : m_ptr(o.get()) {
+ if (PtrType ptr = m_ptr)
+ CFRetain(ptr);
}
-template <typename T> inline void RetainPtr<T>::clear()
-{
- if (PtrType ptr = m_ptr) {
- m_ptr = nullptr;
- CFRelease(ptr);
- }
+template <typename T>
+inline void RetainPtr<T>::clear() {
+ if (PtrType ptr = m_ptr) {
+ m_ptr = nullptr;
+ CFRelease(ptr);
+ }
}
-template <typename T> inline typename RetainPtr<T>::PtrType RetainPtr<T>::leakRef()
-{
- PtrType ptr = m_ptr;
- m_ptr = nullptr;
- return ptr;
+template <typename T>
+inline typename RetainPtr<T>::PtrType RetainPtr<T>::leakRef() {
+ PtrType ptr = m_ptr;
+ m_ptr = nullptr;
+ return ptr;
}
-template <typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<T>& o)
-{
- PtrType optr = o.get();
- if (optr)
- CFRetain(optr);
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
- return *this;
+template <typename T>
+inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<T>& o) {
+ PtrType optr = o.get();
+ if (optr)
+ CFRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
+ return *this;
}
template <typename T>
-template <typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<U>& o)
-{
- PtrType optr = o.get();
- if (optr)
- CFRetain(optr);
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
- return *this;
+template <typename U>
+inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<U>& o) {
+ PtrType optr = o.get();
+ if (optr)
+ CFRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
+ return *this;
}
-template <typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(PtrType optr)
-{
- if (optr)
- CFRetain(optr);
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
- return *this;
+template <typename T>
+inline RetainPtr<T>& RetainPtr<T>::operator=(PtrType optr) {
+ if (optr)
+ CFRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
+ return *this;
}
template <typename T>
-template <typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(U* optr)
-{
- if (optr)
- CFRetain(optr);
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
- return *this;
+template <typename U>
+inline RetainPtr<T>& RetainPtr<T>::operator=(U* optr) {
+ if (optr)
+ CFRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
+ return *this;
}
-template <typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<T>&& o)
-{
- adoptCF(o.leakRef());
- return *this;
+template <typename T>
+inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<T>&& o) {
+ adoptCF(o.leakRef());
+ return *this;
}
template <typename T>
-template <typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<U>&& o)
-{
- adoptCF(o.leakRef());
- return *this;
+template <typename U>
+inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<U>&& o) {
+ adoptCF(o.leakRef());
+ return *this;
}
-template <typename T> inline void RetainPtr<T>::adoptCF(PtrType optr)
-{
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
+template <typename T>
+inline void RetainPtr<T>::adoptCF(PtrType optr) {
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
}
-template <typename T> inline void RetainPtr<T>::adoptNS(PtrType optr)
-{
- adoptNSReference(optr);
+template <typename T>
+inline void RetainPtr<T>::adoptNS(PtrType optr) {
+ adoptNSReference(optr);
- PtrType ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- CFRelease(ptr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ CFRelease(ptr);
}
-template <typename T> inline void RetainPtr<T>::swap(RetainPtr<T>& o)
-{
- std::swap(m_ptr, o.m_ptr);
+template <typename T>
+inline void RetainPtr<T>::swap(RetainPtr<T>& o) {
+ std::swap(m_ptr, o.m_ptr);
}
-template <typename T> inline void swap(RetainPtr<T>& a, RetainPtr<T>& b)
-{
- a.swap(b);
+template <typename T>
+inline void swap(RetainPtr<T>& a, RetainPtr<T>& b) {
+ a.swap(b);
}
-template <typename T, typename U> inline bool operator==(const RetainPtr<T>& a, const RetainPtr<U>& b)
-{
- return a.get() == b.get();
+template <typename T, typename U>
+inline bool operator==(const RetainPtr<T>& a, const RetainPtr<U>& b) {
+ return a.get() == b.get();
}
-template <typename T, typename U> inline bool operator==(const RetainPtr<T>& a, U* b)
-{
- return a.get() == b;
+template <typename T, typename U>
+inline bool operator==(const RetainPtr<T>& a, U* b) {
+ return a.get() == b;
}
-template <typename T, typename U> inline bool operator==(T* a, const RetainPtr<U>& b)
-{
- return a == b.get();
+template <typename T, typename U>
+inline bool operator==(T* a, const RetainPtr<U>& b) {
+ return a == b.get();
}
-template <typename T, typename U> inline bool operator!=(const RetainPtr<T>& a, const RetainPtr<U>& b)
-{
- return a.get() != b.get();
+template <typename T, typename U>
+inline bool operator!=(const RetainPtr<T>& a, const RetainPtr<U>& b) {
+ return a.get() != b.get();
}
-template <typename T, typename U> inline bool operator!=(const RetainPtr<T>& a, U* b)
-{
- return a.get() != b;
+template <typename T, typename U>
+inline bool operator!=(const RetainPtr<T>& a, U* b) {
+ return a.get() != b;
}
-template <typename T, typename U> inline bool operator!=(T* a, const RetainPtr<U>& b)
-{
- return a != b.get();
+template <typename T, typename U>
+inline bool operator!=(T* a, const RetainPtr<U>& b) {
+ return a != b.get();
}
-template <typename T> inline RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
-template <typename T> inline RetainPtr<T> adoptCF(T o)
-{
- return RetainPtr<T>(AdoptCF, o);
+template <typename T>
+inline RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+template <typename T>
+inline RetainPtr<T> adoptCF(T o) {
+ return RetainPtr<T>(AdoptCF, o);
}
-template <typename T> inline RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
-template <typename T> inline RetainPtr<T> adoptNS(T o)
-{
- return RetainPtr<T>(AdoptNS, o);
+template <typename T>
+inline RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+template <typename T>
+inline RetainPtr<T> adoptNS(T o) {
+ return RetainPtr<T>(AdoptNS, o);
}
// Helper function for creating a RetainPtr using template argument deduction.
-template <typename T> inline RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN;
-template <typename T> inline RetainPtr<T> retainPtr(T o)
-{
- return RetainPtr<T>(o);
+template <typename T>
+inline RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN;
+template <typename T>
+inline RetainPtr<T> retainPtr(T o) {
+ return RetainPtr<T>(o);
}
-template <typename P> struct HashTraits<RetainPtr<P>> : SimpleClassHashTraits<RetainPtr<P>> { };
-
-template <typename P> struct PtrHash<RetainPtr<P>> : PtrHash<typename RetainPtr<P>::PtrType> {
- using PtrHash<typename RetainPtr<P>::PtrType>::hash;
- static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); }
- using PtrHash<typename RetainPtr<P>::PtrType>::equal;
- static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) { return a == b; }
- static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) { return a == b; }
- static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) { return a == b; }
+template <typename P>
+struct HashTraits<RetainPtr<P>> : SimpleClassHashTraits<RetainPtr<P>> {};
+
+template <typename P>
+struct PtrHash<RetainPtr<P>> : PtrHash<typename RetainPtr<P>::PtrType> {
+ using PtrHash<typename RetainPtr<P>::PtrType>::hash;
+ static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); }
+ using PtrHash<typename RetainPtr<P>::PtrType>::equal;
+ static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) {
+ return a == b;
+ }
+ static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) {
+ return a == b;
+ }
+ static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) {
+ return a == b;
+ }
};
-template <typename P> struct DefaultHash<RetainPtr<P>> { typedef PtrHash<RetainPtr<P>> Hash; };
+template <typename P>
+struct DefaultHash<RetainPtr<P>> {
+ typedef PtrHash<RetainPtr<P>> Hash;
+};
-} // namespace WTF
+} // namespace WTF
using WTF::AdoptCF;
using WTF::AdoptNS;
@@ -319,4 +336,4 @@ using WTF::adoptNS;
using WTF::RetainPtr;
using WTF::retainPtr;
-#endif // WTF_RetainPtr_h
+#endif // WTF_RetainPtr_h
« no previous file with comments | « third_party/WebKit/Source/wtf/RefVector.h ('k') | third_party/WebKit/Source/wtf/SaturatedArithmetic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698