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

Side by Side Diff: Source/core/streams/ReadableStream2.h

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove C++ queuing strategies 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ReadableStream2_h
6 #define ReadableStream2_h
7
8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/ScriptValue.h"
10 #include "core/CoreExport.h"
11 #include "core/streams/UnderlyingSourceBase.h"
12 #include <v8.h>
13
14 namespace blink {
15
16 // TODO probably needs to be GCed. Like ScriptPromiseProperty? Or we need a sepa rate ReadableStreamProperty?
17
18 class CORE_EXPORT ReadableStream2 {
19 public:
20 enum State {
21 Readable = 0,
22 Closed = 1,
23 Errored = 2,
24 };
25
26 // This is for UA-created ReadableStreams
27 ReadableStream2(ScriptState*, UnderlyingSourceBase*, ScriptValue);
28
29 bool isLocked() const;
30
31 static ScriptValue createCountQueuingStrategy(ScriptState*, double highWater Mark);
32
33 // TODO(domenic): also a constructor for converting author-created ReadableS treams, e.g. for use in the bindings for
34 // functions/setters that accept ReadableStream?
35
36 bool isObject() const
37 {
38 return m_stream.isObject();
39 }
40
41 bool isNull() const
42 {
43 return m_stream.isNull();
44 }
45
46 bool isUndefinedOrNull() const
47 {
48 return m_stream.isUndefined() || m_stream.isNull();
49 }
50
51 ScriptValue scriptValue() const
52 {
53 return m_stream;
54 }
55
56 v8::Local<v8::Value> v8Value() const
57 {
58 return m_stream.v8Value();
59 }
60
61 v8::Isolate* isolate() const
62 {
63 return m_stream.isolate();
64 }
65
66 bool isEmpty() const
67 {
68 return m_stream.isEmpty();
69 }
70
71 void clear()
72 {
73 m_stream.clear();
74 }
75
76 bool operator==(const ReadableStream2& value) const
77 {
78 return m_stream == value.m_stream;
79 }
80
81 bool operator!=(const ReadableStream2& value) const
82 {
83 return !operator==(value);
84 }
85
86 private:
87 ScriptValue m_stream;
88 };
89
90 } // namespace blink
91
92 #endif // ReadableStream2_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698