NS_IMETHODIMP nsSocketTransportService::IsOnCurrentThread(bool *result) { nsCOMPtr<nsIThread> thread = GetThreadSafely(); NS_ENSURE_TRUE(thread, NS_ERROR_NOT_INITIALIZED); return thread->IsOnCurrentThread(result); }
NS_IMETHODIMP nsSocketTransportService::Dispatch(nsIRunnable *event, PRUint32 flags) { LOG(("STS dispatch [%p]\n", event)); nsCOMPtr<nsIThread> thread = GetThreadSafely(); NS_ENSURE_TRUE(thread, NS_ERROR_NOT_INITIALIZED); nsresult rv = thread->Dispatch(event, flags); if (rv == NS_ERROR_UNEXPECTED) { // Thread is no longer accepting events. We must have just shut it // down on the main thread. Pretend we never saw it. rv = NS_ERROR_NOT_INITIALIZED; } return rv; }