OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef USBInTransferResult_h | 5 #ifndef USBInTransferResult_h |
6 #define USBInTransferResult_h | 6 #define USBInTransferResult_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/dom/DOMArrayBuffer.h" | 9 #include "core/dom/DOMArrayBuffer.h" |
10 #include "core/dom/DOMDataView.h" | 10 #include "core/dom/DOMDataView.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "public/platform/modules/webusb/WebUSBTransferInfo.h" | 12 #include "wtf/Vector.h" |
13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class USBInTransferResult final | 17 class USBInTransferResult final |
18 : public GarbageCollectedFinalized<USBInTransferResult> | 18 : public GarbageCollectedFinalized<USBInTransferResult> |
19 , public ScriptWrappable { | 19 , public ScriptWrappable { |
20 DEFINE_WRAPPERTYPEINFO(); | 20 DEFINE_WRAPPERTYPEINFO(); |
21 public: | 21 public: |
22 static USBInTransferResult* create(const String& status, const WebVector<uin
t8_t> data) | 22 static USBInTransferResult* create(const String& status, const Vector<uint8_
t>& data) |
23 { | 23 { |
24 return new USBInTransferResult(status, data); | 24 return new USBInTransferResult(status, data); |
25 } | 25 } |
26 | 26 |
27 USBInTransferResult(const String& status, const WebVector<uint8_t> data) | 27 USBInTransferResult(const String& status, const Vector<uint8_t>& data) |
28 : m_status(status) | 28 : m_status(status) |
29 , m_data(DOMDataView::create(DOMArrayBuffer::create(data.data(), data.si
ze()), 0, data.size())) | 29 , m_data(DOMDataView::create(DOMArrayBuffer::create(data.data(), data.si
ze()), 0, data.size())) |
30 { | 30 { |
31 } | 31 } |
32 | 32 |
33 virtual ~USBInTransferResult() { } | 33 virtual ~USBInTransferResult() { } |
34 | 34 |
35 String status() const { return m_status; } | 35 String status() const { return m_status; } |
36 DOMDataView* data() const { return m_data; } | 36 DOMDataView* data() const { return m_data; } |
37 | 37 |
38 DEFINE_INLINE_TRACE() | 38 DEFINE_INLINE_TRACE() |
39 { | 39 { |
40 visitor->trace(m_data); | 40 visitor->trace(m_data); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 const String m_status; | 44 const String m_status; |
45 const Member<DOMDataView> m_data; | 45 const Member<DOMDataView> m_data; |
46 }; | 46 }; |
47 | 47 |
48 } // namespace blink | 48 } // namespace blink |
49 | 49 |
50 #endif // USBInTransferResult_h | 50 #endif // USBInTransferResult_h |
OLD | NEW |