Reland of Properly report number of quality downscales in stats. (patchset #1 id:1 of https://codereview.webrtc.org/2586783003/ )

Reason for revert:
Bug affecting perf tests has been fixed. The issue was that I had accidentally disabled cpu overuse adaptation based on the encoders ScalingSettings, not just quality-based scaling.

Original issue's description:
> Revert of Properly report number of quality downscales in stats. (patchset #11 id:220001 of https://codereview.webrtc.org/2564373002/ )
>
> Reason for revert:
> Breaks perf tests
>
> Original issue's description:
> > Properly report number of quality downscales in stats.
> >
> > A regression was introduced in 876222f that caused these stats to
> > be reported incorrectly. This used to be only implemented for VP8
> > but should now be available for all codecs.
> >
> > BUG=webrtc:6860
> >
> > Review-Url: https://codereview.webrtc.org/2564373002
> > Cr-Commit-Position: refs/heads/master@{#15673}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/0c8c5388355f5df085595d9ea24fa38995708120
>
> TBR=asapersson@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6860
>
> Review-Url: https://codereview.webrtc.org/2586783003
> Cr-Commit-Position: refs/heads/master@{#15678}
> Committed: https://chromium.googlesource.com/external/webrtc/+/fe04bd43cc7a7d45ce59a2a83d716a68d06b5e92

TBR=asapersson@webrtc.org,stefan@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6860

Review-Url: https://codereview.webrtc.org/2588743002
Cr-Commit-Position: refs/heads/master@{#15680}
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index 4cee104..acb8a30 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -31,6 +31,12 @@
 const int kHeight = 480;
 const int kQpIdx0 = 21;
 const int kQpIdx1 = 39;
+const CodecSpecificInfo kDefaultCodecInfo = []() {
+  CodecSpecificInfo codec_info;
+  codec_info.codecType = kVideoCodecVP8;
+  codec_info.codecSpecific.VP8.simulcastIdx = 0;
+  return codec_info;
+}();
 }  // namespace
 
 class SendStatisticsProxyTest : public ::testing::Test {
@@ -659,10 +665,10 @@
 TEST_F(SendStatisticsProxyTest,
        QualityLimitedHistogramsNotUpdatedWhenDisabled) {
   EncodedImage encoded_image;
-  // encoded_image.adapt_reason_.quality_resolution_downscales disabled by
-  // default: -1
+  statistics_proxy_->SetResolutionRestrictionStats(false /* scaling_enabled */,
+                                                   0, 0);
   for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
-    statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
+    statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
 
   // Histograms are updated when the statistics_proxy_ is deleted.
   statistics_proxy_.reset();
@@ -674,11 +680,9 @@
 
 TEST_F(SendStatisticsProxyTest,
        QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
-  const int kDownscales = 0;
   EncodedImage encoded_image;
-  encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales;
   for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
-    statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
+    statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
 
   // Histograms are updated when the statistics_proxy_ is deleted.
   statistics_proxy_.reset();
@@ -695,10 +699,9 @@
        QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
   const int kDownscales = 2;
   EncodedImage encoded_image;
-  encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales;
+  statistics_proxy_->OnQualityRestrictedResolutionChanged(kDownscales);
   for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
-    statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
-
+    statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
   // Histograms are updated when the statistics_proxy_ is deleted.
   statistics_proxy_.reset();
   EXPECT_EQ(
@@ -720,12 +723,18 @@
   EncodedImage encoded_image;
   statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
   EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
-  // Resolution not scaled.
+
+  // Simulcast disabled resolutions
+  encoded_image.adapt_reason_.bw_resolutions_disabled = 1;
+  statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
+  EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution);
+
   encoded_image.adapt_reason_.bw_resolutions_disabled = 0;
   statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
   EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
-  // Resolution scaled due to bandwidth.
-  encoded_image.adapt_reason_.bw_resolutions_disabled = 1;
+
+  // Resolution scaled due to quality.
+  statistics_proxy_->OnQualityRestrictedResolutionChanged(1);
   statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
   EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution);
 }