- Fix use-after-return in ReleaseAndWaitForDestructor if it times out

while running unit tests.
- Increase PluginTest PDF load timeout.
This commit is contained in:
Marshall Greenblatt
2015-10-14 09:42:42 -07:00
parent 70ed95bcca
commit 16f8a66040
2 changed files with 9 additions and 0 deletions

View File

@@ -299,10 +299,15 @@ template<typename T>
void ReleaseAndWaitForDestructor(CefRefPtr<T>& handler, int delay_ms = 2000) {
base::WaitableEvent event(true, false);
handler->SetDestroyEvent(&event);
T* _handler_ptr = handler.get();
handler = NULL;
bool handler_destructed =
event.TimedWait(base::TimeDelta::FromMilliseconds(delay_ms));
EXPECT_TRUE(handler_destructed);
if (!handler_destructed) {
// |event| is a stack variable so clear the reference before returning.
_handler_ptr->SetDestroyEvent(NULL);
}
}
// Post a task to the specified thread and wait for the task to execute as