Remove usage of wstring StringPrintf(): base/

This function is going away.

Bug: 1371963
Change-Id: I646c39a62abcc90df53290ce84e6e315c1f2a4dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4884753
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1199926}
NOKEYCHECK=True
GitOrigin-RevId: bfb5e7d8f22b2b71178b4096272a0a3f42418eb1
diff --git a/debug/stack_trace_win.cc b/debug/stack_trace_win.cc
index 75bd006..415f1cf 100644
--- a/debug/stack_trace_win.cc
+++ b/debug/stack_trace_win.cc
@@ -17,8 +17,8 @@
 #include "base/files/file_path.h"
 #include "base/logging.h"
 #include "base/memory/singleton.h"
+#include "base/strings/strcat_win.h"
 #include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
 #include "base/synchronization/lock.h"
 #include "build/build_config.h"
 
@@ -201,8 +201,8 @@
     return false;
   }
 
-  std::wstring new_path = StringPrintf(L"%ls;%ls", symbols_path,
-                                       GetExePath().DirName().value().c_str());
+  std::wstring new_path =
+      StrCat({symbols_path, L";", GetExePath().DirName().value()});
   if (!SymSetSearchPathW(GetCurrentProcess(), new_path.c_str())) {
     g_init_error = GetLastError();
     DLOG(WARNING) << "SymSetSearchPath failed." << g_init_error;
diff --git a/win/access_control_list_unittest.cc b/win/access_control_list_unittest.cc
index 53332ea..3369b32 100644
--- a/win/access_control_list_unittest.cc
+++ b/win/access_control_list_unittest.cc
@@ -12,7 +12,7 @@
 #include <vector>
 
 #include "base/check.h"
-#include "base/strings/stringprintf.h"
+#include "base/strings/string_number_conversions_win.h"
 #include "base/win/scoped_localalloc.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -213,8 +213,8 @@
   EXPECT_EQ(ConvertAclToSddl(acl), kEvent);
   // ACL has a maximum capacity of 2^16-1 bytes or 2^16-1 ACEs. Force a fail.
   while (ace_list.size() < 0x10000) {
-    auto sid = Sid::FromSddlString(
-        base::StringPrintf(L"S-1-5-1234-%zu", ace_list.size()).c_str());
+    auto sid =
+        Sid::FromSddlString(L"S-1-5-1234-" + NumberToWString(ace_list.size()));
     ASSERT_TRUE(sid);
     ace_list.emplace_back(*sid, SecurityAccessMode::kGrant, GENERIC_ALL, 0);
   }
diff --git a/win/access_token.cc b/win/access_token.cc
index a46080c..c648851 100644
--- a/win/access_token.cc
+++ b/win/access_token.cc
@@ -11,6 +11,7 @@
 
 #include "base/numerics/checked_math.h"
 #include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
 
 namespace base::win {
 
@@ -230,9 +231,10 @@
   luid.LowPart = luid_.LowPart;
   luid.HighPart = luid_.HighPart;
   DWORD size = std::size(name);
-  if (!::LookupPrivilegeName(nullptr, &luid, name, &size))
-    return base::StringPrintf(L"%08X-%08X", luid.HighPart, luid.LowPart);
-  return name;
+  return ::LookupPrivilegeName(nullptr, &luid, name, &size)
+             ? name
+             : ASCIIToWide(
+                   StringPrintf("%08lX-%08lX", luid.HighPart, luid.LowPart));
 }
 
 bool AccessToken::Privilege::IsEnabled() const {
diff --git a/win/event_trace_consumer_unittest.cc b/win/event_trace_consumer_unittest.cc
index 2f1f92c..1909dff 100644
--- a/win/event_trace_consumer_unittest.cc
+++ b/win/event_trace_consumer_unittest.cc
@@ -16,8 +16,8 @@
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
 #include "base/process/process_handle.h"
+#include "base/strings/string_number_conversions_win.h"
 #include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
 #include "base/win/event_trace_controller.h"
 #include "base/win/event_trace_provider.h"
 #include "base/win/scoped_handle.h"
@@ -81,7 +81,7 @@
 class EtwTraceConsumerBaseTest : public testing::Test {
  public:
   EtwTraceConsumerBaseTest()
-      : session_name_(StringPrintf(L"TestSession-%d", GetCurrentProcId())) {}
+      : session_name_(L"TestSession-" + NumberToWString(GetCurrentProcId())) {}
 
   void SetUp() override {
     // Cleanup any potentially dangling sessions.
diff --git a/win/event_trace_controller_unittest.cc b/win/event_trace_controller_unittest.cc
index 57467fc..d4ee08f 100644
--- a/win/event_trace_controller_unittest.cc
+++ b/win/event_trace_controller_unittest.cc
@@ -13,8 +13,8 @@
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
 #include "base/process/process_handle.h"
+#include "base/strings/string_number_conversions_win.h"
 #include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
 #include "base/system/sys_info.h"
 #include "base/win/event_trace_controller.h"
 #include "base/win/event_trace_provider.h"
@@ -105,7 +105,7 @@
 class EtwTraceControllerTest : public testing::Test {
  public:
   EtwTraceControllerTest()
-      : session_name_(StringPrintf(L"TestSession-%d", GetCurrentProcId())) {}
+      : session_name_(L"TestSession-" + NumberToWString(GetCurrentProcId())) {}
 
   void SetUp() override {
     EtwTraceProperties ignore;
diff --git a/win/security_util_unittest.cc b/win/security_util_unittest.cc
index 14d6139..477f743 100644
--- a/win/security_util_unittest.cc
+++ b/win/security_util_unittest.cc
@@ -12,7 +12,7 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/strings/stringprintf.h"
+#include "base/strings/string_number_conversions_win.h"
 #include "base/win/scoped_handle.h"
 #include "base/win/scoped_localalloc.h"
 #include "base/win/sid.h"
@@ -99,8 +99,8 @@
       GrantAccessToPath(path, *sids, FILE_GENERIC_READ, NO_INHERITANCE, false));
   std::vector<Sid> large_sid_list;
   while (large_sid_list.size() < 0x10000) {
-    auto sid = Sid::FromSddlString(
-        base::StringPrintf(L"S-1-5-1234-%zu", large_sid_list.size()).c_str());
+    auto sid = Sid::FromSddlString(L"S-1-5-1234-" +
+                                   NumberToWString(large_sid_list.size()));
     ASSERT_TRUE(sid);
     large_sid_list.emplace_back(std::move(*sid));
   }