void BlobResourceHandle::doStart() { // Do not continue if the request is aborted or an error occurs. if (m_aborted || m_errorCode) return; // If the blob data is not found, fail now. if (!m_blobData) { m_errorCode = notFoundError; notifyResponse(); return; } // Parse the "Range" header we care about. String range = firstRequest().httpHeaderField("Range"); if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) { m_errorCode = rangeError; notifyResponse(); return; } if (m_async) getSizeForNext(); else { for (size_t i = 0; i < m_blobData->items().size() && !m_aborted && !m_errorCode; ++i) getSizeForNext(); notifyResponse(); } }
void NetworkDataTaskBlob::didGetSize(long long size) { ASSERT(isMainThread()); if (m_state == State::Canceling || m_state == State::Completed || (!m_client && !isDownload())) { clearStream(); return; } // If the size is -1, it means the file has been moved or changed. Fail now. if (size == -1) { didFail(Error::NotFoundError); return; } // The size passed back is the size of the whole file. If the underlying item is a sliced file, we need to use the slice length. const BlobDataItem& item = m_blobData->items().at(m_sizeItemCount); size = item.length(); // Cache the size. m_itemLengthList.append(size); // Count the size. m_totalSize += size; m_totalRemainingSize += size; m_sizeItemCount++; // Continue with the next item. getSizeForNext(); }
void BlobResourceHandle::didGetSize(long long size) { // Do not continue if the request is aborted or an error occurs. if (m_aborted || m_errorCode) return; // If the size is -1, it means the file has been moved or changed. Fail now. if (size == -1) { m_errorCode = notFoundError; notifyResponse(); return; } // The size passed back is the size of the whole file. If the underlying item is a sliced file, we need to use the slice length. const BlobDataItem& item = m_blobData->items().at(m_sizeItemCount); if (item.type == BlobDataItem::File && item.length != BlobDataItem::toEndOfFile) size = item.length; // Cache the size. m_itemLengthList.append(size); // Count the size. m_totalRemainingSize += size; m_sizeItemCount++; // Continue with the next item. getSizeForNext(); }
void BlobResourceHandle::doStart() { ASSERT(isMainThread()); // Do not continue if the request is aborted or an error occurs. if (m_aborted || m_errorCode) return; if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) { notifyFail(methodNotAllowed); return; } // If the blob data is not found, fail now. if (!m_blobData) { m_errorCode = notFoundError; notifyResponse(); return; } // Parse the "Range" header we care about. String range = firstRequest().httpHeaderField(HTTPHeaderName::Range); if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) { m_errorCode = rangeError; notifyResponse(); return; } if (m_async) getSizeForNext(); else { Ref<BlobResourceHandle> protectedThis(*this); // getSizeForNext calls the client for (size_t i = 0; i < m_blobData->items().size() && !m_aborted && !m_errorCode; ++i) getSizeForNext(); notifyResponse(); } }
void NetworkDataTaskBlob::resume() { ASSERT(m_state != State::Running); if (m_state == State::Canceling || m_state == State::Completed) return; m_state = State::Running; if (m_scheduledFailureType != NoFailure) { ASSERT(m_failureTimer.isActive()); return; } RunLoop::main().dispatch([this, protectedThis = makeRef(*this)] { if (m_state == State::Canceling || m_state == State::Completed || !m_client) { clearStream(); return; } if (!equalLettersIgnoringASCIICase(m_firstRequest.httpMethod(), "get")) { didFail(Error::MethodNotAllowed); return; } // If the blob data is not found, fail now. if (!m_blobData) { didFail(Error::NotFoundError); return; } // Parse the "Range" header we care about. String range = m_firstRequest.httpHeaderField(HTTPHeaderName::Range); if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) { didReceiveResponse(Error::RangeError); return; } getSizeForNext(); }); }