Avoid races in taking networking assertions for downloads by having both Networking...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 21:37:07 +0000 (21:37 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 21:37:07 +0000 (21:37 +0000)
commitd99eeb4c859fe20ebd7fceedce69c26911757ebb
treeb518390f88f2d48301c86b5b4ac394b0f1017cc9
parent5c91054457b41b2ea4ee46f3d10838774a3fec1d
Avoid races in taking networking assertions for downloads by having both Networking and UIProcess do it.
<rdar://problem/50564630> and https://bugs.webkit.org/show_bug.cgi?id=197995

Reviewed by Chris Dumez.

There's a fairly indeterminant time gap between when the UIProcess decides a load becomes a download
and when the NetworkProcess Download object is created, and therefore the download assertion to be taken.

The time gap can be long enough for the Networking process to suspend before the download actually starts.

There's the reverse race when the UIProcess tells a download to stop, as well.

By having both the UIProcess and NetworkProcess take an assertion on behalf of the NetworkProcess we
avoid the race.

* NetworkProcess/Downloads/DownloadMap.cpp:
(WebKit::DownloadMap::add):
(WebKit::DownloadMap::remove):

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::convertToDownload):

* UIProcess/Downloads/DownloadProxyMap.cpp:
(WebKit::DownloadProxyMap::createDownloadProxy):
(WebKit::DownloadProxyMap::downloadFinished):
(WebKit::DownloadProxyMap::invalidate):
* UIProcess/Downloads/DownloadProxyMap.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245480 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Downloads/DownloadMap.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h