// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TYPED_ARRAYS_ARRAY_BUFFER_VIEW_HELPERS_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_TYPED_ARRAYS_ARRAY_BUFFER_VIEW_HELPERS_H_ #include <type_traits> #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/type_traits.h" namespace blink { // A wrapper template type that is used to ensure that a TypedArray is not // backed by a SharedArrayBuffer. It is usable like a smart pointer. // // void Foo(NotShared<DOMUint32Array> param) { // size_t length = param->length(); // ... // } template <typename T> class NotShared { … }; // A wrapper template type that specifies that a TypedArray *may* be backed by // a SharedArrayBuffer. It is usable like a smart pointer. // // void Foo(MaybeShared<DOMUint32Array> param) { // DOMArrayBuffer* buffer = param->buffer(); // ... // } template <typename T> class MaybeShared { … }; } // namespace blink namespace WTF { // NotShared<T> is essentially Member<T> from the perspective of HeapVector. VectorTraits<blink::NotShared<T>>; // MaybeShared<T> is essentially Member<T> from the perspective of HeapVector. VectorTraits<blink::MaybeShared<T>>; } // namespace WTF #endif // THIRD_PARTY_BLINK_RENDERER_CORE_TYPED_ARRAYS_ARRAY_BUFFER_VIEW_HELPERS_H_