OLD | NEW |
(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/QueuingStrategyBase.h" |
| 12 #include "core/streams/UnderlyingSourceBase.h" |
| 13 #include <v8.h> |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 // TODO probably needs to be GCed. Like ScriptPromiseProperty? Or we need a sepa
rate ReadableStreamProperty? |
| 18 |
| 19 class CORE_EXPORT ReadableStream2 { |
| 20 public: |
| 21 enum State { |
| 22 Readable = 0, |
| 23 Closed = 1, |
| 24 Errored = 2, |
| 25 }; |
| 26 |
| 27 // This is for UA-created ReadableStreams |
| 28 ReadableStream2(ScriptState*, UnderlyingSourceBase*, QueuingStrategyBase*); |
| 29 |
| 30 bool isLocked() const; |
| 31 |
| 32 // TODO(domenic): also a constructor for converting author-created ReadableS
treams, e.g. for use in the bindings for |
| 33 // functions/setters that accept ReadableStream? |
| 34 |
| 35 bool isObject() const |
| 36 { |
| 37 return m_stream.isObject(); |
| 38 } |
| 39 |
| 40 bool isNull() const |
| 41 { |
| 42 return m_stream.isNull(); |
| 43 } |
| 44 |
| 45 bool isUndefinedOrNull() const |
| 46 { |
| 47 return m_stream.isUndefined() || m_stream.isNull(); |
| 48 } |
| 49 |
| 50 ScriptValue scriptValue() const |
| 51 { |
| 52 return m_stream; |
| 53 } |
| 54 |
| 55 v8::Local<v8::Value> v8Value() const |
| 56 { |
| 57 return m_stream.v8Value(); |
| 58 } |
| 59 |
| 60 v8::Isolate* isolate() const |
| 61 { |
| 62 return m_stream.isolate(); |
| 63 } |
| 64 |
| 65 bool isEmpty() const |
| 66 { |
| 67 return m_stream.isEmpty(); |
| 68 } |
| 69 |
| 70 void clear() |
| 71 { |
| 72 m_stream.clear(); |
| 73 } |
| 74 |
| 75 bool operator==(const ReadableStream2& value) const |
| 76 { |
| 77 return m_stream == value.m_stream; |
| 78 } |
| 79 |
| 80 bool operator!=(const ReadableStream2& value) const |
| 81 { |
| 82 return !operator==(value); |
| 83 } |
| 84 |
| 85 private: |
| 86 ScriptValue m_stream; |
| 87 }; |
| 88 |
| 89 } // namespace blink |
| 90 |
| 91 #endif // ReadableStream2_h |
OLD | NEW |