Avoid touching ScopedFileOpener::Runner's ref count before it's fully constructed
ScopedFileOpener::Runner is a ref counted object, and its first reference used to be made in its constructor through base::Bind. The reference is passed to ProvidedFileSystem::OpenFile, and released when the callback object is destroyed. However, if OpenFile failed, the reference is released before the Runner construction has done. Then `new Runner` returns a stale pointer, instead of newly created object. This CL adds a static consntructor and moves the implicit ref count manipulation out of the real constructor. Bug: 866456 Change-Id: I92d68b3383d8fecd900be080cc23551cddb5f12b Reviewed-on: https://chromium-review.googlesource.com/1156325Reviewed-by:Tatsuhisa Yamaguchi <yamaguchi@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#579359}
Showing
Please register or sign in to comment