| Index: third_party/WebKit/Source/wtf/CrossThreadCopier.h
|
| diff --git a/third_party/WebKit/Source/core/dom/custom/V0CustomElementDescriptorHash.h b/third_party/WebKit/Source/wtf/CrossThreadCopier.h
|
| similarity index 54%
|
| copy from third_party/WebKit/Source/core/dom/custom/V0CustomElementDescriptorHash.h
|
| copy to third_party/WebKit/Source/wtf/CrossThreadCopier.h
|
| index 2a0d2f5a37e6967bdc3fc49f02bca4769fe9d67b..f921890f59d866850cad3f186141b15a5ec5f28c 100644
|
| --- a/third_party/WebKit/Source/core/dom/custom/V0CustomElementDescriptorHash.h
|
| +++ b/third_party/WebKit/Source/wtf/CrossThreadCopier.h
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -28,42 +28,55 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef V0CustomElementDescriptorHash_h
|
| -#define V0CustomElementDescriptorHash_h
|
| +#ifndef CrossThreadCopier_h
|
| +#define CrossThreadCopier_h
|
|
|
| -#include "core/dom/custom/V0CustomElementDescriptor.h"
|
| #include "wtf/Allocator.h"
|
| -#include "wtf/HashFunctions.h"
|
| -#include "wtf/HashTraits.h"
|
| -#include "wtf/text/AtomicStringHash.h"
|
| +#include <memory>
|
| +#include <type_traits>
|
|
|
| -namespace blink {
|
| +namespace WTF {
|
|
|
| -struct V0CustomElementDescriptorHash {
|
| - STATIC_ONLY(V0CustomElementDescriptorHash);
|
| - static unsigned hash(const V0CustomElementDescriptor& descriptor)
|
| +template <typename T>
|
| +struct CrossThreadCopierPassThrough {
|
| + STATIC_ONLY(CrossThreadCopierPassThrough);
|
| + typedef T Type;
|
| + static Type copy(const T& parameter)
|
| {
|
| - return WTF::hashInts(AtomicStringHash::hash(descriptor.type()), WTF::hashInts(AtomicStringHash::hash(descriptor.namespaceURI()), AtomicStringHash::hash(descriptor.localName())));
|
| + return parameter;
|
| }
|
| +};
|
|
|
| - static bool equal(const V0CustomElementDescriptor& a, const V0CustomElementDescriptor& b)
|
| - {
|
| - return a == b;
|
| - }
|
| +template <typename T, bool isArithmeticOrEnum>
|
| +struct CrossThreadCopierBase;
|
|
|
| - static const bool safeToCompareToEmptyOrDeleted = true;
|
| +// Arithmetic values (integers or floats) and enums can be safely copied.
|
| +template <typename T>
|
| +struct CrossThreadCopierBase<T, true> : public CrossThreadCopierPassThrough<T> {
|
| + STATIC_ONLY(CrossThreadCopierBase);
|
| };
|
|
|
| -} // namespace blink
|
| +template <typename T>
|
| +struct CrossThreadCopier : public CrossThreadCopierBase<T, std::is_arithmetic<T>::value || std::is_enum<T>::value> {
|
| + STATIC_ONLY(CrossThreadCopier);
|
| +};
|
|
|
| -namespace WTF {
|
| +// nullptr_t can be passed through without any changes.
|
| +template <>
|
| +struct CrossThreadCopier<std::nullptr_t> : public CrossThreadCopierPassThrough<std::nullptr_t> {
|
| + STATIC_ONLY(CrossThreadCopier);
|
| +};
|
|
|
| -template<>
|
| -struct HashTraits<blink::V0CustomElementDescriptor> : SimpleClassHashTraits<blink::V0CustomElementDescriptor> {
|
| - STATIC_ONLY(HashTraits);
|
| - static const bool emptyValueIsZero = HashTraits<AtomicString>::emptyValueIsZero;
|
| +template <typename T, typename Deleter>
|
| +struct CrossThreadCopier<std::unique_ptr<T, Deleter>> {
|
| + STATIC_ONLY(CrossThreadCopier);
|
| + using Type = std::unique_ptr<T, Deleter>;
|
| + static std::unique_ptr<T, Deleter> copy(std::unique_ptr<T, Deleter> pointer)
|
| + {
|
| + return pointer; // This is in fact a move.
|
| + }
|
| };
|
|
|
| } // namespace WTF
|
|
|
| -#endif // V0CustomElementDescriptorHash
|
| +#endif // CrossThreadCopier_h
|
|
|