• Jeffrey Kardatzke's avatar
    Fix feedback uploader crash with raw pointer misuse · be95a711
    Jeffrey Kardatzke authored
    This fixes a bug in the uploader where it would post a task with a
    callback that had a raw pointer, and if it was during shutdown then the
    referenced object could be destructed before the call on said pointer
    was invoked.  The simple part of the change is using a WeakPtr in that
    location instead of a raw pointer, so the callback will be skipped.
    However, the way the code worked was that it would read the pre-existing
    feedback report from disk to a string, then it would pass that into the
    callback which asynchronously generated a new feedback report in a new
    disk location and then it would delete the old feedback report file.
    However, if that callback is suppressed (which it would be in the case
    the new WeakPtr becomes invalidated) then we would end up deleting that
    feedback report from disk without sending it. So this code also changes
    things to not recreate the report on disk but instead reuses that
    existing file for the feedback report.
    
    Bug: 994846
    Test: components_unittests pass and manually verified report upload
    Change-Id: Ib64ce1abbfea23e94e45387fa5a296817bf19a30
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766766
    Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
    Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#691752}
    be95a711
feedback_profile_observer.cc 2.66 KB