| 226 | } |
| 227 | |
| 228 | void DownloaderEmscripten::onError(emscripten_fetch_t *fetch) |
| 229 | { |
| 230 | AXLOGD("DownloaderEmscripten::onLoad(fetch: {})", fmt::ptr(fetch)); |
| 231 | DownloaderEmscripten* downloader = reinterpret_cast<DownloaderEmscripten*>(fetch->userData); |
| 232 | auto iter = downloader->_taskMap.find(fetch); |
| 233 | if (downloader->_taskMap.end() == iter) |
| 234 | { |
| 235 | emscripten_fetch_close(fetch); |
| 236 | AXLOGD("DownloaderEmscripten::onLoad can't find task with fetch: {}", fmt::ptr(fetch)); |
| 237 | return; |
| 238 | } |
| 239 | auto context = iter->second; |
| 240 | updateTaskProgressInfo(*context->task, fetch); |
| 241 | vector<unsigned char> buf; |
| 242 | downloader->_taskMap.erase(iter); |
| 243 | downloader->onTaskFinish(*context->task, |
| 244 | DownloadTask::ERROR_IMPL_INTERNAL, |
| 245 | fetch->status, |
| 246 | fetch->statusText, |
| 247 | buf |
| 248 | ); |
| 249 | |
| 250 | emscripten_fetch_close(fetch); |
| 251 | context->fetch = fetch = NULL; |
| 252 | context->task.reset(); |
| 253 | } |
| 254 | |
| 255 | void DownloaderEmscripten::updateTaskProgressInfo(DownloadTask& task, emscripten_fetch_t *fetch) |
| 256 | { |
no test coverage detected