Commit e2a39ec5 authored by Doug Arnett's avatar Doug Arnett Committed by Commit Bot

PerFrameTranslate: Posts the OnPageTranslated callback on thread's queue

This is an attempt to avoid a race condition crash with the infobar
going away while the page translated callback occurs.

Bug: 1093320
Change-Id: I47025de0d8c23045e1a964d4cef0c732e903b8b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283657Reviewed-by: default avatarMegan Jablonski <megjablon@chromium.org>
Commit-Queue: Doug Arnett <dougarnett@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785850}
parent f5324e62
...@@ -453,8 +453,13 @@ void PerFrameContentTranslateDriver::OnFrameTranslated( ...@@ -453,8 +453,13 @@ void PerFrameContentTranslateDriver::OnFrameTranslated(
} }
if (--stats_.pending_request_count == 0) { if (--stats_.pending_request_count == 0) {
OnPageTranslated(cancelled, original_lang, translated_lang, // Post the callback on the thread's task runner in case the
stats_.main_frame_error); // info bar is in the process of going away.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&ContentTranslateDriver::OnPageTranslated,
weak_pointer_factory_.GetWeakPtr(), cancelled,
original_lang, translated_lang,
stats_.main_frame_error));
stats_.Report(); stats_.Report();
stats_.Clear(); stats_.Clear();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment