| 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 "modules/fetch/ReadableStreamDataConsumerHandle.h" | 5 #include "modules/fetch/ReadableStreamDataConsumerHandle.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (!m_isReading) { | 152 if (!m_isReading) { |
| 153 m_isReading = true; | 153 m_isReading = true; |
| 154 ScriptState::Scope scope(m_scriptState.get()); | 154 ScriptState::Scope scope(m_scriptState.get()); |
| 155 ScriptValue reader(m_scriptState.get(), m_reader.newLocal(m_scriptSt
ate->isolate())); | 155 ScriptValue reader(m_scriptState.get(), m_reader.newLocal(m_scriptSt
ate->isolate())); |
| 156 if (reader.isEmpty()) { | 156 if (reader.isEmpty()) { |
| 157 // The reader was collected. | 157 // The reader was collected. |
| 158 m_hasError = true; | 158 m_hasError = true; |
| 159 m_isReading = false; | 159 m_isReading = false; |
| 160 return WebDataConsumerHandle::UnexpectedError; | 160 return WebDataConsumerHandle::UnexpectedError; |
| 161 } | 161 } |
| 162 ReadableStreamOperations::read(m_scriptState.get(), reader).then( | 162 ReadableStreamOperations::defaultReaderRead( |
| 163 OnFulfilled::createFunction(m_scriptState.get(), this), | 163 m_scriptState.get(), reader).then( |
| 164 OnRejected::createFunction(m_scriptState.get(), this)); | 164 OnFulfilled::createFunction(m_scriptState.get(), this), |
| 165 OnRejected::createFunction(m_scriptState.get(), this)); |
| 165 } | 166 } |
| 166 return WebDataConsumerHandle::ShouldWait; | 167 return WebDataConsumerHandle::ShouldWait; |
| 167 } | 168 } |
| 168 | 169 |
| 169 Result endRead(size_t readSize) | 170 Result endRead(size_t readSize) |
| 170 { | 171 { |
| 171 ASSERT(m_pendingBuffer); | 172 ASSERT(m_pendingBuffer); |
| 172 ASSERT(m_pendingOffset + readSize <= m_pendingBuffer->length()); | 173 ASSERT(m_pendingOffset + readSize <= m_pendingBuffer->length()); |
| 173 m_pendingOffset += readSize; | 174 m_pendingOffset += readSize; |
| 174 if (m_pendingOffset == m_pendingBuffer->length()) { | 175 if (m_pendingOffset == m_pendingBuffer->length()) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 { | 271 { |
| 271 } | 272 } |
| 272 ReadableStreamDataConsumerHandle::~ReadableStreamDataConsumerHandle() = default; | 273 ReadableStreamDataConsumerHandle::~ReadableStreamDataConsumerHandle() = default; |
| 273 | 274 |
| 274 FetchDataConsumerHandle::Reader* ReadableStreamDataConsumerHandle::obtainReaderI
nternal(Client* client) | 275 FetchDataConsumerHandle::Reader* ReadableStreamDataConsumerHandle::obtainReaderI
nternal(Client* client) |
| 275 { | 276 { |
| 276 return new ReadingContext::ReaderImpl(m_readingContext, client); | 277 return new ReadingContext::ReaderImpl(m_readingContext, client); |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace blink | 280 } // namespace blink |
| 280 | |
| OLD | NEW |