Fix flaky chrome://webrtc-internals stats reporting bug.

A timer polls stats regularly, using standard or legacy stats as
specified in a UI. Which stats to use can change while a pending request
is in progress. This CL adds a check to discard legacy stats that are
given to JS if we are not currently expecting legacy stats.
This is something we were already doing for addStandardStats() but had
forgotten to add to addLegacyStats(). The bug was only apparent every
now and then depending on timing.

Drive-by: Rename "nukeStatsList" to "clearStatsList"

NOTRY=True

Bug: 803014
Change-Id: I5323d58f25792c2b34f2432fe1e8482008db1f39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1578608
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653146}
2 files changed