blob: e34fe6efe33bf461547f24f35e9a4502e75a3999 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// 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 THIRD_PARTY_BLINK_RENDERER_MODULES_WEBUSB_USB_IN_TRANSFER_RESULT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBUSB_USB_IN_TRANSFER_RESULT_H_
#include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_data_view.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class USBInTransferResult final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static USBInTransferResult* Create(const String& status,
const Vector<uint8_t>& data) {
DOMDataView* data_view = DOMDataView::Create(
DOMArrayBuffer::Create(data.data(), data.size()), 0, data.size());
return MakeGarbageCollected<USBInTransferResult>(status, data_view);
}
static USBInTransferResult* Create(const String& status) {
return MakeGarbageCollected<USBInTransferResult>(status, nullptr);
}
static USBInTransferResult* Create(const String& status,
NotShared<DOMDataView> data) {
return MakeGarbageCollected<USBInTransferResult>(status, data.View());
}
USBInTransferResult(const String& status, DOMDataView* data)
: status_(status), data_(data) {}
~USBInTransferResult() override = default;
String status() const { return status_; }
DOMDataView* data() const { return data_; }
void Trace(Visitor* visitor) const override {
visitor->Trace(data_);
ScriptWrappable::Trace(visitor);
}
private:
const String status_;
const Member<DOMDataView> data_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBUSB_USB_IN_TRANSFER_RESULT_H_
|