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 #include "config.h" | 5 #include "config.h" |
6 #include "core/streams/ReadableStreamReader.h" | 6 #include "core/streams/ReadableStreamReader.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/V8IteratorResultValue.h" | 10 #include "bindings/core/v8/V8IteratorResultValue.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 { | 45 { |
46 return cancel(scriptState, ScriptValue(scriptState, v8::Undefined(scriptStat
e->isolate()))); | 46 return cancel(scriptState, ScriptValue(scriptState, v8::Undefined(scriptStat
e->isolate()))); |
47 } | 47 } |
48 | 48 |
49 ScriptPromise ReadableStreamReader::cancel(ScriptState* scriptState, ScriptValue
reason) | 49 ScriptPromise ReadableStreamReader::cancel(ScriptState* scriptState, ScriptValue
reason) |
50 { | 50 { |
51 if (isActive()) | 51 if (isActive()) |
52 return m_stream->cancelInternal(scriptState, reason); | 52 return m_stream->cancelInternal(scriptState, reason); |
53 | 53 |
54 // A method should return a different promise on each call. | 54 // A method should return a different promise on each call. |
55 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 55 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
56 ScriptPromise promise = resolver->promise(); | 56 ScriptPromise promise = resolver->promise(); |
57 resolver->resolve(closed(scriptState).v8Value()); | 57 resolver->resolve(closed(scriptState).v8Value()); |
58 return promise; | 58 return promise; |
59 } | 59 } |
60 | 60 |
61 ScriptPromise ReadableStreamReader::read(ScriptState* scriptState) | 61 ScriptPromise ReadableStreamReader::read(ScriptState* scriptState) |
62 { | 62 { |
63 if (!isActive()) { | 63 if (!isActive()) { |
64 ASSERT(m_stateAfterRelease == ReadableStream::Closed || m_stateAfterRele
ase == ReadableStream::Errored); | 64 ASSERT(m_stateAfterRelease == ReadableStream::Closed || m_stateAfterRele
ase == ReadableStream::Errored); |
65 if (m_stateAfterRelease == ReadableStream::Closed) { | 65 if (m_stateAfterRelease == ReadableStream::Closed) { |
66 // {value: undefined, done: true} | 66 // {value: undefined, done: true} |
67 return ScriptPromise::cast(scriptState, v8IteratorResultDone(scriptS
tate)); | 67 return ScriptPromise::cast(scriptState, v8IteratorResultDone(scriptS
tate)); |
68 } | 68 } |
69 // A method should return a different promise on each call. | 69 // A method should return a different promise on each call. |
70 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolv
er::create(scriptState); | 70 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptSt
ate); |
71 ScriptPromise promise = resolver->promise(); | 71 ScriptPromise promise = resolver->promise(); |
72 resolver->resolve(closed(scriptState).v8Value()); | 72 resolver->resolve(closed(scriptState).v8Value()); |
73 return promise; | 73 return promise; |
74 } | 74 } |
75 | 75 |
76 return m_stream->read(scriptState); | 76 return m_stream->read(scriptState); |
77 } | 77 } |
78 | 78 |
79 void ReadableStreamReader::releaseLock(ExceptionState& es) | 79 void ReadableStreamReader::releaseLock(ExceptionState& es) |
80 { | 80 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 DEFINE_TRACE(ReadableStreamReader) | 130 DEFINE_TRACE(ReadableStreamReader) |
131 { | 131 { |
132 visitor->trace(m_stream); | 132 visitor->trace(m_stream); |
133 visitor->trace(m_closed); | 133 visitor->trace(m_closed); |
134 ActiveDOMObject::trace(visitor); | 134 ActiveDOMObject::trace(visitor); |
135 } | 135 } |
136 | 136 |
137 } // namespace blink | 137 } // namespace blink |
OLD | NEW |