| 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 ReadableStreamOperations_h | 5 #ifndef ReadableStreamOperations_h |
| 6 #define ReadableStreamOperations_h | 6 #define ReadableStreamOperations_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include <v8.h> | 10 #include <v8.h> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class UnderlyingSourceBase; |
| 14 class ExceptionState; | 15 class ExceptionState; |
| 15 class ScriptState; | 16 class ScriptState; |
| 16 | 17 |
| 17 // This class has various methods for ReadableStream[Reader] implemented with | 18 // This class has various methods for ReadableStream[Reader] implemented with |
| 18 // V8 Extras. | 19 // V8 Extras. |
| 19 // All methods should be called in an appropriate V8 context. All ScriptValue | 20 // All methods should be called in an appropriate V8 context. All ScriptValue |
| 20 // arguments must not be empty. | 21 // arguments must not be empty. |
| 21 class CORE_EXPORT ReadableStreamOperations { | 22 class CORE_EXPORT ReadableStreamOperations { |
| 22 STATIC_ONLY(ReadableStreamOperations); | 23 STATIC_ONLY(ReadableStreamOperations); |
| 23 public: | 24 public: |
| 25 // createReadableStreamWithExternalController |
| 26 // If the caller supplies an invalid strategy (e.g. one that returns |
| 27 // negative sizes, or doesn't have appropriate properties), this will crash. |
| 28 static ScriptValue createReadableStream(ScriptState*, UnderlyingSourceBase*,
ScriptValue strategy); |
| 29 |
| 30 // createBuiltInCountQueuingStrategy |
| 31 static ScriptValue createCountQueuingStrategy(ScriptState*, size_t highWater
Mark); |
| 32 |
| 24 // AcquireReadableStreamReader | 33 // AcquireReadableStreamReader |
| 25 // This function assumes |isReadableStream(stream)|. | 34 // This function assumes |isReadableStream(stream)|. |
| 26 // Returns an empty value and throws an error via the ExceptionState when | 35 // Returns an empty value and throws an error via the ExceptionState when |
| 27 // errored. | 36 // errored. |
| 28 static ScriptValue getReader(ScriptState*, ScriptValue stream, ExceptionStat
e&); | 37 static ScriptValue getReader(ScriptState*, ScriptValue stream, ExceptionStat
e&); |
| 29 | 38 |
| 30 // IsReadableStream | 39 // IsReadableStream |
| 31 static bool isReadableStream(ScriptState*, ScriptValue); | 40 static bool isReadableStream(ScriptState*, ScriptValue); |
| 32 | 41 |
| 33 // IsReadableStreamDisturbed | 42 // IsReadableStreamDisturbed |
| 34 // This function assumes |isReadableStream(stream)|. | 43 // This function assumes |isReadableStream(stream)|. |
| 35 static bool isDisturbed(ScriptState*, ScriptValue stream); | 44 static bool isDisturbed(ScriptState*, ScriptValue stream); |
| 36 | 45 |
| 37 // IsReadableStreamLocked | 46 // IsReadableStreamLocked |
| 38 // This function assumes |isReadableStream(stream)|. | 47 // This function assumes |isReadableStream(stream)|. |
| 39 static bool isLocked(ScriptState*, ScriptValue stream); | 48 static bool isLocked(ScriptState*, ScriptValue stream); |
| 40 | 49 |
| 41 // IsReadableStreamReader | 50 // IsReadableStreamReader |
| 42 static bool isReadableStreamReader(ScriptState*, ScriptValue); | 51 static bool isReadableStreamReader(ScriptState*, ScriptValue); |
| 43 | 52 |
| 44 // ReadFromReadableStreamReader | 53 // ReadFromReadableStreamReader |
| 45 // This function assumes |isReadableStreamReader(reader)|. | 54 // This function assumes |isReadableStreamReader(reader)|. |
| 46 static ScriptPromise read(ScriptState*, ScriptValue reader); | 55 static ScriptPromise read(ScriptState*, ScriptValue reader); |
| 47 }; | 56 }; |
| 48 | 57 |
| 49 } // namespace blink | 58 } // namespace blink |
| 50 | 59 |
| 51 #endif // ReadableStreamOperations_h | 60 #endif // ReadableStreamOperations_h |
| OLD | NEW |