Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: Source/core/dom/TypedFlexibleArrayBufferView.h

Issue 1269443002: Introduce FlexibleArrayBufferView and TypedFlexibleArrayBufferView (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/TypedFlexibleArrayBufferView.h
diff --git a/Source/core/dom/TypedFlexibleArrayBufferView.h b/Source/core/dom/TypedFlexibleArrayBufferView.h
new file mode 100644
index 0000000000000000000000000000000000000000..73a3020c0b97e9c7921b0b74cc039550cc2a3956
--- /dev/null
+++ b/Source/core/dom/TypedFlexibleArrayBufferView.h
@@ -0,0 +1,32 @@
+// Copyright 2015 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 TypedFlexibleArrayBufferView_h
+#define TypedFlexibleArrayBufferView_h
+
+#include "core/CoreExport.h"
+#include "core/dom/FlexibleArrayBufferView.h"
+#include "wtf/Noncopyable.h"
+
+namespace blink {
+
+template<typename WTFTypedArray>
+class CORE_TEMPLATE_CLASS_EXPORT TypedFlexibleArrayBufferView final : public FlexibleArrayBufferView {
+ DISALLOW_ALLOCATION();
+ WTF_MAKE_NONCOPYABLE(TypedFlexibleArrayBufferView);
haraken 2015/07/30 14:54:57 Add WTF_MAKE_FAST_ALLOCATED.
Michael Lippautz 2015/07/30 17:06:15 STACK_ALLOCATED() (?)
+public:
+ typedef typename WTFTypedArray::ValueType ValueType;
haraken 2015/07/30 14:54:57 Use 'using'.
Michael Lippautz 2015/07/30 17:06:15 Done.
+
+ TypedFlexibleArrayBufferView() : FlexibleArrayBufferView() {}
+
+ ValueType* data() const { return static_cast<ValueType*>(baseAddress()); }
haraken 2015/07/30 14:54:57 I'd rename this to dataMaybeOnStack() or something
Michael Lippautz 2015/07/30 17:06:15 Done.
+ unsigned length() const { return byteLength() / sizeof(ValueType); }
+};
+
+typedef TypedFlexibleArrayBufferView<WTF::Float32Array> FlexibleFloat32ArrayView;
+typedef TypedFlexibleArrayBufferView<WTF::Int32Array> FlexibleInt32ArrayView;
haraken 2015/07/30 14:54:57 Blink prefers 'using' in the new coding style.
Michael Lippautz 2015/07/30 17:06:15 Done.
+
+} // namespace blink
+
+#endif // TypedFlexibleArrayBufferView_h

Powered by Google App Engine
This is Rietveld 408576698