| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/BodyStreamBuffer.h" | 5 #include "modules/fetch/BodyStreamBuffer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/V8HiddenValue.h" | 8 #include "bindings/core/v8/V8HiddenValue.h" |
| 9 #include "core/dom/DOMArrayBuffer.h" | 9 #include "core/dom/DOMArrayBuffer.h" |
| 10 #include "core/dom/DOMTypedArray.h" | 10 #include "core/dom/DOMTypedArray.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return nullptr; | 144 return nullptr; |
| 145 } | 145 } |
| 146 | 146 |
| 147 PassOwnPtr<FetchDataConsumerHandle> BodyStreamBuffer::releaseHandle() | 147 PassOwnPtr<FetchDataConsumerHandle> BodyStreamBuffer::releaseHandle() |
| 148 { | 148 { |
| 149 ASSERT(!isStreamLocked()); | 149 ASSERT(!isStreamLocked()); |
| 150 ASSERT(!isStreamDisturbed()); | 150 ASSERT(!isStreamDisturbed()); |
| 151 // We need to call these before calling closeAndLockAndDisturb. | 151 // We need to call these before calling closeAndLockAndDisturb. |
| 152 const bool isClosed = isStreamClosed(); | 152 const bool isClosed = isStreamClosed(); |
| 153 const bool isErrored = isStreamErrored(); | 153 const bool isErrored = isStreamErrored(); |
| 154 OwnPtr<FetchDataConsumerHandle> handle = m_handle.release(); | 154 OwnPtr<FetchDataConsumerHandle> handle = std::move(m_handle); |
| 155 | 155 |
| 156 closeAndLockAndDisturb(); | 156 closeAndLockAndDisturb(); |
| 157 | 157 |
| 158 if (isClosed) { | 158 if (isClosed) { |
| 159 // Note that the stream cannot be "draining", because it doesn't have | 159 // Note that the stream cannot be "draining", because it doesn't have |
| 160 // the internal buffer. | 160 // the internal buffer. |
| 161 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer
Handle()); | 161 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer
Handle()); |
| 162 } | 162 } |
| 163 if (isErrored) | 163 if (isErrored) |
| 164 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD
ataConsumerHandle()); | 164 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD
ataConsumerHandle()); |
| 165 | 165 |
| 166 ASSERT(handle); | 166 ASSERT(handle); |
| 167 return handle.release(); | 167 return handle; |
| 168 } | 168 } |
| 169 | 169 |
| 170 void BodyStreamBuffer::startLoading(FetchDataLoader* loader, FetchDataLoader::Cl
ient* client) | 170 void BodyStreamBuffer::startLoading(FetchDataLoader* loader, FetchDataLoader::Cl
ient* client) |
| 171 { | 171 { |
| 172 ASSERT(!m_loader); | 172 ASSERT(!m_loader); |
| 173 ASSERT(m_scriptState->contextIsValid()); | 173 ASSERT(m_scriptState->contextIsValid()); |
| 174 OwnPtr<FetchDataConsumerHandle> handle = releaseHandle(); | 174 OwnPtr<FetchDataConsumerHandle> handle = releaseHandle(); |
| 175 m_loader = loader; | 175 m_loader = loader; |
| 176 loader->start(handle.get(), new LoaderClient(m_scriptState->getExecutionCont
ext(), this, client)); | 176 loader->start(handle.get(), new LoaderClient(m_scriptState->getExecutionCont
ext(), this, client)); |
| 177 } | 177 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 378 |
| 379 void BodyStreamBuffer::stopLoading() | 379 void BodyStreamBuffer::stopLoading() |
| 380 { | 380 { |
| 381 if (!m_loader) | 381 if (!m_loader) |
| 382 return; | 382 return; |
| 383 m_loader->cancel(); | 383 m_loader->cancel(); |
| 384 m_loader = nullptr; | 384 m_loader = nullptr; |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace blink | 387 } // namespace blink |
| OLD | NEW |