blob: fee10c349a784e6587410b8e83ad2e7676dd983c (
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
59
60
61
62
|
// Copyright 2019 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_CORE_STREAMS_QUEUE_WITH_SIZES_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_QUEUE_WITH_SIZES_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "v8/include/v8.h"
namespace blink {
class ExceptionState;
class Visitor;
// Implementation of the "Queue-with-sizes" operations from the standard. Unlike
// the standard, these operations do not operate polymorphically on the
// container, but require it to have a QueueWithSizes member.
// https://streams.spec.whatwg.org/#queue-with-sizes
class CORE_EXPORT QueueWithSizes final
: public GarbageCollected<QueueWithSizes> {
public:
QueueWithSizes();
// https://streams.spec.whatwg.org/#dequeue-value
v8::Local<v8::Value> DequeueValue(v8::Isolate*);
// Unlike in the standard, this implementation expects the conversion of
// |size| to a number to be done by the caller.
// https://streams.spec.whatwg.org/#enqueue-value-with-size
void EnqueueValueWithSize(v8::Isolate*,
v8::Local<v8::Value> value,
double size,
ExceptionState&);
// https://streams.spec.whatwg.org/#peek-queue-value
v8::Local<v8::Value> PeekQueueValue(v8::Isolate*);
double TotalSize() { return queue_total_size_; }
// Not part of the standard.
bool IsEmpty() { return queue_.IsEmpty(); }
// https://streams.spec.whatwg.org/#reset-queue
void ResetQueue();
void Trace(Visitor* visitor);
private:
class ValueSizePair;
HeapDeque<Member<ValueSizePair>> queue_;
double queue_total_size_ = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_QUEUE_WITH_SIZES_H_
|