Fix SetCurrentThreadName() for Fuchsia.

CL suggested by lingxueluo@.

Bug: b/236891952
Change-Id: I960d5b016186e9784e0af5e86608891a06e78b7e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284920
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38723}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index c5b9024..fa60656 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -314,7 +314,10 @@
     "platform_thread_types.cc",
     "platform_thread_types.h",
   ]
-  deps = [ ":macromagic" ]
+  deps = [
+    ":checks",
+    ":macromagic",
+  ]
 }
 
 rtc_source_set("refcount") {
diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc
index b0243b4..d64ea68 100644
--- a/rtc_base/platform_thread_types.cc
+++ b/rtc_base/platform_thread_types.cc
@@ -25,6 +25,13 @@
                                                   PCWSTR lpThreadDescription);
 #endif
 
+#if defined(WEBRTC_FUCHSIA)
+#include <string.h>
+#include <zircon/syscalls.h>
+
+#include "rtc_base/checks.h"
+#endif
+
 namespace rtc {
 
 PlatformThreadId CurrentThreadId() {
@@ -109,6 +116,10 @@
   prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name));  // NOLINT
 #elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
   pthread_setname_np(name);
+#elif defined(WEBRTC_FUCHSIA)
+  zx_status_t status = zx_object_set_property(zx_thread_self(), ZX_PROP_NAME,
+                                              name, strlen(name));
+  RTC_DCHECK_EQ(status, ZX_OK);
 #endif
 }