Пример #1
0
void SocketConnectTask::Run() {
  mImpl->UnsetTask();
  if (mCanceled) {
    return;
  }
  mImpl->Connect();
}
Пример #2
0
void SocketAcceptTask::Run() {
  mImpl->UnsetTask();
  if (mCanceled) {
    return;
  }
  mImpl->Accept();
}
Пример #3
0
void SocketDelayedConnectTask::Run()
{
  MOZ_ASSERT(NS_IsMainThread());
  if (!mImpl || mImpl->IsShutdownOnMainThread()) {
    return;
  }
  mImpl->ClearDelayedConnectTask();
  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketConnectTask(mImpl));
}
Пример #4
0
void SocketAcceptTask::Run()
{
  MOZ_ASSERT(!NS_IsMainThread());

  if (mImpl) {
    mImpl->Accept();
  }
}
Пример #5
0
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));
}
Пример #6
0
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();
}
Пример #7
0
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);
}
Пример #8
0
void SocketConnectTask::Run()
{
  MOZ_ASSERT(!NS_IsMainThread());
  mImpl->Connect();
}