Description[Background Fetch] Cleanup/fix thread safety
Document, cleanup, and in several cases fix thread safety of Background
Fetch code. In particular:
- BackgroundFetchContext becomes DeleteOnIOThread to simplify shutdown.
- BackgroundFetchRequestInfo becomes RefCountedDeleteOnSequence to fix
it being deleted on a different thread to the one it is accessed on.
- BackgroundFetchRequestInfo::SetDownloadStatePopulated and
SetResponseDataPopulated are split out and required to be called on
the IO thread, to fix BackgroundFetchJobController writing these
fields on the UI thread potentially in parallel with them being read
on the IO thread.
- Uses WeakPtrs when binding callbacks to BackgroundFetchContext, since
those callbacks are sometimes stored by objects that are themselves
owned by the context, and so there used to be reference cycles when
those callbacks held strong references to the context; this used to
cause us to leak the context sometimes.
- Adds comments for clarity in tests which use StoragePartition to get
a URLRequestContext, but then construct their own
BackgroundFetchContext etc instead of using the one owned by the
StoragePartition.
BUG=none
Review-Url: https://codereview.chromium.org/2973233002
Cr-Commit-Position: refs/heads/master@{#485639}
Committed: https://chromium.googlesource.com/chromium/src/+/57400c18f9da4828e4b59c33db37cd2b2f52e36f
Patch Set 1 #
Total comments: 12
Patch Set 2 : Address review comments #Patch Set 3 : Use WeakPtrs when binding BGFContext to avoid reference cycle; also comments for StoragePartition's… #Patch Set 4 : Remove n.b. from comments #Dependent Patchsets: Messages
Total messages: 30 (19 generated)
|