Commit a67f5458 authored by tzik's avatar tzik Committed by Commit Bot

Make WTF::PassRefPtr an alias of WTF::RefPtr

This CL converts WTF::PassRefPtr to an alias of WTF::RefPtr, and removes
the implementation.

Bug: 494719
Change-Id: Ide96ef03dfa69668c1de87891a712bcd46470e13
Reviewed-on: https://chromium-review.googlesource.com/657786
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501218}
parent 3468b0d9
......@@ -274,7 +274,7 @@ crbug.com/704961 [ Mac ] virtual/layout_ng/external/wpt/css/CSS2/positioning/abs
### virtual/layout_ng Mac textarea.
crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/float/overhanging-tall-block.html [ Failure ]
crbug.com/763494 [ Mac ] virtual/layout_ng/fast/block/float/editable-text-overlapping-float.html [ Failure ]
crbug.com/763494 [ Mac ] virtual/layout_ng/fast/block/float/editable-text-overlapping-float.html [ Crash Failure ]
### virtual/layout_ng Mac 1px glyph difference.
crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/basic/015.html [ Failure ]
......
......@@ -94,23 +94,13 @@ struct CrossThreadCopier
// CrossThreadCopier specializations follow.
template <typename T>
struct CrossThreadCopier<PassRefPtr<T>> {
STATIC_ONLY(CrossThreadCopier);
typedef PassRefPtr<T> Type;
static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value,
"PassRefPtr<T> can be passed across threads only if T is "
"ThreadSafeRefCounted.");
static PassRefPtr<T> Copy(PassRefPtr<T>&& pointer) {
return std::move(pointer);
}
};
template <typename T>
struct CrossThreadCopier<RefPtr<T>>
: public CrossThreadCopierPassThrough<RefPtr<T>> {
STATIC_ONLY(CrossThreadCopier);
static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value,
"RefPtr<T> can be passed across threads only if T is "
"ThreadSafeRefCounted.");
static RefPtr<T> Copy(RefPtr<T> pointer) { return pointer; }
};
template <typename T>
struct CrossThreadCopier<sk_sp<T>>
......
......@@ -85,7 +85,7 @@ float* WebAudioBus::ChannelData(unsigned channel_index) {
return private_->Channel(channel_index)->MutableData();
}
PassRefPtr<AudioBus> WebAudioBus::Release() {
RefPtr<AudioBus> WebAudioBus::Release() {
RefPtr<AudioBus> audio_bus(AdoptRef(static_cast<AudioBus*>(private_)));
private_ = 0;
return audio_bus;
......
......@@ -26,11 +26,11 @@
namespace WTF {
template <typename T>
class PassRefPtr;
template <typename T>
class RefPtr;
template <typename T>
using PassRefPtr = RefPtr<T>;
template <typename T>
class StringBuffer;
template <typename T, size_t inlineCapacity, typename Allocator>
class Vector;
......
......@@ -171,11 +171,6 @@ struct ParamStorageTraits {
"GCed type is forbidden as a bound parameters.");
};
template <typename T>
struct ParamStorageTraits<PassRefPtr<T>> {
typedef RefPtr<T> StorageType;
};
template <typename T>
struct ParamStorageTraits<RefPtr<T>> {
typedef RefPtr<T> StorageType;
......
......@@ -150,16 +150,10 @@ template <typename T>
struct RefPtrHash : PtrHash<T> {
using PtrHash<T>::GetHash;
static unsigned GetHash(const RefPtr<T>& key) { return GetHash(key.Get()); }
static unsigned GetHash(const PassRefPtr<T>& key) {
return GetHash(key.Get());
}
using PtrHash<T>::Equal;
static bool Equal(const RefPtr<T>& a, const RefPtr<T>& b) { return a == b; }
static bool Equal(T* a, const RefPtr<T>& b) { return a == b; }
static bool Equal(const RefPtr<T>& a, T* b) { return a == b; }
static bool Equal(const RefPtr<T>& a, const PassRefPtr<T>& b) {
return a == b;
}
};
template <typename T>
......
......@@ -29,15 +29,11 @@
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Assertions.h"
#include "platform/wtf/Compiler.h"
#include "platform/wtf/Forward.h"
#include "platform/wtf/TypeTraits.h"
namespace WTF {
template <typename T>
class RefPtr;
template <typename T>
class PassRefPtr;
// requireAdoption() is not overloaded for WTF::RefCounted, which has a built-in
// assumption that adoption is required. requireAdoption() is for bootstrapping
// alternate reference count classes that are compatible with RefPtr/PassRefPtr
......@@ -60,147 +56,11 @@ ALWAYS_INLINE void DerefIfNotNull(T* ptr) {
ptr->Deref();
}
template <typename T>
class PassRefPtr {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
public:
PassRefPtr() : ptr_(nullptr) {}
PassRefPtr(std::nullptr_t) : ptr_(nullptr) {}
PassRefPtr(T* ptr) : ptr_(ptr) { RefIfNotNull(ptr); }
PassRefPtr(PassRefPtr&& o) : ptr_(o.LeakRef()) {}
template <typename U>
PassRefPtr(PassRefPtr<U>&& o, EnsurePtrConvertibleArgDecl(U, T))
: ptr_(o.LeakRef()) {}
ALWAYS_INLINE ~PassRefPtr() { DerefIfNotNull(ptr_); }
template <typename U>
PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T));
template <typename U>
PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T));
T* Get() const { return ptr_; }
WARN_UNUSED_RESULT T* LeakRef();
T& operator*() const { return *ptr_; }
T* operator->() const { return ptr_; }
bool operator!() const { return !ptr_; }
explicit operator bool() const { return ptr_ != nullptr; }
private:
PassRefPtr& operator=(const PassRefPtr&) {
static_assert(!sizeof(T*), "PassRefPtr should never be assigned to");
return *this;
}
T* ptr_;
};
template <typename T>
PassRefPtr<T> WrapPassRefPtr(T* ptr) {
return PassRefPtr<T>(ptr);
}
template <typename T>
template <typename U>
inline PassRefPtr<T>::PassRefPtr(const RefPtr<U>& o,
EnsurePtrConvertibleArgDefn(U, T))
: ptr_(o.Get()) {
T* ptr = ptr_;
RefIfNotNull(ptr);
}
template <typename T>
template <typename U>
inline PassRefPtr<T>::PassRefPtr(RefPtr<U>&& o,
EnsurePtrConvertibleArgDefn(U, T))
: ptr_(o.LeakRef()) {}
template <typename T>
inline T* PassRefPtr<T>::LeakRef() {
T* ptr = ptr_;
ptr_ = nullptr;
return ptr;
}
template <typename T, typename U>
inline bool operator==(const PassRefPtr<T>& a, const PassRefPtr<U>& b) {
return a.Get() == b.Get();
}
template <typename T, typename U>
inline bool operator==(const PassRefPtr<T>& a, const RefPtr<U>& b) {
return a.Get() == b.Get();
}
template <typename T, typename U>
inline bool operator==(const RefPtr<T>& a, const PassRefPtr<U>& b) {
return a.Get() == b.Get();
}
template <typename T, typename U>
inline bool operator==(const PassRefPtr<T>& a, U* b) {
return a.Get() == b;
}
template <typename T, typename U>
inline bool operator==(T* a, const PassRefPtr<U>& b) {
return a == b.Get();
}
template <typename T>
inline bool operator==(const PassRefPtr<T>& a, std::nullptr_t) {
return !a.Get();
}
template <typename T>
inline bool operator==(std::nullptr_t, const PassRefPtr<T>& b) {
return !b.Get();
}
template <typename T, typename U>
inline bool operator!=(const PassRefPtr<T>& a, const PassRefPtr<U>& b) {
return a.Get() != b.Get();
}
template <typename T, typename U>
inline bool operator!=(const PassRefPtr<T>& a, const RefPtr<U>& b) {
return a.Get() != b.Get();
}
template <typename T, typename U>
inline bool operator!=(const RefPtr<T>& a, const PassRefPtr<U>& b) {
return a.Get() != b.Get();
}
template <typename T, typename U>
inline bool operator!=(const PassRefPtr<T>& a, U* b) {
return a.Get() != b;
}
template <typename T, typename U>
inline bool operator!=(T* a, const PassRefPtr<U>& b) {
return a != b.Get();
}
template <typename T>
inline bool operator!=(const PassRefPtr<T>& a, std::nullptr_t) {
return a.Get();
}
template <typename T>
inline bool operator!=(std::nullptr_t, const PassRefPtr<T>& b) {
return b.Get();
}
template <typename T>
inline T* GetPtr(const PassRefPtr<T>& p) {
return p.Get();
}
} // namespace WTF
using WTF::PassRefPtr;
......
......@@ -31,8 +31,6 @@
namespace WTF {
template <typename T>
class PassRefPtr;
template <typename T>
class RefPtrValuePeeker;
template <typename T>
......@@ -63,11 +61,6 @@ class RefPtr {
RefPtr(RefPtr<U>&& o, EnsurePtrConvertibleArgDecl(U, T))
: ptr_(o.LeakRef()) {}
// See comments in PassRefPtr.h for an explanation of why this takes a const
// reference.
template <typename U>
RefPtr(PassRefPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T));
// Hash table deleted values, which are only constructed and never copied or
// destroyed.
RefPtr(HashTableDeletedValueType) : ptr_(HashTableDeletedValue()) {}
......@@ -112,11 +105,6 @@ class RefPtr {
T* ptr_;
};
template <typename T>
template <typename U>
inline RefPtr<T>::RefPtr(PassRefPtr<U>&& o, EnsurePtrConvertibleArgDefn(U, T))
: ptr_(o.LeakRef()) {}
template <typename T>
inline T* RefPtr<T>::LeakRef() {
T* ptr = ptr_;
......@@ -213,8 +201,6 @@ class RefPtrValuePeeker {
ALWAYS_INLINE RefPtrValuePeeker(std::nullptr_t) : ptr_(nullptr) {}
template <typename U>
RefPtrValuePeeker(const RefPtr<U>& p) : ptr_(p.Get()) {}
template <typename U>
RefPtrValuePeeker(const PassRefPtr<U>& p) : ptr_(p.Get()) {}
ALWAYS_INLINE operator T*() const { return ptr_; }
......
......@@ -30,7 +30,7 @@
#if INSIDE_BLINK
namespace WTF {
template <typename T>
class PassRefPtr;
class RefPtr;
}
#endif
......@@ -68,7 +68,7 @@ class BLINK_PLATFORM_EXPORT WebAudioBus {
float* ChannelData(unsigned channel_index);
#if INSIDE_BLINK
WTF::PassRefPtr<AudioBus> Release();
WTF::RefPtr<AudioBus> Release();
#endif
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment