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

Unified Diff: Source/modules/bluetooth/BluetoothArrayBuffer.cpp

Issue 1147243004: bluetooth: readValue Blink implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-read-value-interface
Patch Set: readValue blink Implementation. Created 5 years, 6 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/modules/bluetooth/BluetoothArrayBuffer.cpp
diff --git a/Source/modules/bluetooth/BluetoothArrayBuffer.cpp b/Source/modules/bluetooth/BluetoothArrayBuffer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6f5dcea86edac569678bdd3ebebf707d929eba5d
--- /dev/null
+++ b/Source/modules/bluetooth/BluetoothArrayBuffer.cpp
@@ -0,0 +1,31 @@
+// Copyright 2014 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.
+
+#include "config.h"
+#include "modules/bluetooth/BluetoothArrayBuffer.h"
+
+#include "wtf/OwnPtr.h"
+
+namespace blink {
+
+PassRefPtr<DOMArrayBuffer> BluetoothArrayBuffer::take(ScriptPromiseResolver*, WebVector<uint8_t>* webVectorRawPointer)
+{
+ OwnPtr<WebVector<uint8_t>> webVector = adoptPtr(webVectorRawPointer);
+
+ int numElements = webVector->size();
+ size_t sizeOfElements = sizeof(uint8_t);
+
+ RefPtr<DOMArrayBuffer> domBuffer = DOMArrayBuffer::create(
Jeffrey Yasskin 2015/06/10 21:12:25 DOMArrayBuffer::create(webVector->data(), webVecto
ortuno 2015/06/11 00:10:52 Done.
+ numElements, sizeOfElements);
+
+ memcpy(domBuffer->data(), webVector->data(), numElements * sizeOfElements);
+ return domBuffer;
+}
+
+void BluetoothArrayBuffer::dispose(WebVector<uint8_t>* webBufferRaw)
+{
+ delete webBufferRaw;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698