Index: third_party/WebKit/Source/core/dom/NotShared.h |
diff --git a/third_party/WebKit/Source/core/dom/NotShared.h b/third_party/WebKit/Source/core/dom/NotShared.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28cc38906cfc1bbcfa60ff560c4d2a730620482b |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/dom/NotShared.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NotShared_h |
+#define NotShared_h |
+ |
+#include "platform/heap/Handle.h" |
+ |
+namespace blink { |
+ |
+template <typename T> |
+class CORE_EXPORT NotShared { |
haraken
2017/04/06 08:43:54
Add a class-level comment.
binji
2017/04/09 00:40:02
Done.
|
+ STACK_ALLOCATED(); |
+ |
+ public: |
+ using TypedArrayType = T; |
+ |
+ NotShared() {} |
+ |
+ explicit NotShared(T* typedArray) : m_typedArray(typedArray) { |
+ DCHECK(!(typedArray && typedArray->view()->isShared())); |
+ } |
+ NotShared(const NotShared& other) = default; |
+ template <typename U> |
+ NotShared(const NotShared<U>& other) : m_typedArray(other.view()) {} |
+ template <typename U> |
+ NotShared(const Member<U>& other) { |
+ DCHECK(!other->view()->isShared()); |
+ m_typedArray = *other; |
+ } |
+ |
+#if 0 |
haraken
2017/04/06 08:43:54
Remove this.
binji
2017/04/09 00:40:02
Done.
|
+ NotShared& operator=(T* typedArray) { |
+ DCHECK(!typedArray->view()->isShared()); |
+ m_typedArray = typedArray; |
+ return *this; |
+ } |
+#endif |
+ NotShared& operator=(const NotShared& other) = default; |
+ template <typename U> |
+ NotShared& operator=(const NotShared<U>& other) { |
+ m_typedArray = other.view(); |
+ return *this; |
+ } |
+#if 0 |
haraken
2017/04/06 08:43:54
Remove this.
binji
2017/04/09 00:40:02
Done.
|
+ template <typename U> |
+ NotShared& operator=(const Member<U>& other) { |
+ DCHECK(!other->view()->isShared()); |
+ m_typedArray = *other; |
+ return *this; |
+ } |
+#endif |
+ |
+ T* view() const { return m_typedArray.get(); } |
+ |
+ bool operator!() const { return !m_typedArray; } |
+ explicit operator bool() const { return !!m_typedArray; } |
+ operator ScriptWrappable*() const { return m_typedArray.get(); } |
+ operator Member<T>() const { return Member<T>(m_typedArray.get()); } |
haraken
2017/04/06 08:43:54
I'd prefer not adding these implicit conversions.
binji
2017/04/09 00:40:02
Done.
|
+ |
+ private: |
+ Member<T> m_typedArray; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // NotShared_h |