Index: ui/ozone/public/ozone_gpu_test_helper.cc |
diff --git a/ui/ozone/public/ozone_gpu_test_helper.cc b/ui/ozone/public/ozone_gpu_test_helper.cc |
index 1fa265c6b35fd822c457ad43a5ee9dc4687b25f9..71a2fab454967a02a23be911c287ee735ce85718 100644 |
--- a/ui/ozone/public/ozone_gpu_test_helper.cc |
+++ b/ui/ozone/public/ozone_gpu_test_helper.cc |
@@ -4,6 +4,7 @@ |
#include "ui/ozone/public/ozone_gpu_test_helper.h" |
+#include "base/synchronization/waitable_event.h" |
#include "base/thread_task_runner_handle.h" |
#include "ipc/ipc_listener.h" |
#include "ipc/ipc_message.h" |
@@ -66,7 +67,13 @@ class FakeGpuProcessHost { |
FakeGpuProcessHost( |
const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) |
: gpu_task_runner_(gpu_task_runner), weak_factory_(this) {} |
- ~FakeGpuProcessHost() {} |
+ ~FakeGpuProcessHost() { |
+ base::WaitableEvent done(false, false); |
+ gpu_task_runner_->PostTask(FROM_HERE, |
+ base::Bind(&FakeGpuProcessHost::Destroy, |
+ weak_factory_.GetWeakPtr(), &done)); |
+ done.Wait(); |
+ } |
void Init() { |
base::Callback<void(IPC::Message*)> sender = |
@@ -79,6 +86,12 @@ class FakeGpuProcessHost { |
} |
private: |
+ void Destroy(base::WaitableEvent* done) { |
+ DCHECK(gpu_task_runner_->BelongsToCurrentThread()); |
+ this->weak_factory_.InvalidateWeakPtrs(); |
+ done->Signal(); |
+ } |
+ |
void DispatchToGpuPlatformSupportTask(IPC::Message* msg) { |
ui::OzonePlatform::GetInstance() |
->GetGpuPlatformSupport() |