_updateStats = (stats, statsSnapshot) => {
  stats.counter += 1;

  for (const statName of Object.values(STATS_KEYS)) {
    // Drop oldest stat value when we've reached the history size.
    if (stats[statName].length >= HISTORY_SIZE) {
      stats[statName] = stats[statName].slice(1);
    }
    // Construct new stat value from stats snapshot.
    const newStatValue = {
      x: stats.counter,
      y: (statsSnapshot && statsSnapshot[statName]) || 0
    };
    stats[statName].push(newStatValue);
  }
  return stats;
}
Update stats history with a stats snapshot.
@param {Stats} stats - Stats history.
@param {StatsSnapshot} statsSnapshot - Snapshot used to update stats history.