Avoid touching SafeBrowsingClientImpl's ref count before it's fully constructed
SafeBrowsingContextImpl is ref counted, and its first reference used to be made in its constructor through base::Bind. The reference is passed to the IO thread, and released when the task is destroyed. However, if PostTask failed or the posted task ran soon even before the constructor has finished, the SafeBrowsingContextImpl instance may be destroyed before the construction has completed. Though the SafeBrowsingContextImpl case is safe, even if `new SafeBrowsingContextImpl` returns a stale pointer, this hits an sanity check that is being added to base::Bind. This CL moves the PostTask() out of the constructor, and holds an reference to the instance while base::Bind is called to avoid the check failure. Bug: 866456 Change-Id: Iee58de1e4cd807ff858985f9831e48f4a903bbd4 Reviewed-on: https://chromium-review.googlesource.com/1156332Reviewed-by:Reilly Grant <reillyg@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#579433}
Showing
Please register or sign in to comment