nsresult GMPVideoDecoderParent::Reset() { LOGD(("GMPVideoDecoderParent[%p]::Reset()", this)); if (!mIsOpen) { NS_WARNING("Trying to use an dead GMP video decoder"); return NS_ERROR_FAILURE; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); if (!SendReset()) { return NS_ERROR_FAILURE; } mIsAwaitingResetComplete = true; RefPtr<GMPVideoDecoderParent> self(this); nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([self]() -> void { LOGD(("GMPVideoDecoderParent[%p]::ResetCompleteTimeout() timed out waiting for ResetComplete", self.get())); self->mResetCompleteTimeout = nullptr; LogToBrowserConsole(NS_LITERAL_STRING("GMPVideoDecoderParent timed out waiting for ResetComplete()")); }); CancelResetCompleteTimeout(); mResetCompleteTimeout = SimpleTimer::Create(task, 5000, mPlugin->GMPThread()); // Async IPC, we don't have access to a return value. return NS_OK; }
mozilla::ipc::IPCResult GMPVideoDecoderParent::RecvDrainComplete() { LOGD(("GMPVideoDecoderParent[%p]::RecvDrainComplete() frameCount=%d", this, mFrameCount)); nsAutoString msg; msg.AppendLiteral("GMPVideoDecoderParent::RecvDrainComplete() outstanding frames="); msg.AppendInt(mFrameCount); LogToBrowserConsole(msg); if (!mCallback) { // We anticipate shutting down in the middle of a drain in the // `UnblockResetAndDrain` method, which is called when we shutdown, so // everything is sunny. return IPC_OK(); } if (!mIsAwaitingDrainComplete) { return IPC_OK(); } mIsAwaitingDrainComplete = false; // Ignore any return code. It is OK for this to fail without killing the process. mCallback->DrainComplete(); return IPC_OK(); }
void DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason) { nsPrintfCString msg("%s promise rejected 0x%x '%s'", mName.get(), aArg, PromiseFlatCString(aReason).get()); EME_LOG(msg.get()); MaybeReportTelemetry(Failed); LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg)); nsRefPtr<DOMException> exception = DOMException::Create(aArg, aReason); Promise::MaybeRejectBrokenly(exception); }
void LogToBrowserConsole(const nsAString& aMsg) { if (!NS_IsMainThread()) { nsString msg(aMsg); nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction( "LogToBrowserConsole", [msg]() { LogToBrowserConsole(msg); }); SystemGroup::Dispatch(TaskCategory::Other, task.forget()); return; } nsCOMPtr<nsIConsoleService> console( do_GetService("@mozilla.org/consoleservice;1")); if (!console) { NS_WARNING("Failed to log message to console."); return; } nsAutoString msg(aMsg); console->LogStringMessage(msg.get()); }
void LogToBrowserConsole(const nsAString& aMsg) { if (!NS_IsMainThread()) { nsAutoString msg(aMsg); nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([msg]() { LogToBrowserConsole(msg); }); NS_DispatchToMainThread(task.forget(), NS_DISPATCH_NORMAL); return; } nsCOMPtr<nsIConsoleService> console( do_GetService("@mozilla.org/consoleservice;1")); if (!console) { NS_WARNING("Failed to log message to console."); return; } nsAutoString msg(aMsg); console->LogStringMessage(msg.get()); }
bool GMPVideoDecoderParent::RecvDrainComplete() { LOGD(("GMPVideoDecoderParent[%p]::RecvDrainComplete() frameCount=%d", this, mFrameCount)); nsAutoString msg; msg.AppendLiteral("GMPVideoDecoderParent::RecvDrainComplete() outstanding frames="); msg.AppendInt(mFrameCount); LogToBrowserConsole(msg); if (!mCallback) { return false; } if (!mIsAwaitingDrainComplete) { return true; } mIsAwaitingDrainComplete = false; // Ignore any return code. It is OK for this to fail without killing the process. mCallback->DrainComplete(); return true; }