[Cronet] Extend the lifetime of |RequestFinishedInfo|.

Cronet users have expressed a desire to correlate information from the
|RequestFinishedInfoListener| and the |UrlRequestCallback|.

With the current |RequestFinishedInfo| ownership, this is very awkward
to do -- the |RequestFinishedInfo| only lives for the duration of
|RequestFinishedInfoListener.OnRequestFinished()|, which may be run
before or after the |UrlRequestCallback| methods |OnSucceeded()|,
|OnFailed()|, and |OnCanceled()|, depending on the
|RequestFinishedListener| executor and ordering of thread execution.

The |UrlResponseInfo| and |Error| objects are already owned by the
|UrlRequest|, so making the |RequestFinishedInfo| also owned by the
|UrlRequest| makes sense.

However, since the app is allowed to destroy the |UrlRequest| after the
|OnSucceeded()|, |OnFailed()|, and |OnCanceled()| methods, which may be
run before |OnRequestFinished()|, we should also ensure that the
|RequestFinishedInfo| is valid for the duration of each
|RequestFinishedInfo| call so that app developers can avoid debugging
use-after-free races.

We can accomplish both by sharing ownership between the |UrlRequest| and
the |RequestFinishedInfoListener| runner code.

Bug: 879208
Change-Id: I88cf28b59e162b2550ed7a1f8f521bcf78cfc367
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1584890
Reviewed-by: Misha Efimov <mef@chromium.org>
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Commit-Queue: Caleb Raitto <caraitto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654314}
1 file changed