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

Unified Diff: Source/core/streams/ReadableStream.h

Issue 407453002: ReadableStream initial implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/streams/ReadableStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/streams/ReadableStream.h
diff --git a/Source/core/streams/ReadableStream.h b/Source/core/streams/ReadableStream.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc5c32bd6c9e9b681d837aa94dded97a8687e2fb
--- /dev/null
+++ b/Source/core/streams/ReadableStream.h
@@ -0,0 +1,73 @@
+// Copyright 2014 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 ReadableStream_h
+#define ReadableStream_h
+
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/ScriptValue.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "platform/heap/Handle.h"
+#include "wtf/RefPtr.h"
+
+namespace blink {
+
+class ExceptionState;
+class UnderlyingSource;
+
+class ReadableStream FINAL : public GarbageCollectedFinalized<ReadableStream> {
+public:
+ enum State {
+ Readable,
+ Waiting,
+ Closed,
+ Errored,
+ };
+
+ // FIXME: Define Strategy here.
+ // FIXME: Add |strategy| constructor parameter.
+ ReadableStream(ScriptState*, UnderlyingSource*, ExceptionState*);
+ virtual ~ReadableStream();
+
+ template <typename T>
+ bool enqueue(const T& chunk)
+ {
+ ScriptState::Scope scope(m_scriptState.get());
+ return enqueueInternal(ScriptValue(m_scriptState.get(), V8ValueTraits<T>::toV8Value(chunk)));
+ }
+
+ bool isStarted() const { return m_isStarted; }
+ bool isDraining() const { return m_isDraining; }
+ bool isPulling() const { return m_isPulling; }
+ State state() const { return m_state; }
+
+ // FIXME: Implement these APIs.
+ // bool read();
+ // ScriptPromise wait();
+ // void close();
+
+ void error(ScriptValue error);
+
+ void trace(Visitor*);
+
+private:
+ class OnStarted;
+ class OnStartFailed;
+
+ void onStarted(void);
+ bool enqueueInternal(ScriptValue chunk);
+
+ RefPtr<ScriptState> m_scriptState;
+ Member<UnderlyingSource> m_source;
+ bool m_isStarted;
+ bool m_isDraining;
+ bool m_isPulling;
+ State m_state;
+};
+
+} // namespace blink
+
+#endif // ReadableStream_h
+
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/streams/ReadableStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698