Merge rtc_stats and rtc_stats_api build targets.

Keep the rtc_stats build target for backward compatibility.

Change-Id: I9cabd975346e9c008cc39b31a731828a9eb43a5f
Bug: webrtc:42226139
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/478443
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#47892}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 3895469..46f773b 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -1077,14 +1077,18 @@
   ]
 }
 
-rtc_source_set("rtc_stats_api") {
+rtc_library("rtc_stats_api") {
   visibility = [ "*" ]
   cflags = []
   sources = [
+    "stats/attribute.cc",
     "stats/attribute.h",
+    "stats/rtc_stats.cc",
     "stats/rtc_stats.h",
     "stats/rtc_stats_collector_callback.h",
+    "stats/rtc_stats_report.cc",
     "stats/rtc_stats_report.h",
+    "stats/rtcstats_objects.cc",
     "stats/rtcstats_objects.h",
   ]
 
@@ -1093,6 +1097,7 @@
     ":refcountedbase",
     ":scoped_refptr",
     "../rtc_base:checks",
+    "../rtc_base:stringutils",
     "../rtc_base/system:rtc_export",
     "units:timestamp",
   ]
diff --git a/stats/attribute.cc b/api/stats/attribute.cc
similarity index 100%
rename from stats/attribute.cc
rename to api/stats/attribute.cc
diff --git a/stats/rtc_stats.cc b/api/stats/rtc_stats.cc
similarity index 100%
rename from stats/rtc_stats.cc
rename to api/stats/rtc_stats.cc
diff --git a/stats/rtc_stats_report.cc b/api/stats/rtc_stats_report.cc
similarity index 100%
rename from stats/rtc_stats_report.cc
rename to api/stats/rtc_stats_report.cc
diff --git a/stats/rtcstats_objects.cc b/api/stats/rtcstats_objects.cc
similarity index 100%
rename from stats/rtcstats_objects.cc
rename to api/stats/rtcstats_objects.cc
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index d726ee6..c82d3d6 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -65,8 +65,8 @@
     }
   }
 
-  # TODO(bugs.webrtc.org/9627): Remove this when unused. Targets should depend on base_objc
-  # or helpers_objc directly instead.
+  # TODO(bugs.webrtc.org/9627): Remove this when unused. Targets should depend
+  # on base_objc or helpers_objc directly instead.
   rtc_library("common_objc") {
     visibility = [ "*" ]
 
@@ -1171,7 +1171,6 @@
         "../rtc_base:threading",
         "../rtc_base:timeutils",
         "../rtc_base/system:plan_b_only",
-        "../stats:rtc_stats",
         "../system_wrappers:metrics",
       ]
 
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 894672e..38136c4 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -904,7 +904,6 @@
       "../../rtc_base:stringutils",
       "../../rtc_base:threading",
       "../../rtc_base/system:plan_b_only",
-      "../../stats:rtc_stats",
       "//third_party/abseil-cpp/absl/memory",
       "//third_party/abseil-cpp/absl/strings",
       "//third_party/jni_zero",
diff --git a/stats/BUILD.gn b/stats/BUILD.gn
index 5626cc5..941e9aa 100644
--- a/stats/BUILD.gn
+++ b/stats/BUILD.gn
@@ -15,20 +15,9 @@
 rtc_library("rtc_stats") {
   visibility = [ "*" ]
   cflags = []
-  sources = [
-    "attribute.cc",
-    "rtc_stats.cc",
-    "rtc_stats_report.cc",
-    "rtcstats_objects.cc",
-  ]
+  sources = []
 
-  deps = [
-    "../api:rtc_stats_api",
-    "../api:scoped_refptr",
-    "../api/units:timestamp",
-    "../rtc_base:checks",
-    "../rtc_base:stringutils",
-  ]
+  deps = [ "../api:rtc_stats_api" ]
 }
 
 rtc_library("rtc_stats_test_utils") {
diff --git a/unsafe_buffers_paths.txt b/unsafe_buffers_paths.txt
index a1522f4..78b026e 100644
--- a/unsafe_buffers_paths.txt
+++ b/unsafe_buffers_paths.txt
@@ -40,6 +40,7 @@
 -api/numerics/samples_stats_counter_unittest.cc
 -api/rtc_error.cc
 -api/rtp_packet_info.cc
+-api/stats/rtcstats_objects.cc
 -api/video/i010_buffer.cc
 -api/video/i210_buffer.cc
 -api/video/i410_buffer.cc
@@ -617,7 +618,6 @@
 -rtc_tools/video_replay.cc
 -stats/rtc_stats_report_unittest.cc
 -stats/rtc_stats_unittest.cc
--stats/rtcstats_objects.cc
 -stats/test/rtc_test_stats.cc
 -test/call_test.cc
 -test/direct_transport.cc