build: clean up rtc_base deps

using
  find rtc_base -name BUILD.gn | xargs tools_webrtc/gn_check_autofix.py -r
followed by
  tools_webrtc/gn_check_autofix.py -C out/Default
and cherry-picking chunks

Bug: webrtc:467294026
Change-Id: Ibee7ac6cc590fdbf10e0710669396e7bdee96d85
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/461883
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#47339}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index f895f0b..7120fe4 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -57,7 +57,6 @@
     ":checks",
     ":untyped_function",
     "../api:function_view",
-    "system:assume",
     "system:inline",
     "system:rtc_export",
   ]
@@ -200,8 +199,8 @@
     "denormal_disabler.h",
   ]
   deps = [
-    "../rtc_base:checks",
-    "../rtc_base/system:arch",
+    ":checks",
+    "system:arch",
   ]
   if (is_clang) {
     cflags_cc = [ "-Wno-unused-private-field" ]
@@ -224,7 +223,6 @@
     ":platform_thread",
     ":platform_thread_types",
     ":rtc_event",
-    ":timeutils",
     "../api:sequence_checker",
     "../api/environment",
     "../api/units:time_delta",
@@ -397,10 +395,7 @@
     "ref_counted_object.h",
     "ref_counter.h",
   ]
-  deps = [
-    "../api:ref_count",
-    "../api:scoped_refptr",
-  ]
+  deps = [ "../api:ref_count" ]
 }
 
 rtc_library("criticalsection") {
@@ -412,7 +407,6 @@
     ":checks",
     ":macromagic",
     ":platform_thread_types",
-    "synchronization:yield",
     "system:unused",
   ]
 }
@@ -425,9 +419,6 @@
   deps = [
     ":checks",
     ":platform_thread_types",
-    ":rtc_event",
-    ":timeutils",
-    "../api:sequence_checker",
     "//third_party/abseil-cpp/absl/functional:any_invocable",
     "//third_party/abseil-cpp/absl/strings:string_view",
   ]
@@ -521,7 +512,6 @@
   ]
   deps = [
     ":safe_compare",
-    ":type_traits",
     "../api:scoped_refptr",
     "system:inline",
     "system:rtc_export",
@@ -602,7 +592,6 @@
   deps = [
     ":checks",
     ":safe_conversions",
-    ":stringutils",
     "system:rtc_export",
   ]
 
@@ -647,10 +636,8 @@
     "text2pcap.h",
   ]
   deps = [
-    ":logging",
     ":stringutils",
     ":timeutils",
-    "system:rtc_export",
     "//third_party/abseil-cpp/absl/strings:string_view",
   ]
 }
@@ -668,7 +655,6 @@
   deps = [
     ":checks",
     ":macromagic",
-    ":refcount",
     "../api:make_ref_counted",
     "../api:refcountedbase",
     "../api:scoped_refptr",
@@ -730,11 +716,9 @@
   deps = [
     ":checks",
     ":divide_round",
-    ":logging",
     ":macromagic",
     ":platform_thread",
     ":rtc_event",
-    ":safe_conversions",
     ":timeutils",
     "../api:location",
     "../api/task_queue",
@@ -759,7 +743,6 @@
       "../api/task_queue",
       "../api/task_queue:task_queue_test",
       "../api/units:time_delta",
-      "../test:run_loop",
       "../test:test_support",
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
@@ -909,7 +892,6 @@
   deps = [
     ":checks",
     ":ip_address",
-    ":logging",
     ":macromagic",
     ":net_helpers",
     ":platform_thread",
@@ -918,7 +900,6 @@
     ":stringutils",
     "../api:async_dns_resolver",
     "../api:make_ref_counted",
-    "../api:refcountedbase",
     "../api:scoped_refptr",
     "../api:sequence_checker",
     "../api/task_queue",
@@ -939,7 +920,6 @@
     ":logging",
     ":net_helpers",
     ":socket_address",
-    ":threading",
     "../test:run_loop",
     "../test:test_support",
   ]
@@ -971,9 +951,7 @@
   ]
   deps = [
     ":byte_order",
-    ":checks",
     ":ip_address",
-    ":logging",
     ":net_helpers",
     ":safe_conversions",
     ":stringutils",
@@ -1027,7 +1005,6 @@
   ]
   deps = [
     ":async_dns_resolver",
-    ":byte_order",
     ":checks",
     ":criticalsection",
     ":event_tracer",
@@ -1037,9 +1014,7 @@
     ":net_helpers",
     ":network_constants",
     ":null_socket_server",
-    ":platform_thread",
     ":platform_thread_types",
-    ":refcount",
     ":rtc_event",
     ":socket",
     ":socket_address",
@@ -1048,16 +1023,12 @@
     "../api:async_dns_resolver",
     "../api:function_view",
     "../api:location",
-    "../api:refcountedbase",
-    "../api:scoped_refptr",
     "../api:sequence_checker",
     "../api/task_queue",
-    "../api/task_queue:pending_task_safety_flag",
     "../api/transport:ecn_marking",
     "../api/units:time_delta",
     "../api/units:timestamp",
     "synchronization:mutex",
-    "system:no_unique_address",
     "system:rtc_export",
     "//third_party/abseil-cpp/absl/algorithm:container",
     "//third_party/abseil-cpp/absl/base:core_headers",
@@ -1091,7 +1062,6 @@
     "async_socket.h",
   ]
   deps = [
-    ":callback_list",
     ":checks",
     ":socket",
     ":socket_address",
@@ -1109,8 +1079,6 @@
     ":callback_list",
     ":callback_list_with_locks",
     ":checks",
-    ":ip_address",
-    ":net_helpers",
     ":socket_address",
     "../api/transport:ecn_marking",
     "../api/units:timestamp",
@@ -1129,7 +1097,6 @@
     deps = [
       ":socket",
       ":socket_address",
-      "../test:run_loop",
       "../test:test_support",
     ]
   }
@@ -1314,14 +1281,10 @@
   ]
   deps = [
     ":async_socket",
-    ":buffer",
-    ":byte_buffer",
     ":checks",
     ":logging",
     ":socket",
     ":socket_address",
-    ":stringutils",
-    ":zero_memory",
     "//third_party/abseil-cpp/absl/functional:any_invocable",
     "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/strings:string_view",
@@ -1353,9 +1316,7 @@
     ":logging",
     ":socket",
     ":socket_address",
-    ":timeutils",
     "../api/environment",
-    "../api/units:timestamp",
     "network:received_packet",
     "network:sent_packet",
     "//third_party/abseil-cpp/absl/base:nullability",
@@ -1378,7 +1339,6 @@
     ":socket",
     ":socket_address",
     ":socket_factory",
-    ":timeutils",
     "../api:sequence_checker",
     "../api/environment",
     "../api/units:time_delta",
@@ -1403,7 +1363,6 @@
     ":macromagic",
     ":socket",
     ":socket_address",
-    ":timeutils",
     "../api:sequence_checker",
     "network:received_packet",
     "network:sent_packet",
@@ -1421,7 +1380,6 @@
       ":async_packet_socket",
       ":socket",
       ":socket_address",
-      "../test:run_loop",
       "../test:test_support",
       "network:received_packet",
     ]
@@ -1442,7 +1400,6 @@
       "../api/units:timestamp",
       "../system_wrappers",
       "../test:create_test_environment",
-      "../test:run_loop",
       "../test:test_support",
       "network:received_packet",
       "//third_party/abseil-cpp/absl/memory",
@@ -1458,7 +1415,6 @@
       ":rtc_base_tests_utils",
       ":socket",
       "../test:create_test_environment",
-      "../test:run_loop",
       "../test:test_support",
     ]
   }
@@ -1483,7 +1439,6 @@
   ]
   deps = [
     ":checks",
-    ":logging",
     ":stringutils",
     "system:file_wrapper",
     "//third_party/abseil-cpp/absl/algorithm:container",
@@ -1533,11 +1488,8 @@
     "stream.h",
   ]
   deps = [
-    ":buffer",
     ":checks",
-    ":logging",
     ":macromagic",
-    ":threading",
     "../api:sequence_checker",
     "system:no_unique_address",
     "system:rtc_export",
@@ -1751,13 +1703,9 @@
   ]
   deps = [
     ":async_packet_socket",
-    ":async_udp_socket",
     ":buffer",
-    ":rtc_base_tests_utils",
     ":socket",
     ":socket_address",
-    ":threading",
-    ":timeutils",
     "../api/transport:ecn_marking",
     "../api/units:time_delta",
     "../api/units:timestamp",
@@ -1774,7 +1722,6 @@
   deps = [
     ":callback_list",
     ":untyped_function",
-    "../api:function_view",
     "../test:test_support",
   ]
 }
@@ -1812,9 +1759,7 @@
     ":async_packet_socket",
     ":async_socket",
     ":async_tcp_socket",
-    ":async_udp_socket",
     ":buffer",
-    ":byte_buffer",
     ":byte_order",
     ":callback_list",
     ":checks",
@@ -1835,7 +1780,6 @@
     ":socket_server",
     ":ssl",
     ":stream",
-    ":stringutils",
     ":threading",
     ":timeutils",
     "../api:make_ref_counted",
@@ -1843,12 +1787,10 @@
     "../api:scoped_refptr",
     "../api:sequence_checker",
     "../api/environment",
-    "../api/task_queue",
     "../api/task_queue:pending_task_safety_flag",
     "../api/transport:ecn_marking",
     "../api/units:time_delta",
     "../api/units:timestamp",
-    "memory:always_valid_pointer",
     "memory:fifo_buffer",
     "memory:less_unique_ptr",
     "network:received_packet",
@@ -1872,7 +1814,6 @@
     "rtp_to_ntp_estimator.h",
   ]
   deps = [
-    ":checks",
     ":logging",
     ":rtc_numerics",
     ":safe_conversions",
@@ -1974,7 +1915,6 @@
     sources = [ "untyped_function_unittest.cc" ]
     deps = [
       ":untyped_function",
-      "../test:run_loop",
       "../test:test_support",
     ]
   }
@@ -2011,10 +1951,8 @@
         "socket_unittest.h",
       ]
       deps = [
-        ":async_packet_socket",
         ":async_udp_socket",
         ":buffer",
-        ":checks",
         ":file_rotating_stream",
         ":ip_address",
         ":logging",
@@ -2035,7 +1973,6 @@
         "../api/transport:ecn_marking",
         "../api/units:time_delta",
         "../api/units:timestamp",
-        "../system_wrappers",
         "../test:create_test_environment",
         "../test:fileutils",
         "../test:near_matcher",
@@ -2123,7 +2060,6 @@
         ":mod_ops",
         ":moving_max_counter",
         ":net_helpers",
-        ":null_socket_server",
         ":one_time_event",
         ":platform_thread",
         ":random",
@@ -2140,8 +2076,6 @@
         ":sanitizer",
         ":socket",
         ":socket_address",
-        ":socket_server",
-        ":ssl",
         ":stringutils",
         ":strong_alias",
         ":swap_queue",
@@ -2154,7 +2088,6 @@
         "../api:ref_count",
         "../api:scoped_refptr",
         "../api/environment",
-        "../api/numerics",
         "../api/transport:ecn_marking",
         "../api/units:data_rate",
         "../api/units:data_size",
@@ -2163,8 +2096,6 @@
         "../api/units:timestamp",
         "../system_wrappers",
         "../test:create_test_environment",
-        "../test:fileutils",
-        "../test:run_loop",
         "../test:test_support",
         "../test/time_controller",
         "containers:flat_map",
@@ -2191,13 +2122,11 @@
 
       sources = [ "task_queue_unittest.cc" ]
       deps = [
-        ":rtc_base_tests_utils",
         ":rtc_event",
         ":task_queue_for_test",
         ":timeutils",
         "../api/task_queue",
         "../api/units:time_delta",
-        "../test:run_loop",
         "../test:test_support",
         "//third_party/abseil-cpp/absl/memory",
       ]
@@ -2208,11 +2137,8 @@
 
       sources = [ "weak_ptr_unittest.cc" ]
       deps = [
-        ":rtc_base_tests_utils",
-        ":rtc_event",
         ":task_queue_for_test",
         ":weak_ptr",
-        "../test:run_loop",
         "../test:test_support",
       ]
     }
@@ -2234,10 +2160,8 @@
       deps = [
         ":mod_ops",
         ":rtc_numerics",
-        ":timeutils",
         ":windowed_min_filter",
         "../api/units:time_delta",
-        "../test:run_loop",
         "../test:test_support",
         "//testing/gtest",
         "//third_party/abseil-cpp/absl/algorithm:container",
@@ -2249,9 +2173,7 @@
 
       sources = [ "strings/json_unittest.cc" ]
       deps = [
-        ":rtc_base_tests_utils",
         ":rtc_json",
-        "../test:run_loop",
         "../test:test_support",
       ]
     }
@@ -2287,6 +2209,7 @@
         ":buffer",
         ":buffer_queue",
         ":byte_order",
+        ":callback_list",
         ":checks",
         ":crc32",
         ":crypto_random",
@@ -2304,7 +2227,6 @@
         ":network_route",
         ":null_socket_server",
         ":random",
-        ":refcount",
         ":rolling_accumulator",
         ":rtc_base_tests_utils",
         ":rtc_certificate_generator",
@@ -2312,7 +2234,6 @@
         ":rtp_to_ntp_estimator",
         ":safe_conversions",
         ":socket",
-        ":socket_adapters",
         ":socket_address",
         ":socket_factory",
         ":socket_server",
@@ -2328,7 +2249,6 @@
         "../api:field_trials",
         "../api:field_trials_view",
         "../api:location",
-        "../api:make_ref_counted",
         "../api:rtc_error_matchers",
         "../api:scoped_refptr",
         "../api:sequence_checker",
@@ -2343,13 +2263,11 @@
         "../system_wrappers",
         "../test:create_test_environment",
         "../test:create_test_field_trials",
-        "../test:fileutils",
         "../test:rtc_expect_death",
         "../test:run_loop",
         "../test:test_support",
         "../test:wait_until",
         "../test/time_controller",
-        "memory:fifo_buffer",
         "network:received_packet",
         "synchronization:mutex",
         "//testing/gtest",
@@ -2375,7 +2293,7 @@
           "ssl_identity_unittest.cc",
           "ssl_stream_adapter_unittest.cc",
         ]
-        deps += [ ":callback_list" ]
+        deps += []
       }
 
       if (build_with_chromium) {
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index 98d3025..8b9eb62 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -32,13 +32,13 @@
     "struct_parameters_parser.h",
   ]
   deps = [
+    "..:checks",
+    "..:logging",
+    "..:safe_conversions",
+    "..:stringutils",
     "../../api/units:data_rate",
     "../../api/units:data_size",
     "../../api/units:time_delta",
-    "../../rtc_base:checks",
-    "../../rtc_base:logging",
-    "../../rtc_base:safe_conversions",
-    "../../rtc_base:stringutils",
     "//third_party/abseil-cpp/absl/memory",
     "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/strings:string_view",
@@ -63,12 +63,12 @@
     "quality_scaling_experiment.h",
   ]
   deps = [
+    ":field_trial_parser",
     "..:checks",
     "..:logging",
     "../../api:field_trials_view",
     "../../api/video:video_frame",
     "../../api/video_codecs:video_codecs_api",
-    "../../rtc_base/experiments:field_trial_parser",
     "//third_party/abseil-cpp/absl/strings",
   ]
 }
@@ -122,11 +122,8 @@
   deps = [
     ":field_trial_parser",
     "..:logging",
-    "..:safe_conversions",
     "../../api:field_trials_view",
     "../../api/units:data_size",
-    "../../api/video_codecs:video_codecs_api",
-    "../../video/config:encoder_config",
     "//third_party/abseil-cpp/absl/strings",
   ]
 }
@@ -149,11 +146,11 @@
   ]
   deps = [
     ":field_trial_parser",
+    "..:checks",
+    "..:logging",
     "../../api:field_trials_view",
     "../../api/units:data_rate",
     "../../api/video:video_frame",
-    "../../rtc_base:checks",
-    "../../rtc_base:logging",
   ]
 }
 
@@ -166,7 +163,6 @@
     ":field_trial_parser",
     "..:logging",
     "../../api:field_trials_view",
-    "../../api/environment",
     "../../api/units:time_delta",
     "//third_party/abseil-cpp/absl/strings",
   ]
@@ -182,7 +178,6 @@
     "../../api:field_trials_view",
     "../../api/video:video_frame",
     "../../api/video_codecs:video_codecs_api",
-    "../../rtc_base/containers:flat_map",
     "//third_party/abseil-cpp/absl/strings",
   ]
 }
@@ -194,10 +189,9 @@
   ]
   deps = [
     ":field_trial_parser",
+    "..:logging",
     "../../api:field_trials_view",
     "../../api/units:time_delta",
-    "../../rtc_base:logging",
-    "../../video/corruption_detection:frame_selector",
   ]
 }
 
@@ -242,9 +236,7 @@
       "../../api/units:time_delta",
       "../../api/video:video_frame",
       "../../api/video_codecs:video_codecs_api",
-      "../../test:create_test_field_trials",
       "../../test:test_support",
-      "../../video/config:encoder_config",
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
   }
diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn
index 2a0ec55..9682dae 100644
--- a/rtc_base/memory/BUILD.gn
+++ b/rtc_base/memory/BUILD.gn
@@ -58,7 +58,6 @@
     ":always_valid_pointer",
     ":fifo_buffer",
     "..:stream",
-    "..:threading",
     "../../test:run_loop",
     "../../test:test_support",
   ]
diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn
index 2a19715..c1d924d 100644
--- a/rtc_base/synchronization/BUILD.gn
+++ b/rtc_base/synchronization/BUILD.gn
@@ -31,10 +31,8 @@
   }
 
   deps = [
-    ":yield",
     "..:checks",
     "..:macromagic",
-    "..:platform_thread_types",
     "../system:no_unique_address",
     "//third_party/abseil-cpp/absl/base:core_headers",
   ]
@@ -69,7 +67,6 @@
     "yield_policy.h",
   ]
   deps = [
-    "..:checks",
     "//third_party/abseil-cpp/absl/base:config",
     "//third_party/abseil-cpp/absl/base:core_headers",
   ]
@@ -86,9 +83,7 @@
       ":mutex",
       ":yield",
       ":yield_policy",
-      "..:checks",
       "..:macromagic",
-      "..:platform_thread",
       "..:rtc_event",
       "..:threading",
       "../../api/units:time_delta",
diff --git a/rtc_base/system/BUILD.gn b/rtc_base/system/BUILD.gn
index 653466e..f74e951 100644
--- a/rtc_base/system/BUILD.gn
+++ b/rtc_base/system/BUILD.gn
@@ -27,7 +27,6 @@
   ]
   deps = [
     "..:checks",
-    "..:criticalsection",
     "..:safe_conversions",
     "//third_party/abseil-cpp/absl/strings:string_view",
   ]
diff --git a/rtc_base/task_utils/BUILD.gn b/rtc_base/task_utils/BUILD.gn
index a5ef17a..006e715 100644
--- a/rtc_base/task_utils/BUILD.gn
+++ b/rtc_base/task_utils/BUILD.gn
@@ -15,9 +15,7 @@
   ]
   deps = [
     "..:checks",
-    "..:logging",
     "..:macromagic",
-    "..:timeutils",
     "../../api:location",
     "../../api:scoped_refptr",
     "../../api:sequence_checker",
diff --git a/rtc_base/units/BUILD.gn b/rtc_base/units/BUILD.gn
index 98ff7c9..0bcd025 100644
--- a/rtc_base/units/BUILD.gn
+++ b/rtc_base/units/BUILD.gn
@@ -16,9 +16,9 @@
   sources = [ "unit_base.h" ]
 
   deps = [
-    "../../rtc_base:checks",
-    "../../rtc_base:divide_round",
-    "../../rtc_base:safe_conversions",
+    "..:checks",
+    "..:divide_round",
+    "..:safe_conversions",
   ]
 }