void XMLHttpRequest::abort() { WTF_LOG(Network, "XMLHttpRequest %p abort()", this); // internalAbort() calls dropProtection(), which may release the last reference. RefPtr<XMLHttpRequest> protect(this); bool sendFlag = m_loader; // Response is cleared next, save needed progress event data. long long expectedLength = m_response.expectedContentLength(); long long receivedLength = m_receivedLength; if (!internalAbort()) return; clearResponse(); // Clear headers as required by the spec m_requestHeaders.clear(); if (!((m_state <= OPENED && !sendFlag) || m_state == DONE)) { ASSERT(!m_loader); handleRequestError(0, EventTypeNames::abort, receivedLength, expectedLength); } m_state = UNSENT; }
// Called by libuv when the stat call for size completes. static void fileSizeCallback(uv_fs_t* request) { if (handleRequestError(request)) return; double size = (double)request->statbuf.st_size; schedulerResume(freeRequest(request), true); wrenSetSlotDouble(getVM(), 2, size); schedulerFinishResume(); }
static void fileOpenCallback(uv_fs_t* request) { if (handleRequestError(request)) return; double fd = (double)request->result; schedulerResume(freeRequest(request), true); wrenSetSlotDouble(getVM(), 2, fd); schedulerFinishResume(); }
void XMLHttpRequest::handleDidCancel() { WTF_LOG(Network, "XMLHttpRequest %p handleDidCancel()", this); // Response is cleared next, save needed progress event data. long long expectedLength = m_response.expectedContentLength(); long long receivedLength = m_receivedLength; handleDidFailGeneric(); handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expectedLength); }
// Called by libuv when the stat call completes. static void statPathCallback(uv_fs_t* request) { if (handleRequestError(request)) return; WrenVM* vm = getVM(); wrenEnsureSlots(vm, 4); wrenSetSlotNewList(vm, 2); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_dev); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_ino); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_mode); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_nlink); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_uid); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_gid); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_rdev); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_size); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_blksize); wrenInsertInList(vm, 2, -1, 3); wrenSetSlotDouble(vm, 3, (double)request->statbuf.st_blocks); wrenInsertInList(vm, 2, -1, 3); // TODO: Include access, modification, and change times once we figure out // how we want to represent it. // time_t st_atime; /* time of last access */ // time_t st_mtime; /* time of last modification */ // time_t st_ctime; /* time of last status change */ schedulerResume(freeRequest(request), true); schedulerFinishResume(); }
static void fileReadBytesCallback(uv_fs_t* request) { if (handleRequestError(request)) return; FileRequestData* data = (FileRequestData*)request->data; uv_buf_t buffer = data->buffer; size_t count = request->result; // TODO: Having to copy the bytes here is a drag. It would be good if Wren's // embedding API supported a way to *give* it bytes that were previously // allocated using Wren's own allocator. schedulerResume(freeRequest(request), true); wrenSetSlotBytes(getVM(), 2, buffer.base, count); schedulerFinishResume(); // TODO: Likewise, freeing this after we resume is lame. free(buffer.base); }
static void directoryListCallback(uv_fs_t* request) { if (handleRequestError(request)) return; uv_dirent_t entry; WrenVM* vm = getVM(); wrenEnsureSlots(vm, 3); wrenSetSlotNewList(vm, 2); while (uv_fs_scandir_next(request, &entry) != UV_EOF) { wrenSetSlotString(vm, 1, entry.name); wrenInsertInList(vm, 2, -1, 1); } schedulerResume(freeRequest(request), true); schedulerFinishResume(); }
static void fileCloseCallback(uv_fs_t* request) { if (handleRequestError(request)) return; schedulerResume(freeRequest(request), false); }