ceftests: Don't use base::Bind in object constructor (see issue #3140)

Fixes the following error:
[FATAL:cef_bind_internal.h(868)] Check failed: receiver->HasAtLeastOneRef().
base::Bind{Once,Repeating}() refuses to create the first reference to ref-counted
objects. That typically happens around PostTask() in their constructor, and such
objects can be destroyed before `new` returns if the task resolves fast enough.
This commit is contained in:
Marshall Greenblatt
2021-06-18 09:41:17 -07:00
parent 6a1c641f75
commit 3545e20b01
2 changed files with 9 additions and 5 deletions

View File

@@ -495,11 +495,7 @@ class HttpTestRunner : public base::RefCountedThreadSafe<HttpTestRunner> {
HttpTestRunner(bool parallel_requests)
: parallel_requests_(parallel_requests),
initialized_(false),
next_request_id_(0) {
handler_ = new TestServerHandler(
base::Bind(&HttpTestRunner::OnServerStarted, this),
base::Bind(&HttpTestRunner::OnServerDestroyed, this));
}
next_request_id_(0) {}
virtual ~HttpTestRunner() {
if (destroy_event_)
@@ -516,6 +512,10 @@ class HttpTestRunner : public base::RefCountedThreadSafe<HttpTestRunner> {
void ExecuteTest() {
EXPECT_FALSE(CefCurrentlyOn(TID_UI));
handler_ = new TestServerHandler(
base::Bind(&HttpTestRunner::OnServerStarted, this),
base::Bind(&HttpTestRunner::OnServerDestroyed, this));
run_event_ = CefWaitableEvent::CreateWaitableEvent(false, false);
CefPostTask(TID_UI, base::Bind(&HttpTestRunner::RunTest, this));