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

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

Issue 455303002: Add 'stream' to XMLHttpRequest response type. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@stream-promise-property-reset
Patch Set: Created 6 years, 4 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/streams/ReadableStream.h ('k') | Source/core/streams/ReadableStream.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/streams/ReadableStream.cpp
diff --git a/Source/core/streams/ReadableStream.cpp b/Source/core/streams/ReadableStream.cpp
index b67e0232b193c21927f4af4e4d5f6f3d144d73b1..d87c5624f9357b1eb3f6c91ded0220ba2efce902 100644
--- a/Source/core/streams/ReadableStream.cpp
+++ b/Source/core/streams/ReadableStream.cpp
@@ -16,43 +16,39 @@
namespace blink {
-class ReadableStream::OnStarted : public ScriptFunction {
-public:
- OnStarted(v8::Isolate* isolate, ReadableStream* stream)
- : ScriptFunction(isolate)
- , m_stream(stream) { }
- virtual ScriptValue call(ScriptValue value) OVERRIDE
- {
- m_stream->onStarted();
- return value;
- }
-
-private:
- Persistent<ReadableStream> m_stream;
-};
-
-ReadableStream::ReadableStream(ScriptState* scriptState, UnderlyingSource* source, ExceptionState* exceptionState)
- : ContextLifecycleObserver(scriptState->executionContext())
- , m_source(source)
+ReadableStream::ReadableStream(ExecutionContext* executionContext, UnderlyingSource* source)
+ : m_source(source)
, m_isStarted(false)
, m_isDraining(false)
, m_isPulling(false)
, m_isSchedulingPull(false)
, m_state(Waiting)
- , m_wait(new WaitPromise(scriptState->executionContext(), this, WaitPromise::Ready))
- , m_closed(new ClosedPromise(scriptState->executionContext(), this, ClosedPromise::Closed))
+ , m_wait(new WaitPromise(executionContext, this, WaitPromise::Ready))
+ , m_closed(new ClosedPromise(executionContext, this, ClosedPromise::Closed))
{
ScriptWrappable::init(this);
-
- ScriptPromise promise = source->startSource(exceptionState);
- // The underlying source calls |this->error| on failure.
- promise.then(adoptPtr(new OnStarted(scriptState->isolate(), this)));
}
ReadableStream::~ReadableStream()
{
}
+String ReadableStream::stateString() const
+{
+ switch (m_state) {
+ case Readable:
+ return "readable";
+ case Waiting:
+ return "waiting";
+ case Closed:
+ return "closed";
+ case Errored:
+ return "errored";
+ }
+ ASSERT(false);
+ return String();
+}
+
bool ReadableStream::enqueuePreliminaryCheck(size_t chunkSize)
{
if (m_state == Errored || m_state == Closed || m_isDraining)
@@ -88,18 +84,18 @@ void ReadableStream::close()
}
}
-void ReadableStream::readPreliminaryCheck(ExceptionState* exceptionState)
+void ReadableStream::readPreliminaryCheck(ExceptionState& exceptionState)
{
if (m_state == Waiting) {
- exceptionState->throwTypeError("read is called while state is waiting");
+ exceptionState.throwTypeError("read is called while state is waiting");
return;
}
if (m_state == Closed) {
- exceptionState->throwTypeError("read is called while state is closed");
+ exceptionState.throwTypeError("read is called while state is closed");
return;
}
if (m_state == Errored) {
- exceptionState->throwDOMException(m_exception->code(), m_exception->message());
+ exceptionState.throwDOMException(m_exception->code(), m_exception->message());
return;
}
}
@@ -174,7 +170,7 @@ void ReadableStream::error(PassRefPtrWillBeRawPtr<DOMException> exception)
}
}
-void ReadableStream::onStarted()
+void ReadableStream::didSourceStart()
{
m_isStarted = true;
if (m_isSchedulingPull)
« no previous file with comments | « Source/core/streams/ReadableStream.h ('k') | Source/core/streams/ReadableStream.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698