| Index: third_party/WebKit/Source/wtf/PassOwnPtr.h
|
| diff --git a/third_party/WebKit/Source/platform/weborigin/KURLHash.h b/third_party/WebKit/Source/wtf/PassOwnPtr.h
|
| similarity index 58%
|
| copy from third_party/WebKit/Source/platform/weborigin/KURLHash.h
|
| copy to third_party/WebKit/Source/wtf/PassOwnPtr.h
|
| index ee12f70f504ccf5027139aa47cc36746a0dcaacf..37b1b37f12789ee61e99e25c32ec2df859ce9316 100644
|
| --- a/third_party/WebKit/Source/platform/weborigin/KURLHash.h
|
| +++ b/third_party/WebKit/Source/wtf/PassOwnPtr.h
|
| @@ -1,5 +1,6 @@
|
| /*
|
| - * Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
| + * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
|
| + * Copyright (C) 2013 Intel Corporation. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions
|
| @@ -23,41 +24,41 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef KURLHash_h
|
| -#define KURLHash_h
|
| +#ifndef WTF_PassOwnPtr_h
|
| +#define WTF_PassOwnPtr_h
|
|
|
| -#include "platform/weborigin/KURL.h"
|
| #include "wtf/Allocator.h"
|
| -#include "wtf/text/StringHash.h"
|
| -#include "wtf/text/WTFString.h"
|
| +#include "wtf/Forward.h"
|
| +#include "wtf/Noncopyable.h"
|
| +#include "wtf/OwnPtr.h"
|
|
|
| -namespace blink {
|
| -
|
| -// KURLHash doesn't support null KURLs. get(), contains(), and add() on
|
| -// HashMap<KURL,..., KURLHash> cause a null-pointer dereference when passed null
|
| -// KURLs.
|
| +namespace WTF {
|
|
|
| -struct KURLHash {
|
| - STATIC_ONLY(KURLHash);
|
| - static unsigned hash(const KURL& key)
|
| - {
|
| - return key.getString().impl()->hash();
|
| - }
|
| +// PassOwnPtr is now an alias of OwnPtr, as defined in Forward.h.
|
|
|
| - static bool equal(const KURL& a, const KURL& b)
|
| - {
|
| - return StringHash::equal(a.getString(), b.getString());
|
| - }
|
| +template <typename T> PassOwnPtr<T> adoptPtr(T*);
|
| +template <typename T> PassOwnPtr<T[]> adoptArrayPtr(T*);
|
|
|
| - static const bool safeToCompareToEmptyOrDeleted = false;
|
| -};
|
| +template <typename T> inline PassOwnPtr<T> adoptPtr(T* ptr)
|
| +{
|
| + return PassOwnPtr<T>(ptr);
|
| +}
|
|
|
| -} // namespace blink
|
| +template <typename T> inline PassOwnPtr<T[]> adoptArrayPtr(T* ptr)
|
| +{
|
| + return PassOwnPtr<T[]>(ptr);
|
| +}
|
|
|
| -namespace WTF {
|
| -
|
| -template<> struct HashTraits<blink::KURL> : SimpleClassHashTraits<blink::KURL> { };
|
| +template <typename T, typename U> inline PassOwnPtr<T> static_pointer_cast(PassOwnPtr<U>&& p)
|
| +{
|
| + static_assert(!std::is_array<T>::value, "pointers to array must never be converted");
|
| + return adoptPtr(static_cast<T*>(p.leakPtr()));
|
| +}
|
|
|
| } // namespace WTF
|
|
|
| -#endif // KURLHash_h
|
| +using WTF::adoptPtr;
|
| +using WTF::adoptArrayPtr;
|
| +using WTF::static_pointer_cast;
|
| +
|
| +#endif // WTF_PassOwnPtr_h
|
|
|