Avoid initial NetworkChangeNotifier OnDNSChanged() signal on Android
When the DnsConfigServicePosix finishes its initial reading of the
system DNS config, it normally triggers a NetworkChangeNotifier (NCN)
OnDNSChanged() signal. This can cause in-flight network requests to
abort with ERR_NETWORK_CHANGED. Avoid aborting requests by:
1. Adding a new NCN signal, OnInitialDNSConfigRead which indicates
the initial DNS config reading completed but does not represent
a change in DNS config.
2. Modify HostResolverImpl to not abort requests upon this new
signal (like it does for the OnDNSChanged signal).
3. Add logic to NetworkChangeNotifierAndroid to emit this new
signal when safe to do so. Network requests begin being issued
immediately after the NCN (and hence DnsConfigService) is
initialized, so we need to be sure no network change signals
are missed between NCN initialization completing and the
OnInitialDNSConfigRead signal. This is tricky because the
NCN (and hence DnsConfigService) is initialized on threads
where file I/O is not allowed. Were file I/O allowed we could
simply slurp up the DNS config and hosts file. Instead we
start listening for network changes (which is our trigger signal
for DNS changes on Android) on the initialization thread and
record the current time to later compare against the hosts
file's last-modified time to check for changes to the file.
Actual loading of the DNS config and hosts file is done on
another thread that allows file I/O.
BUG=470897
Review URL: https://codereview.chromium.org/1047103002
Cr-Commit-Position: refs/heads/master@{#325560}
17 files changed