Fix server thread assertion on CEF shutdown (see issue #2969)
The server thread was not guaranteed to be released in the correct scope on CEF shutdown. This resulted in occasional thread_restrictions assertions on ceftests shutdown after running the URLRequestTest suite with the Chrome runtime enabled.
This commit is contained in:
parent
09a9d9b54c
commit
c565d9b1e6
|
@ -595,7 +595,7 @@ void CefServerImpl::ShutdownOnUIThread() {
|
|||
if (thread_) {
|
||||
// Stop the handler thread as a background task so the UI thread isn't
|
||||
// blocked.
|
||||
CEF_POST_BACKGROUND_TASK(BindOnce(
|
||||
auto task = base::BindOnce(
|
||||
[](std::unique_ptr<base::Thread> thread) {
|
||||
// Calling PlatformThread::Join() on the UI thread is otherwise
|
||||
// disallowed.
|
||||
|
@ -603,7 +603,15 @@ void CefServerImpl::ShutdownOnUIThread() {
|
|||
scoped_allow_sync_primitives;
|
||||
thread.reset();
|
||||
},
|
||||
std::move(thread_)));
|
||||
std::move(thread_));
|
||||
|
||||
// Make sure the task is executed on shutdown. Otherwise, |thread| might
|
||||
// be released outside of the correct scope.
|
||||
base::PostTask(
|
||||
FROM_HERE,
|
||||
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()},
|
||||
std::move(task));
|
||||
|
||||
// Release the reference that was added in StartupOnUIThread().
|
||||
Release();
|
||||
|
|
Loading…
Reference in New Issue