Bug 1910452: Part 5 - Release content analysis cache request on main thread r=dlp-reviewers,gstoll

Without this, we assert when releasing the request on the background thread when
we hit an error, such as the DLP agent not running.

Differential Revision: https://phabricator.services.mozilla.com/D220617
This commit is contained in:
David Parks 2024-09-11 23:02:25 +00:00
parent 22d811e7da
commit 098eeb9430

View File

@ -1315,6 +1315,11 @@ void ContentAnalysis::DoAnalyzeRequest(
nsCOMPtr<nsIContentAnalysisRequest> aRequestToCache,
const std::shared_ptr<content_analysis::sdk::Client>& aClient) {
MOZ_ASSERT(!NS_IsMainThread());
auto threadsafeErrorHandler = MakeScopeExit([&]() {
// Make sure the cache request is destroyed on the main thread.
NS_DispatchToMainThread(NS_NewCancelableRunnableFunction(
"CARequestErrorCleanup", [aRTC = std::move(aRequestToCache)]() {}));
});
RefPtr<ContentAnalysis> owner =
ContentAnalysis::GetContentAnalysisFromService();
if (!owner) {
@ -1391,6 +1396,7 @@ void ContentAnalysis::DoAnalyzeRequest(
}
owner->IssueResponse(response);
}));
threadsafeErrorHandler.release();
}
void ContentAnalysis::SendWarnResponse(