Avoid binding ref counted objects in ScreenObserverDelegate constructor
This CL adds a static constructor to ScreenObserverDelegate to avoid a racy ref count operation. As ScreenObserverDelegate is a ref counted class, base::Bind implicitly increments the reference count, and releases it on the callback instance destruction. If PostTask in the SOD ctor fails, or the posted task ran soon before the ctor has completed, the ScreenObserverDelegate instance may be destroyed immediately, and `new ScreenObserverDelegate` may returns a stale pointer. Bug: 866456 Change-Id: I7c64915529786b2f0738731c323aaf2f293dbc20 Reviewed-on: https://chromium-review.googlesource.com/1147896Reviewed-by:Christian Fremerey <chfremer@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#577624}
Showing
Please register or sign in to comment