void SocketConnectTask::Run() { mImpl->UnsetTask(); if (mCanceled) { return; } mImpl->Connect(); }
void SocketAcceptTask::Run() { mImpl->UnsetTask(); if (mCanceled) { return; } mImpl->Accept(); }
void SocketDelayedConnectTask::Run() { MOZ_ASSERT(NS_IsMainThread()); if (!mImpl || mImpl->IsShutdownOnMainThread()) { return; } mImpl->ClearDelayedConnectTask(); XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketConnectTask(mImpl)); }
void SocketAcceptTask::Run() { MOZ_ASSERT(!NS_IsMainThread()); if (mImpl) { mImpl->Accept(); } }
void UnixSocketConsumer::CloseSocket() { if (!mImpl) { return; } UnixSocketImpl* impl = mImpl; mImpl = nullptr; impl->mConsumer.forget(); impl->StopTask(); // To make sure the owner doesn't die on the IOThread, remove pointer here // Line it up to be destructed on the IO Thread // Kill our pointer to it XRE_GetIOMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(DestroyImpl, impl)); }
void UnixSocketConsumer::CloseSocket() { // Needed due to refcount change MOZ_ASSERT(NS_IsMainThread()); if (!mImpl) { return; } UnixSocketImpl* impl = mImpl; // To make sure the owner doesn't die on the IOThread, remove pointer here mImpl = nullptr; // Line it up to be destructed on the IO Thread impl->mConsumer.forget(); impl->StopTask(); XRE_GetIOMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(DestroyImpl, impl)); NotifyDisconnect(); }
void ShutdownSocketTask::Run() { MOZ_ASSERT(!NS_IsMainThread()); // At this point, there should be no new events on the IO thread after this // one with the possible exception of a SocketAcceptTask that // ShutdownOnIOThread will cancel for us. We are now fully shut down, so we // can send a message to the main thread that will delete mImpl safely knowing // that no more tasks reference it. mImpl->ShutdownOnIOThread(); nsRefPtr<nsIRunnable> t(new DeleteInstanceRunnable<UnixSocketImpl>(mImpl)); nsresult rv = NS_DispatchToMainThread(t); NS_ENSURE_SUCCESS_VOID(rv); }
void SocketConnectTask::Run() { MOZ_ASSERT(!NS_IsMainThread()); mImpl->Connect(); }