[crashpad] Prepare crashpad for base::string16 switch

This change prepares crashpad for the upcoming switch of base::string16
to std::u16string on all platforms. It does so by replacing Windows-only
instances of base::string16 with std::wstring, and using appropriate
string utility functions.

Bug: chromium:911896
Change-Id: I1870e12ac07bae5aadd79a101555f756418ed58a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2332402
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
GitOrigin-RevId: a98ee20e578f6febb828f5606c6ed1c02dc4e879
diff --git a/client/crash_report_database.cc b/client/crash_report_database.cc
index e1559ca..122e62e 100644
--- a/client/crash_report_database.cc
+++ b/client/crash_report_database.cc
@@ -50,7 +50,7 @@
   }
 
 #if defined(OS_WIN)
-  const std::wstring uuid_string = uuid_.ToString16();
+  const std::wstring uuid_string = uuid_.ToWString();
 #else
   const std::string uuid_string = uuid_.ToString();
 #endif
diff --git a/client/crash_report_database_win.cc b/client/crash_report_database_win.cc
index f1a4960..a5fd38c 100644
--- a/client/crash_report_database_win.cc
+++ b/client/crash_report_database_win.cc
@@ -25,7 +25,6 @@
 
 #include "base/logging.h"
 #include "base/numerics/safe_math.h"
-#include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "client/settings.h"
@@ -66,9 +65,8 @@
 
 // Converts |str| to UTF8, adds the result to the string table and returns the
 // byte index where it was added.
-uint32_t AddStringToTable(std::string* string_table,
-                          const base::string16& str) {
-  return AddStringToTable(string_table, base::UTF16ToUTF8(str));
+uint32_t AddStringToTable(std::string* string_table, const std::wstring& str) {
+  return AddStringToTable(string_table, base::WideToUTF8(str));
 }
 
 // Reads from the current file position to EOF and returns as a string of bytes.
@@ -183,7 +181,7 @@
     : Report() {
   uuid = record.uuid;
   file_path = report_dir.Append(
-      base::UTF8ToUTF16(&string_table[record.file_path_index]));
+      base::UTF8ToWide(&string_table[record.file_path_index]));
   id = &string_table[record.id_index];
   creation_time = record.creation_time;
   last_upload_attempt_time = record.last_upload_attempt_time;
@@ -540,7 +538,7 @@
     const base::FilePath& path = report.file_path;
     if (path.DirName() != report_dir_) {
       LOG(ERROR) << path.value().c_str() << " expected to start with "
-                 << base::UTF16ToUTF8(report_dir_.value());
+                 << base::WideToUTF8(report_dir_.value());
       return;
     }
     records.push_back(MetadataFileReportRecord(report, &string_table));
@@ -584,12 +582,11 @@
 bool EnsureDirectory(const base::FilePath& path) {
   DWORD fileattr = GetFileAttributes(path.value().c_str());
   if (fileattr == INVALID_FILE_ATTRIBUTES) {
-    PLOG(ERROR) << "GetFileAttributes " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value());
     return false;
   }
   if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
-    LOG(ERROR) << "GetFileAttributes "
-               << base::UTF16ToUTF8(path.value())
+    LOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value())
                << ": not a directory";
     return false;
   }
@@ -606,7 +603,7 @@
   if (CreateDirectory(path.value().c_str(), nullptr))
     return true;
   if (GetLastError() != ERROR_ALREADY_EXISTS) {
-    PLOG(ERROR) << "CreateDirectory " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "CreateDirectory " << base::WideToUTF8(path.value());
     return false;
   }
   return EnsureDirectory(path);
@@ -675,7 +672,7 @@
 }
 
 base::FilePath CrashReportDatabaseWin::AttachmentsPath(const UUID& uuid) {
-  const std::wstring uuid_string = uuid.ToString16();
+  const std::wstring uuid_string = uuid.ToWString();
   return base_dir_.Append(kAttachmentsDirectory).Append(uuid_string);
 }
 
@@ -691,7 +688,7 @@
     return nullptr;
   }
 
-  base::FilePath path = attachments_dir.Append(base::UTF8ToUTF16(name));
+  base::FilePath path = attachments_dir.Append(base::UTF8ToWide(name));
 
   auto writer = std::make_unique<FileWriter>();
   if (!writer->Open(
@@ -727,7 +724,7 @@
       continue;
     }
     attachment_readers_.emplace_back(std::move(file_reader));
-    attachment_map_[base::UTF16ToUTF8(filename.value())] =
+    attachment_map_[base::WideToUTF8(filename.value())] =
         attachment_readers_.back().get();
   }
 }
@@ -925,8 +922,7 @@
     return os;
 
   if (!DeleteFile(report_path.value().c_str())) {
-    PLOG(ERROR) << "DeleteFile "
-                << base::UTF16ToUTF8(report_path.value());
+    PLOG(ERROR) << "DeleteFile " << base::WideToUTF8(report_path.value());
     return kFileSystemError;
   }
 
@@ -1096,7 +1092,7 @@
 
       // Remove attachments if corresponding report doen't exist.
       base::FilePath report_path =
-          reports_dir.Append(uuid.ToString16() + kCrashReportFileExtension);
+          reports_dir.Append(uuid.ToWString() + kCrashReportFileExtension);
       if (!IsRegularFile(report_path)) {
         RemoveAttachmentsByUUID(uuid);
       }
diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc
index 1f2fb81..4ae8da0 100644
--- a/client/crashpad_client_win.cc
+++ b/client/crashpad_client_win.cc
@@ -26,7 +26,6 @@
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/scoped_generic.h"
-#include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/synchronization/lock.h"
@@ -200,7 +199,7 @@
 
 std::wstring FormatArgumentString(const std::string& name,
                                   const std::wstring& value) {
-  return std::wstring(L"--") + base::UTF8ToUTF16(name) + L"=" + value;
+  return std::wstring(L"--") + base::UTF8ToWide(name) + L"=" + value;
 }
 
 struct ScopedProcThreadAttributeListTraits {
@@ -282,7 +281,7 @@
 #endif
       GetCurrentProcessId());
   do {
-    *pipe_name = base::UTF8ToUTF16(pipe_name_base + RandomString());
+    *pipe_name = base::UTF8ToWide(pipe_name_base + RandomString());
 
     pipe_instance->reset(CreateNamedPipeInstance(*pipe_name, true));
 
@@ -362,7 +361,7 @@
   std::wstring command_line;
   AppendCommandLineArgument(data->handler.value(), &command_line);
   for (const std::string& argument : data->arguments) {
-    AppendCommandLineArgument(base::UTF8ToUTF16(argument), &command_line);
+    AppendCommandLineArgument(base::UTF8ToWide(argument), &command_line);
   }
   if (!data->database.value().empty()) {
     AppendCommandLineArgument(
@@ -376,13 +375,13 @@
   }
   if (!data->url.empty()) {
     AppendCommandLineArgument(
-        FormatArgumentString("url", base::UTF8ToUTF16(data->url)),
+        FormatArgumentString("url", base::UTF8ToWide(data->url)),
         &command_line);
   }
   for (const auto& kv : data->annotations) {
     AppendCommandLineArgument(
         FormatArgumentString("annotation",
-                             base::UTF8ToUTF16(kv.first + '=' + kv.second)),
+                             base::UTF8ToWide(kv.first + '=' + kv.second)),
         &command_line);
   }
   for (const base::FilePath& attachment : data->attachments) {
@@ -408,8 +407,8 @@
       FromPointerCast<WinVMAddress>(&g_non_crash_exception_information),
       FromPointerCast<WinVMAddress>(&g_critical_section_with_debug_info));
   AppendCommandLineArgument(
-      base::UTF8ToUTF16(std::string("--initial-client-data=") +
-                        initial_client_data.StringRepresentation()),
+      base::UTF8ToWide(std::string("--initial-client-data=") +
+                       initial_client_data.StringRepresentation()),
       &command_line);
 
   BOOL rv;
@@ -495,7 +494,7 @@
   // invalid command line where the first argument needed by rundll32 is not in
   // the correct format as required in:
   // https://support.microsoft.com/en-ca/help/164787/info-windows-rundll-and-rundll32-interface
-  const base::StringPiece16 kRunDll32Exe(L"rundll32.exe");
+  const base::WStringPiece kRunDll32Exe(L"rundll32.exe");
   bool is_embedded_in_dll = false;
   if (data->handler.value().size() >= kRunDll32Exe.size() &&
       _wcsicmp(data->handler.value()
diff --git a/handler/handler_main.cc b/handler/handler_main.cc
index f3730e8..3364929 100644
--- a/handler/handler_main.cc
+++ b/handler/handler_main.cc
@@ -1097,7 +1097,7 @@
   ExceptionHandlerServer exception_handler_server(!options.pipe_name.empty());
 
   if (!options.pipe_name.empty()) {
-    exception_handler_server.SetPipeName(base::UTF8ToUTF16(options.pipe_name));
+    exception_handler_server.SetPipeName(base::UTF8ToWide(options.pipe_name));
   }
 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
   ExceptionHandlerServer exception_handler_server;
diff --git a/handler/win/crash_report_exception_handler.cc b/handler/win/crash_report_exception_handler.cc
index c26dfdc..d78d9e6 100644
--- a/handler/win/crash_report_exception_handler.cc
+++ b/handler/win/crash_report_exception_handler.cc
@@ -126,7 +126,7 @@
 
       base::FilePath filename = attachment.BaseName();
       FileWriter* file_writer =
-          new_report->AddAttachment(base::UTF16ToUTF8(filename.value()));
+          new_report->AddAttachment(base::WideToUTF8(filename.value()));
       if (file_writer == nullptr) {
         LOG(ERROR) << "attachment " << filename.value().c_str()
                    << " couldn't be created, skipping";
diff --git a/minidump/minidump_misc_info_writer.cc b/minidump/minidump_misc_info_writer.cc
index e17962c..0974e3d 100644
--- a/minidump/minidump_misc_info_writer.cc
+++ b/minidump/minidump_misc_info_writer.cc
@@ -310,7 +310,7 @@
   misc_info_.TimeZone.Bias = bias;
 
   internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
-      misc_info_.TimeZone.StandardName,
+      AsU16CStr(misc_info_.TimeZone.StandardName),
       base::size(misc_info_.TimeZone.StandardName),
       standard_name);
 
@@ -318,7 +318,7 @@
   misc_info_.TimeZone.StandardBias = standard_bias;
 
   internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
-      misc_info_.TimeZone.DaylightName,
+      AsU16CStr(misc_info_.TimeZone.DaylightName),
       base::size(misc_info_.TimeZone.DaylightName),
       daylight_name);
 
@@ -336,9 +336,11 @@
   misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
 
   internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
-      misc_info_.BuildString, base::size(misc_info_.BuildString), build_string);
+      AsU16CStr(misc_info_.BuildString),
+      base::size(misc_info_.BuildString),
+      build_string);
   internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
-      misc_info_.DbgBldStr,
+      AsU16CStr(misc_info_.DbgBldStr),
       base::size(misc_info_.DbgBldStr),
       debug_build_string);
 }
diff --git a/minidump/minidump_misc_info_writer.h b/minidump/minidump_misc_info_writer.h
index ee90b0e..b19a818 100644
--- a/minidump/minidump_misc_info_writer.h
+++ b/minidump/minidump_misc_info_writer.h
@@ -20,10 +20,13 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <time.h>
+#include <wchar.h>
 
 #include <string>
 
 #include "base/macros.h"
+#include "base/strings/string16.h"
+#include "build/build_config.h"
 #include "minidump/minidump_stream_writer.h"
 #include "minidump/minidump_writable.h"
 
@@ -137,6 +140,26 @@
   DISALLOW_COPY_AND_ASSIGN(MinidumpMiscInfoWriter);
 };
 
+//! \brief Conversion functions from a native UTF16 C-string to a base::char16
+//!     C-string. No-op where the native UTF16 string is base::string16.
+#if defined(WCHAR_T_IS_UTF16) || DOXYGEN
+inline const base::char16* AsU16CStr(const wchar_t* str) {
+  return reinterpret_cast<const base::char16*>(str);
+}
+
+inline base::char16* AsU16CStr(wchar_t* str) {
+  return reinterpret_cast<base::char16*>(str);
+}
+#else
+inline const base::char16* AsU16CStr(const base::char16* str) {
+  return str;
+}
+
+inline base::char16* AsU16CStr(base::char16* str) {
+  return str;
+}
+#endif
+
 }  // namespace crashpad
 
 #endif  // CRASHPAD_MINIDUMP_MINIDUMP_MISC_INFO_WRITER_H_
diff --git a/minidump/minidump_misc_info_writer_test.cc b/minidump/minidump_misc_info_writer_test.cc
index bd92733..b7ea3d0 100644
--- a/minidump/minidump_misc_info_writer_test.cc
+++ b/minidump/minidump_misc_info_writer_test.cc
@@ -125,8 +125,8 @@
   EXPECT_EQ(observed->TimeZone.Bias, expected->TimeZone.Bias);
   {
     SCOPED_TRACE("Standard");
-    ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
-                                 observed->TimeZone.StandardName,
+    ExpectNULPaddedString16Equal(AsU16CStr(expected->TimeZone.StandardName),
+                                 AsU16CStr(observed->TimeZone.StandardName),
                                  base::size(expected->TimeZone.StandardName));
     ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
                           &observed->TimeZone.StandardDate);
@@ -134,8 +134,8 @@
   }
   {
     SCOPED_TRACE("Daylight");
-    ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
-                                 observed->TimeZone.DaylightName,
+    ExpectNULPaddedString16Equal(AsU16CStr(expected->TimeZone.DaylightName),
+                                 AsU16CStr(observed->TimeZone.DaylightName),
                                  base::size(expected->TimeZone.DaylightName));
     ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
                           &observed->TimeZone.DaylightDate);
@@ -152,14 +152,14 @@
       reinterpret_cast<const MINIDUMP_MISC_INFO_3*>(observed));
   {
     SCOPED_TRACE("BuildString");
-    ExpectNULPaddedString16Equal(expected->BuildString,
-                                 observed->BuildString,
+    ExpectNULPaddedString16Equal(AsU16CStr(expected->BuildString),
+                                 AsU16CStr(observed->BuildString),
                                  base::size(expected->BuildString));
   }
   {
     SCOPED_TRACE("DbgBldStr");
-    ExpectNULPaddedString16Equal(expected->DbgBldStr,
-                                 observed->DbgBldStr,
+    ExpectNULPaddedString16Equal(AsU16CStr(expected->DbgBldStr),
+                                 AsU16CStr(observed->DbgBldStr),
                                  base::size(expected->DbgBldStr));
   }
 }
@@ -394,7 +394,7 @@
   expected.TimeZoneId = kTimeZoneId;
   expected.TimeZone.Bias = kBias;
   base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
-  c16lcpy(expected.TimeZone.StandardName,
+  c16lcpy(AsU16CStr(expected.TimeZone.StandardName),
           standard_name_utf16.c_str(),
           base::size(expected.TimeZone.StandardName));
   memcpy(&expected.TimeZone.StandardDate,
@@ -402,7 +402,7 @@
          sizeof(expected.TimeZone.StandardDate));
   expected.TimeZone.StandardBias = kStandardBias;
   base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
-  c16lcpy(expected.TimeZone.DaylightName,
+  c16lcpy(AsU16CStr(expected.TimeZone.DaylightName),
           daylight_name_utf16.c_str(),
           base::size(expected.TimeZone.DaylightName));
   memcpy(&expected.TimeZone.DaylightDate,
@@ -455,7 +455,7 @@
   expected.TimeZoneId = kTimeZoneId;
   expected.TimeZone.Bias = kBias;
   base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
-  c16lcpy(expected.TimeZone.StandardName,
+  c16lcpy(AsU16CStr(expected.TimeZone.StandardName),
           standard_name_utf16.c_str(),
           base::size(expected.TimeZone.StandardName));
   memcpy(&expected.TimeZone.StandardDate,
@@ -463,7 +463,7 @@
          sizeof(expected.TimeZone.StandardDate));
   expected.TimeZone.StandardBias = kStandardBias;
   base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
-  c16lcpy(expected.TimeZone.DaylightName,
+  c16lcpy(AsU16CStr(expected.TimeZone.DaylightName),
           daylight_name_utf16.c_str(),
           base::size(expected.TimeZone.DaylightName));
   memcpy(&expected.TimeZone.DaylightDate,
@@ -494,12 +494,12 @@
   MINIDUMP_MISC_INFO_4 expected = {};
   expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
   base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
-  c16lcpy(expected.BuildString,
+  c16lcpy(AsU16CStr(expected.BuildString),
           build_string_utf16.c_str(),
           base::size(expected.BuildString));
   base::string16 debug_build_string_utf16 =
       base::UTF8ToUTF16(kDebugBuildString);
-  c16lcpy(expected.DbgBldStr,
+  c16lcpy(AsU16CStr(expected.DbgBldStr),
           debug_build_string_utf16.c_str(),
           base::size(expected.DbgBldStr));
 
@@ -531,12 +531,12 @@
   MINIDUMP_MISC_INFO_4 expected = {};
   expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
   base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
-  c16lcpy(expected.BuildString,
+  c16lcpy(AsU16CStr(expected.BuildString),
           build_string_utf16.c_str(),
           base::size(expected.BuildString));
   base::string16 debug_build_string_utf16 =
       base::UTF8ToUTF16(debug_build_string);
-  c16lcpy(expected.DbgBldStr,
+  c16lcpy(AsU16CStr(expected.DbgBldStr),
           debug_build_string_utf16.c_str(),
           base::size(expected.DbgBldStr));
 
@@ -676,7 +676,7 @@
   expected.TimeZoneId = kTimeZoneId;
   expected.TimeZone.Bias = kBias;
   base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
-  c16lcpy(expected.TimeZone.StandardName,
+  c16lcpy(AsU16CStr(expected.TimeZone.StandardName),
           standard_name_utf16.c_str(),
           base::size(expected.TimeZone.StandardName));
   memcpy(&expected.TimeZone.StandardDate,
@@ -684,7 +684,7 @@
          sizeof(expected.TimeZone.StandardDate));
   expected.TimeZone.StandardBias = kStandardBias;
   base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
-  c16lcpy(expected.TimeZone.DaylightName,
+  c16lcpy(AsU16CStr(expected.TimeZone.DaylightName),
           daylight_name_utf16.c_str(),
           base::size(expected.TimeZone.DaylightName));
   memcpy(&expected.TimeZone.DaylightDate,
@@ -692,12 +692,12 @@
          sizeof(expected.TimeZone.DaylightDate));
   expected.TimeZone.DaylightBias = kDaylightBias;
   base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
-  c16lcpy(expected.BuildString,
+  c16lcpy(AsU16CStr(expected.BuildString),
           build_string_utf16.c_str(),
           base::size(expected.BuildString));
   base::string16 debug_build_string_utf16 =
       base::UTF8ToUTF16(kDebugBuildString);
-  c16lcpy(expected.DbgBldStr,
+  c16lcpy(AsU16CStr(expected.DbgBldStr),
           debug_build_string_utf16.c_str(),
           base::size(expected.DbgBldStr));
 
@@ -741,18 +741,18 @@
   expect_misc_info.ProcessorMaxMhz = 2800;
   expect_misc_info.TimeZoneId = 1;
   expect_misc_info.TimeZone.Bias = 300;
-  c16lcpy(expect_misc_info.TimeZone.StandardName,
+  c16lcpy(AsU16CStr(expect_misc_info.TimeZone.StandardName),
           standard_time_name_utf16.c_str(),
           base::size(expect_misc_info.TimeZone.StandardName));
   expect_misc_info.TimeZone.StandardBias = 0;
-  c16lcpy(expect_misc_info.TimeZone.DaylightName,
+  c16lcpy(AsU16CStr(expect_misc_info.TimeZone.DaylightName),
           daylight_time_name_utf16.c_str(),
           base::size(expect_misc_info.TimeZone.DaylightName));
   expect_misc_info.TimeZone.DaylightBias = -60;
-  c16lcpy(expect_misc_info.BuildString,
+  c16lcpy(AsU16CStr(expect_misc_info.BuildString),
           build_string_utf16.c_str(),
           base::size(expect_misc_info.BuildString));
-  c16lcpy(expect_misc_info.DbgBldStr,
+  c16lcpy(AsU16CStr(expect_misc_info.DbgBldStr),
           debug_build_string_utf16.c_str(),
           base::size(expect_misc_info.DbgBldStr));
 
diff --git a/snapshot/crashpad_info_client_options_test.cc b/snapshot/crashpad_info_client_options_test.cc
index 7604ced..a0d22c1 100644
--- a/snapshot/crashpad_info_client_options_test.cc
+++ b/snapshot/crashpad_info_client_options_test.cc
@@ -159,9 +159,9 @@
                               << dlerror();
 #elif defined(OS_WIN)
   ScopedModuleHandle module(LoadLibrary(module_path.value().c_str()));
-  ASSERT_TRUE(module.valid()) << "LoadLibrary "
-                              << base::UTF16ToUTF8(module_path.value()) << ": "
-                              << ErrorMessage();
+  ASSERT_TRUE(module.valid())
+      << "LoadLibrary " << base::WideToUTF8(module_path.value()) << ": "
+      << ErrorMessage();
 #else
 #error Port.
 #endif  // OS_APPLE
@@ -258,7 +258,7 @@
 #elif defined(OS_WIN)
   ScopedModuleHandle module(LoadLibrary(module_path.value().c_str()));
   ASSERT_TRUE(module.valid())
-      << "LoadLibrary " << base::UTF16ToUTF8(module_path.value()) << ": "
+      << "LoadLibrary " << base::WideToUTF8(module_path.value()) << ": "
       << ErrorMessage();
 #else
 #error Port.
diff --git a/snapshot/minidump/process_snapshot_minidump.cc b/snapshot/minidump/process_snapshot_minidump.cc
index 8dc5580..c42e7cc 100644
--- a/snapshot/minidump/process_snapshot_minidump.cc
+++ b/snapshot/minidump/process_snapshot_minidump.cc
@@ -19,6 +19,7 @@
 #include "base/logging.h"
 #include "base/notreached.h"
 #include "base/strings/utf_string_conversions.h"
+#include "build/build_config.h"
 #include "minidump/minidump_extensions.h"
 #include "snapshot/memory_map_region_snapshot.h"
 #include "snapshot/minidump/minidump_simple_string_dictionary_reader.h"
@@ -312,7 +313,11 @@
   switch (stream_it->second->DataSize) {
     case sizeof(MINIDUMP_MISC_INFO_5):
     case sizeof(MINIDUMP_MISC_INFO_4):
+#if defined(WCHAR_T_IS_UTF16)
+      full_version_ = base::WideToUTF8(info.BuildString);
+#else
       full_version_ = base::UTF16ToUTF8(info.BuildString);
+#endif
       full_version_ = full_version_.substr(0, full_version_.find(";"));
       FALLTHROUGH;
     case sizeof(MINIDUMP_MISC_INFO_3):
diff --git a/snapshot/win/exception_snapshot_win_test.cc b/snapshot/win/exception_snapshot_win_test.cc
index 07a25a8..63f9bf8 100644
--- a/snapshot/win/exception_snapshot_win_test.cc
+++ b/snapshot/win/exception_snapshot_win_test.cc
@@ -17,7 +17,6 @@
 #include <string>
 
 #include "base/files/file_path.h"
-#include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "client/crashpad_client.h"
 #include "gtest/gtest.h"
diff --git a/snapshot/win/module_snapshot_win.cc b/snapshot/win/module_snapshot_win.cc
index c7aaad8..fe16bb9 100644
--- a/snapshot/win/module_snapshot_win.cc
+++ b/snapshot/win/module_snapshot_win.cc
@@ -58,7 +58,7 @@
   if (!pe_image_reader_->Initialize(process_reader_,
                                     process_reader_module.dll_base,
                                     process_reader_module.size,
-                                    base::UTF16ToUTF8(name_))) {
+                                    base::WideToUTF8(name_))) {
     return false;
   }
 
@@ -73,7 +73,7 @@
     // would do). As we don't expect to ever encounter a module that wouldn't be
     // using .PDB that we actually have symbols for, we simply set a plausible
     // name here, but this will never correspond to symbols that we have.
-    pdb_name_ = base::UTF16ToUTF8(name_);
+    pdb_name_ = base::WideToUTF8(name_);
   }
 
   if (!memory_range_.Initialize(process_reader_->Memory(),
@@ -110,7 +110,7 @@
 
 std::string ModuleSnapshotWin::Name() const {
   INITIALIZATION_STATE_DCHECK_VALID(initialized_);
-  return base::UTF16ToUTF8(name_);
+  return base::WideToUTF8(name_);
 }
 
 uint64_t ModuleSnapshotWin::Address() const {
@@ -299,7 +299,7 @@
           simple_ranges.size() * sizeof(simple_ranges[0]),
           &simple_ranges[0])) {
     LOG(WARNING) << "could not read simple address_ranges from "
-                 << base::UTF16ToUTF8(name_);
+                 << base::WideToUTF8(name_);
     return;
   }
 
@@ -322,7 +322,7 @@
     if (!process_reader_->Memory()->Read(
             cur, sizeof(list_entry), &list_entry)) {
       LOG(WARNING) << "could not read user data stream entry from "
-                   << base::UTF16ToUTF8(name_);
+                   << base::WideToUTF8(name_);
       return;
     }
 
diff --git a/snapshot/win/pe_image_annotations_reader.cc b/snapshot/win/pe_image_annotations_reader.cc
index 8932e63..f19ab3a 100644
--- a/snapshot/win/pe_image_annotations_reader.cc
+++ b/snapshot/win/pe_image_annotations_reader.cc
@@ -99,7 +99,7 @@
           simple_annotations.size() * sizeof(simple_annotations[0]),
           &simple_annotations[0])) {
     LOG(WARNING) << "could not read simple annotations from "
-                 << base::UTF16ToUTF8(name_);
+                 << base::WideToUTF8(name_);
     return;
   }
 
@@ -110,7 +110,7 @@
       std::string value(entry.value, strnlen(entry.value, sizeof(entry.value)));
       if (!simple_map_annotations->insert(std::make_pair(key, value)).second) {
         LOG(INFO) << "duplicate simple annotation " << key << " in "
-                  << base::UTF16ToUTF8(name_);
+                  << base::WideToUTF8(name_);
       }
     }
   }
@@ -133,7 +133,7 @@
                                        sizeof(annotation_list_object),
                                        &annotation_list_object)) {
     LOG(WARNING) << "could not read annotations list object in "
-                 << base::UTF16ToUTF8(name_);
+                 << base::WideToUTF8(name_);
     return;
   }
 
@@ -145,7 +145,7 @@
     if (!process_reader_->Memory()->Read(
             current.link_node, sizeof(current), &current)) {
       LOG(WARNING) << "could not read annotation at index " << index << " in "
-                   << base::UTF16ToUTF8(name_);
+                   << base::WideToUTF8(name_);
       return;
     }
 
@@ -160,7 +160,7 @@
     if (!process_reader_->Memory()->Read(
             current.name, base::size(name), name)) {
       LOG(WARNING) << "could not read annotation name at index " << index
-                   << " in " << base::UTF16ToUTF8(name_);
+                   << " in " << base::WideToUTF8(name_);
       continue;
     }
 
@@ -173,7 +173,7 @@
     if (!process_reader_->Memory()->Read(
             current.value, value_length, snapshot.value.data())) {
       LOG(WARNING) << "could not read annotation value at index " << index
-                   << " in " << base::UTF16ToUTF8(name_);
+                   << " in " << base::WideToUTF8(name_);
       continue;
     }
 
diff --git a/snapshot/win/pe_image_reader_test.cc b/snapshot/win/pe_image_reader_test.cc
index 161d9c8..e364ed7 100644
--- a/snapshot/win/pe_image_reader_test.cc
+++ b/snapshot/win/pe_image_reader_test.cc
@@ -62,14 +62,14 @@
       &process_reader,
       FromPointerCast<WinVMAddress>(module_handle.get()),
       module_info.SizeOfImage,
-      base::UTF16ToUTF8(module_basename.value())));
+      base::WideToUTF8(module_basename.value())));
 
   UUID uuid;
   DWORD age;
   std::string pdbname;
   ASSERT_TRUE(pe_image_reader.DebugDirectoryInformation(&uuid, &age, &pdbname));
   std::string module_name =
-      base::UTF16ToUTF8(module_basename.RemoveFinalExtension().value());
+      base::WideToUTF8(module_basename.RemoveFinalExtension().value());
   EXPECT_NE(pdbname.find(module_name), std::string::npos);
   const std::string suffix(".pdb");
   EXPECT_EQ(
@@ -84,7 +84,7 @@
   ASSERT_TRUE(pe_image_reader.Initialize(process_reader,
                                          module.dll_base,
                                          module.size,
-                                         base::UTF16ToUTF8(module.name)));
+                                         base::WideToUTF8(module.name)));
 
   VS_FIXEDFILEINFO observed;
   const bool observed_rv = pe_image_reader.VSFixedFileInfo(&observed);
@@ -183,7 +183,7 @@
   EXPECT_GT(modules.size(), 2u);
 
   for (const auto& module : modules) {
-    SCOPED_TRACE(base::UTF16ToUTF8(module.name));
+    SCOPED_TRACE(base::WideToUTF8(module.name));
     TestVSFixedFileInfo(&process_reader, module, false);
   }
 }
diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc
index cafe7b4..4be2033 100644
--- a/snapshot/win/process_snapshot_win.cc
+++ b/snapshot/win/process_snapshot_win.cc
@@ -214,7 +214,7 @@
     // This is probably not strictly correct, but these are not localized so we
     // expect them all to be in ASCII range anyway. This will need to be more
     // carefully done if the object name is added.
-    snapshot.type_name = base::UTF16ToUTF8(handle.type_name);
+    snapshot.type_name = base::WideToUTF8(handle.type_name);
     snapshot.handle = handle.handle;
     snapshot.attributes = handle.attributes;
     snapshot.granted_access = handle.granted_access;
@@ -333,7 +333,7 @@
           uet.SizeOfImage,
           uet.CheckSum,
           uet.TimeDateStamp,
-          base::UTF16ToUTF8(base::StringPiece16(
+          base::WideToUTF8(base::WStringPiece(
               uet.ImageName,
               wcsnlen(uet.ImageName, base::size(uet.ImageName))))));
     }
diff --git a/snapshot/win/process_snapshot_win_test.cc b/snapshot/win/process_snapshot_win_test.cc
index 7192aa8..e1bfebb 100644
--- a/snapshot/win/process_snapshot_win_test.cc
+++ b/snapshot/win/process_snapshot_win_test.cc
@@ -35,7 +35,7 @@
   UUID done_uuid;
   done_uuid.InitializeWithNew();
   ScopedKernelHANDLE done(
-      CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str()));
+      CreateEvent(nullptr, true, false, done_uuid.ToWString().c_str()));
   ASSERT_TRUE(done.is_valid()) << ErrorMessage("CreateEvent");
 
   base::FilePath child_test_executable =
@@ -43,7 +43,7 @@
                                L"image_reader",
                                TestPaths::FileType::kExecutable,
                                architecture);
-  ChildLauncher child(child_test_executable, done_uuid.ToString16());
+  ChildLauncher child(child_test_executable, done_uuid.ToWString());
   ASSERT_NO_FATAL_FAILURE(child.Start());
 
   ScopedSetEvent set_done(done.get());
diff --git a/snapshot/win/system_snapshot_win.cc b/snapshot/win/system_snapshot_win.cc
index 778892c..e089021 100644
--- a/snapshot/win/system_snapshot_win.cc
+++ b/snapshot/win/system_snapshot_win.cc
@@ -410,8 +410,8 @@
       (time_zone_information.Bias + time_zone_information.StandardBias) * -60;
   *daylight_offset_seconds =
       (time_zone_information.Bias + time_zone_information.DaylightBias) * -60;
-  *standard_name = base::UTF16ToUTF8(time_zone_information.StandardName);
-  *daylight_name = base::UTF16ToUTF8(time_zone_information.DaylightName);
+  *standard_name = base::WideToUTF8(time_zone_information.StandardName);
+  *daylight_name = base::WideToUTF8(time_zone_information.DaylightName);
 }
 
 }  // namespace internal
diff --git a/test/filesystem.cc b/test/filesystem.cc
index 1d86e70..39b8648 100644
--- a/test/filesystem.cc
+++ b/test/filesystem.cc
@@ -111,8 +111,7 @@
 #elif defined(OS_WIN)
   if (GetFileAttributes(path.value().c_str()) == INVALID_FILE_ATTRIBUTES) {
     EXPECT_EQ(GetLastError(), static_cast<DWORD>(ERROR_FILE_NOT_FOUND))
-        << ErrorMessage("GetFileAttributes ")
-        << base::UTF16ToUTF8(path.value());
+        << ErrorMessage("GetFileAttributes ") << base::WideToUTF8(path.value());
     return false;
   }
   return true;
@@ -163,13 +162,13 @@
                                        flags,
                                        nullptr));
   if (!handle.is_valid()) {
-    PLOG(ERROR) << "CreateFile " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "CreateFile " << base::WideToUTF8(path.value());
     return false;
   }
 
   FILETIME filetime = TimespecToFiletimeEpoch(mtime);
   if (!SetFileTime(handle.get(), nullptr, nullptr, &filetime)) {
-    PLOG(ERROR) << "SetFileTime " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "SetFileTime " << base::WideToUTF8(path.value());
     return false;
   }
   return true;
diff --git a/test/multiprocess_exec_win.cc b/test/multiprocess_exec_win.cc
index 7aaa71e..08c4c17 100644
--- a/test/multiprocess_exec_win.cc
+++ b/test/multiprocess_exec_win.cc
@@ -125,7 +125,7 @@
   command_line_.clear();
   AppendCommandLineArgument(command_.value(), &command_line_);
   for (size_t i = 0; i < arguments_.size(); ++i) {
-    AppendCommandLineArgument(base::UTF8ToUTF16(arguments_[i]), &command_line_);
+    AppendCommandLineArgument(base::UTF8ToWide(arguments_[i]), &command_line_);
   }
 
   // Make pipes for child-to-parent and parent-to-child communication. Mark them
diff --git a/test/scoped_temp_dir_posix.cc b/test/scoped_temp_dir_posix.cc
index f8a1676..38aa4fb 100644
--- a/test/scoped_temp_dir_posix.cc
+++ b/test/scoped_temp_dir_posix.cc
@@ -19,6 +19,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <string>
+
 #include "base/check.h"
 #include "build/build_config.h"
 #include "gtest/gtest.h"
diff --git a/test/scoped_temp_dir_win.cc b/test/scoped_temp_dir_win.cc
index 499f1ef..10063dc 100644
--- a/test/scoped_temp_dir_win.cc
+++ b/test/scoped_temp_dir_win.cc
@@ -14,10 +14,12 @@
 
 #include "test/scoped_temp_dir.h"
 
+#include <wchar.h>
 #include <windows.h>
 
+#include <string>
+
 #include "base/check.h"
-#include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "gtest/gtest.h"
@@ -33,7 +35,7 @@
   DWORD path_len = GetTempPath(MAX_PATH, temp_path);
   PCHECK(path_len != 0) << "GetTempPath";
   base::FilePath system_temp_dir(temp_path);
-  base::string16 new_dir_name = base::UTF8ToUTF16(base::StringPrintf(
+  std::wstring new_dir_name = base::UTF8ToWide(base::StringPrintf(
       "crashpad.test.%lu.%s", GetCurrentProcessId(), RandomString().c_str()));
   return system_temp_dir.Append(new_dir_name);
 }
diff --git a/test/win/win_child_process.cc b/test/win/win_child_process.cc
index 14299e6..a203d9d 100644
--- a/test/win/win_child_process.cc
+++ b/test/win/win_child_process.cc
@@ -50,7 +50,7 @@
   switch_name_with_equals += "=";
   for (int i = 1; i < num_args; ++i) {
     const wchar_t* arg = args[i];
-    std::string arg_as_utf8 = base::UTF16ToUTF8(arg);
+    std::string arg_as_utf8 = base::WideToUTF8(arg);
     if (arg_as_utf8.compare(
             0, switch_name_with_equals.size(), switch_name_with_equals) == 0) {
       if (value)
@@ -189,7 +189,7 @@
       ::testing::UnitTest::GetInstance()->current_test_info();
   std::wstring command_line =
       TestPaths::Executable().value() +
-      base::UTF8ToUTF16(base::StringPrintf(
+      base::UTF8ToWide(base::StringPrintf(
           " --gtest_filter=%s.%s %s=0x%x|0x%x --gtest_also_run_disabled_tests",
           test_info->test_case_name(),
           test_info->name(),
diff --git a/tools/tool_support.cc b/tools/tool_support.cc
index 15deead..a4f923c 100644
--- a/tools/tool_support.cc
+++ b/tools/tool_support.cc
@@ -79,7 +79,7 @@
   std::vector<std::string> storage;
   storage.reserve(argc);
   for (int i = 0; i < argc; ++i) {
-    storage.push_back(base::UTF16ToUTF8(argv[i]));
+    storage.push_back(base::WideToUTF8(argv[i]));
     argv_as_utf8[i] = &storage[i][0];
   }
   argv_as_utf8[argc] = nullptr;
@@ -94,7 +94,7 @@
 #if defined(OS_POSIX)
   return path.as_string();
 #elif defined(OS_WIN)
-  return base::UTF8ToUTF16(path);
+  return base::UTF8ToWide(path);
 #endif  // OS_POSIX
 }
 
@@ -104,7 +104,7 @@
 #if defined(OS_POSIX)
   return file_path.value();
 #elif defined(OS_WIN)
-  return base::UTF16ToUTF8(file_path.value());
+  return base::WideToUTF8(file_path.value());
 #endif  // OS_POSIX
 }
 
diff --git a/util/file/file_io_win.cc b/util/file/file_io_win.cc
index 3d0d777..8586619 100644
--- a/util/file/file_io_win.cc
+++ b/util/file/file_io_win.cc
@@ -160,7 +160,7 @@
 FileHandle LoggingOpenFileForRead(const base::FilePath& path) {
   FileHandle file = OpenFileForRead(path);
   PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE)
-      << "CreateFile " << base::UTF16ToUTF8(path.value());
+      << "CreateFile " << base::WideToUTF8(path.value());
   return file;
 }
 
@@ -169,7 +169,7 @@
                                    FilePermissions permissions) {
   FileHandle file = OpenFileForWrite(path, mode, permissions);
   PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE)
-      << "CreateFile " << base::UTF16ToUTF8(path.value());
+      << "CreateFile " << base::WideToUTF8(path.value());
   return file;
 }
 
@@ -178,7 +178,7 @@
                                           FilePermissions permissions) {
   FileHandle file = OpenFileForReadAndWrite(path, mode, permissions);
   PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE)
-      << "CreateFile " << base::UTF16ToUTF8(path.value());
+      << "CreateFile " << base::WideToUTF8(path.value());
   return file;
 }
 
diff --git a/util/file/filesystem_win.cc b/util/file/filesystem_win.cc
index a465eac..d0270fc 100644
--- a/util/file/filesystem_win.cc
+++ b/util/file/filesystem_win.cc
@@ -34,7 +34,7 @@
                                             nullptr,
                                             0));
   if (!handle.is_valid()) {
-    PLOG(ERROR) << "FindFirstFileEx " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "FindFirstFileEx " << base::WideToUTF8(path.value());
     return false;
   }
 
@@ -44,7 +44,7 @@
 
 bool LoggingRemoveDirectoryImpl(const base::FilePath& path) {
   if (!RemoveDirectory(path.value().c_str())) {
-    PLOG(ERROR) << "RemoveDirectory " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "RemoveDirectory " << base::WideToUTF8(path.value());
     return false;
   }
   return true;
@@ -68,13 +68,13 @@
                    flags,
                    nullptr));
   if (!handle.is_valid()) {
-    PLOG(ERROR) << "CreateFile " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "CreateFile " << base::WideToUTF8(path.value());
     return false;
   }
 
   FILETIME file_mtime;
   if (!GetFileTime(handle.get(), nullptr, nullptr, &file_mtime)) {
-    PLOG(ERROR) << "GetFileTime " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "GetFileTime " << base::WideToUTF8(path.value());
     return false;
   }
   *mtime = FiletimeToTimespecEpoch(file_mtime);
@@ -89,12 +89,12 @@
   }
   if (may_reuse && GetLastError() == ERROR_ALREADY_EXISTS) {
     if (!IsDirectory(path, true)) {
-      LOG(ERROR) << base::UTF16ToUTF8(path.value()) << " not a directory";
+      LOG(ERROR) << base::WideToUTF8(path.value()) << " not a directory";
       return false;
     }
     return true;
   }
-  PLOG(ERROR) << "CreateDirectory " << base::UTF16ToUTF8(path.value());
+  PLOG(ERROR) << "CreateDirectory " << base::WideToUTF8(path.value());
   return false;
 }
 
@@ -103,8 +103,8 @@
   if (!MoveFileEx(source.value().c_str(),
                   dest.value().c_str(),
                   IsDirectory(source, false) ? 0 : MOVEFILE_REPLACE_EXISTING)) {
-    PLOG(ERROR) << "MoveFileEx" << base::UTF16ToUTF8(source.value()) << ", "
-                << base::UTF16ToUTF8(dest.value());
+    PLOG(ERROR) << "MoveFileEx" << base::WideToUTF8(source.value()) << ", "
+                << base::WideToUTF8(dest.value());
     return false;
   }
   return true;
@@ -113,7 +113,7 @@
 bool IsRegularFile(const base::FilePath& path) {
   DWORD fileattr = GetFileAttributes(path.value().c_str());
   if (fileattr == INVALID_FILE_ATTRIBUTES) {
-    PLOG(ERROR) << "GetFileAttributes " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value());
     return false;
   }
   if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0 ||
@@ -126,7 +126,7 @@
 bool IsDirectory(const base::FilePath& path, bool allow_symlinks) {
   DWORD fileattr = GetFileAttributes(path.value().c_str());
   if (fileattr == INVALID_FILE_ATTRIBUTES) {
-    PLOG(ERROR) << "GetFileAttributes " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value());
     return false;
   }
   if (!allow_symlinks && (fileattr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
@@ -145,7 +145,7 @@
   }
 
   if (!DeleteFile(path.value().c_str())) {
-    PLOG(ERROR) << "DeleteFile " << base::UTF16ToUTF8(path.value());
+    PLOG(ERROR) << "DeleteFile " << base::WideToUTF8(path.value());
     return false;
   }
   return true;
@@ -153,7 +153,7 @@
 
 bool LoggingRemoveDirectory(const base::FilePath& path) {
   if (IsSymbolicLink(path)) {
-    LOG(ERROR) << "Not a directory " << base::UTF16ToUTF8(path.value());
+    LOG(ERROR) << "Not a directory " << base::WideToUTF8(path.value());
     return false;
   }
   return LoggingRemoveDirectoryImpl(path);
diff --git a/util/misc/uuid.cc b/util/misc/uuid.cc
index 681a235..32ffea5 100644
--- a/util/misc/uuid.cc
+++ b/util/misc/uuid.cc
@@ -83,9 +83,11 @@
   return true;
 }
 
-bool UUID::InitializeFromString(const base::StringPiece16& string) {
-  return InitializeFromString(UTF16ToUTF8(string));
+#if defined(OS_WIN)
+bool UUID::InitializeFromString(const base::WStringPiece& string) {
+  return InitializeFromString(WideToUTF8(string));
 }
+#endif
 
 bool UUID::InitializeWithNew() {
 #if defined(OS_APPLE)
@@ -138,8 +140,8 @@
 }
 
 #if defined(OS_WIN)
-base::string16 UUID::ToString16() const {
-  return base::UTF8ToUTF16(ToString());
+std::wstring UUID::ToWString() const {
+  return base::UTF8ToWide(ToString());
 }
 #endif  // OS_WIN
 
diff --git a/util/misc/uuid.h b/util/misc/uuid.h
index af80122..291baa9 100644
--- a/util/misc/uuid.h
+++ b/util/misc/uuid.h
@@ -19,7 +19,6 @@
 
 #include <string>
 
-#include "base/strings/string16.h"
 #include "base/strings/string_piece.h"
 #include "build/build_config.h"
 
@@ -63,7 +62,9 @@
   //!     been initialized with the data. `false` if the string could not be
   //!     parsed, with the object state untouched.
   bool InitializeFromString(const base::StringPiece& string);
-  bool InitializeFromString(const base::StringPiece16& string);
+#if defined(OS_WIN) || DOXYGEN
+  bool InitializeFromString(const base::WStringPiece& string);
+#endif  // OS_WIN
 
   //! \brief Initializes the %UUID using a standard system facility to generate
   //!     the value.
@@ -85,8 +86,8 @@
   std::string ToString() const;
 
 #if defined(OS_WIN) || DOXYGEN
-  //! \brief The same as ToString, but returned as a string16.
-  base::string16 ToString16() const;
+  //! \brief The same as ToString, but returned as a wstring.
+  std::wstring ToWString() const;
 #endif  // OS_WIN
 
   // These fields are laid out according to RFC 4122 §4.1.2.
diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc
index 35f9ecd..ffa3c11 100644
--- a/util/misc/uuid_test.cc
+++ b/util/misc/uuid_test.cc
@@ -215,20 +215,6 @@
   uuid.InitializeFromString("5762C15D-50b5-4171-a2e9-7429C9EC6CAB");
   EXPECT_EQ(uuid.ToString(), "5762c15d-50b5-4171-a2e9-7429c9ec6cab");
 
-  // Test accepting a StringPiece16.
-  // clang-format off
-  static constexpr base::char16 kChar16UUID[] = {
-      'f', '3', '2', 'e', '5', 'b', 'd', 'c', '-',
-      '2', '6', '8', '1', '-',
-      '4', 'c', '7', '3', '-',
-      'a', '4', 'e', '6', '-',
-      '3', '3', '3', 'f', 'f', 'd', '3', '3', 'b', '3', '3', '3',
-  };
-  // clang-format on
-  EXPECT_TRUE(uuid.InitializeFromString(
-      base::StringPiece16(kChar16UUID, base::size(kChar16UUID))));
-  EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-333ffd33b333");
-
 #if defined(OS_WIN)
   // Test accepting a StringPiece16 via L"" literals on Windows.
   EXPECT_TRUE(
@@ -263,7 +249,7 @@
       base::ScopedGeneric<RPC_WSTR*, ScopedRpcStringFreeTraits>;
   ScopedRpcString scoped_system_string(&system_string);
 
-  EXPECT_EQ(uuid.ToString16(), reinterpret_cast<wchar_t*>(system_string));
+  EXPECT_EQ(uuid.ToWString(), reinterpret_cast<wchar_t*>(system_string));
 }
 
 #endif  // OS_WIN
diff --git a/util/net/http_transport_test.cc b/util/net/http_transport_test.cc
index a2a2e39..cf53450 100644
--- a/util/net/http_transport_test.cc
+++ b/util/net/http_transport_test.cc
@@ -42,8 +42,8 @@
 namespace {
 
 #if defined(OS_WIN)
-std::string ToUTF8IfWin(const base::string16& x) {
-  return base::UTF16ToUTF8(x);
+std::string ToUTF8IfWin(const std::wstring& x) {
+  return base::WideToUTF8(x);
 }
 #else
 std::string ToUTF8IfWin(const std::string& x) {
diff --git a/util/net/http_transport_win.cc b/util/net/http_transport_win.cc
index 06ecc4f..9618fbe 100644
--- a/util/net/http_transport_win.cc
+++ b/util/net/http_transport_win.cc
@@ -146,7 +146,7 @@
 }
 
 bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
-  ScopedHINTERNET session(WinHttpOpen(base::UTF8ToUTF16(UserAgent()).c_str(),
+  ScopedHINTERNET session(WinHttpOpen(base::UTF8ToWide(UserAgent()).c_str(),
                                       WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
                                       WINHTTP_NO_PROXY_NAME,
                                       WINHTTP_NO_PROXY_BYPASS,
@@ -171,7 +171,7 @@
   url_components.dwHostNameLength = 1;
   url_components.dwUrlPathLength = 1;
   url_components.dwExtraInfoLength = 1;
-  std::wstring url_wide(base::UTF8ToUTF16(url()));
+  std::wstring url_wide(base::UTF8ToWide(url()));
   // dwFlags = ICU_REJECT_USERPWD fails on XP.
   if (!WinHttpCrackUrl(
           url_wide.c_str(), 0, 0, &url_components)) {
@@ -206,7 +206,7 @@
 
   ScopedHINTERNET request(WinHttpOpenRequest(
       connect.get(),
-      base::UTF8ToUTF16(method()).c_str(),
+      base::UTF8ToWide(method()).c_str(),
       request_target.c_str(),
       nullptr,
       WINHTTP_NO_REFERER,
@@ -235,8 +235,8 @@
       chunked = !base::StringToSizeT(pair.second, &content_length);
       DCHECK(!chunked);
     } else {
-      std::wstring header_string = base::UTF8ToUTF16(pair.first) + L": " +
-                                   base::UTF8ToUTF16(pair.second) + L"\r\n";
+      std::wstring header_string = base::UTF8ToWide(pair.first) + L": " +
+                                   base::UTF8ToWide(pair.second) + L"\r\n";
       if (!WinHttpAddRequestHeaders(
               request.get(),
               header_string.c_str(),
diff --git a/util/stdlib/strlcpy.cc b/util/stdlib/strlcpy.cc
index 30bd20f..d0c5d63 100644
--- a/util/stdlib/strlcpy.cc
+++ b/util/stdlib/strlcpy.cc
@@ -28,9 +28,11 @@
 size_t c16lcpy(base::char16* destination,
                const base::char16* source,
                size_t length) {
-  HRESULT result = StringCchCopyW(destination, length, source);
+  const wchar_t* wsource = reinterpret_cast<const wchar_t*>(source);
+  HRESULT result =
+      StringCchCopyW(reinterpret_cast<wchar_t*>(destination), length, wsource);
   CHECK(result == S_OK || result == STRSAFE_E_INSUFFICIENT_BUFFER);
-  return wcslen(source);
+  return wcslen(wsource);
 }
 
 #elif defined(WCHAR_T_IS_UTF32)
diff --git a/util/stdlib/strlcpy_test.cc b/util/stdlib/strlcpy_test.cc
index bfb00fe..75efa43 100644
--- a/util/stdlib/strlcpy_test.cc
+++ b/util/stdlib/strlcpy_test.cc
@@ -39,12 +39,15 @@
   return base::c16memcmp(s1, s2, n);
 }
 #elif defined(WCHAR_T_IS_UTF16)
+
 size_t C16Len(const base::char16* s) {
-  return wcslen(s);
+  return wcslen(reinterpret_cast<const wchar_t*>(s));
 }
 
 int C16Memcmp(const base::char16* s1, const base::char16* s2, size_t n) {
-  return wmemcmp(s1, s2, n);
+  return wmemcmp(reinterpret_cast<const wchar_t*>(s1),
+                 reinterpret_cast<const wchar_t*>(s2),
+                 n);
 }
 #endif
 
diff --git a/util/win/get_function.cc b/util/win/get_function.cc
index f370f39..3d00a7a 100644
--- a/util/win/get_function.cc
+++ b/util/win/get_function.cc
@@ -23,7 +23,7 @@
 FARPROC GetFunctionInternal(
     const wchar_t* library, const char* function, bool required) {
   HMODULE module = LoadLibrary(library);
-  DPCHECK(!required || module) << "LoadLibrary " << base::UTF16ToUTF8(library);
+  DPCHECK(!required || module) << "LoadLibrary " << base::WideToUTF8(library);
   if (!module) {
     return nullptr;
   }
diff --git a/util/win/module_version.cc b/util/win/module_version.cc
index bd83538..fa54437 100644
--- a/util/win/module_version.cc
+++ b/util/win/module_version.cc
@@ -29,14 +29,13 @@
   DWORD size = GetFileVersionInfoSize(path.value().c_str(), nullptr);
   if (!size) {
     PLOG_IF(WARNING, GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND)
-        << "GetFileVersionInfoSize: " << base::UTF16ToUTF8(path.value());
+        << "GetFileVersionInfoSize: " << base::WideToUTF8(path.value());
     return false;
   }
 
   std::unique_ptr<uint8_t[]> data(new uint8_t[size]);
   if (!GetFileVersionInfo(path.value().c_str(), 0, size, data.get())) {
-    PLOG(WARNING) << "GetFileVersionInfo: "
-                  << base::UTF16ToUTF8(path.value());
+    PLOG(WARNING) << "GetFileVersionInfo: " << base::WideToUTF8(path.value());
     return false;
   }
 
diff --git a/util/win/process_info_test.cc b/util/win/process_info_test.cc
index 75f45db..b5de341 100644
--- a/util/win/process_info_test.cc
+++ b/util/win/process_info_test.cc
@@ -142,7 +142,7 @@
   done_uuid.InitializeWithNew();
 
   ScopedKernelHANDLE done(
-      CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str()));
+      CreateEvent(nullptr, true, false, done_uuid.ToWString().c_str()));
   ASSERT_TRUE(done.get()) << ErrorMessage("CreateEvent");
 
   base::FilePath child_test_executable =
@@ -151,7 +151,7 @@
                                TestPaths::FileType::kExecutable,
                                architecture);
   std::wstring args;
-  AppendCommandLineArgument(done_uuid.ToString16(), &args);
+  AppendCommandLineArgument(done_uuid.ToWString(), &args);
 
   ChildLauncher child(child_test_executable, args);
   ASSERT_NO_FATAL_FAILURE(child.Start());
@@ -559,9 +559,9 @@
   ASSERT_TRUE(scoped_key.is_valid());
 
   std::wstring mapping_name =
-      base::UTF8ToUTF16(base::StringPrintf("Local\\test_mapping_%lu_%s",
-                                           GetCurrentProcessId(),
-                                           RandomString().c_str()));
+      base::UTF8ToWide(base::StringPrintf("Local\\test_mapping_%lu_%s",
+                                          GetCurrentProcessId(),
+                                          RandomString().c_str()));
   ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE,
                                                nullptr,
                                                PAGE_READWRITE,
diff --git a/util/win/registration_protocol_win.cc b/util/win/registration_protocol_win.cc
index 64ed518..7e04cda 100644
--- a/util/win/registration_protocol_win.cc
+++ b/util/win/registration_protocol_win.cc
@@ -30,8 +30,7 @@
 
 namespace {
 
-void* GetSecurityDescriptorWithUser(const base::char16* sddl_string,
-                                    size_t* size) {
+void* GetSecurityDescriptorWithUser(const wchar_t* sddl_string, size_t* size) {
   if (size)
     *size = 0;
 
@@ -71,7 +70,7 @@
 
 }  // namespace
 
-bool SendToCrashHandlerServer(const base::string16& pipe_name,
+bool SendToCrashHandlerServer(const std::wstring& pipe_name,
                               const ClientToServerMessage& message,
                               ServerToClientMessage* response) {
   // Retry CreateFile() in a loop. If the handler isn’t actively waiting in
diff --git a/util/win/registration_protocol_win.h b/util/win/registration_protocol_win.h
index ef8bebc..690d612 100644
--- a/util/win/registration_protocol_win.h
+++ b/util/win/registration_protocol_win.h
@@ -18,7 +18,8 @@
 #include <windows.h>
 #include <stdint.h>
 
-#include "base/strings/string16.h"
+#include <string>
+
 #include "util/win/address_types.h"
 
 namespace crashpad {
@@ -130,7 +131,7 @@
 //! CrashpadClient::SetHandler().
 //!
 //! \sa CrashpadClient::SetHandler()
-bool SendToCrashHandlerServer(const base::string16& pipe_name,
+bool SendToCrashHandlerServer(const std::wstring& pipe_name,
                               const ClientToServerMessage& message,
                               ServerToClientMessage* response);
 
diff --git a/util/win/registration_protocol_win_test.cc b/util/win/registration_protocol_win_test.cc
index ecbea34..2cea7d2 100644
--- a/util/win/registration_protocol_win_test.cc
+++ b/util/win/registration_protocol_win_test.cc
@@ -17,13 +17,13 @@
 #include <aclapi.h>
 #include <sddl.h>
 #include <string.h>
+#include <wchar.h>
 #include <windows.h>
 
 #include <vector>
 
 #include "base/logging.h"
 #include "base/notreached.h"
-#include "base/strings/string16.h"
 #include "gtest/gtest.h"
 #include "test/errors.h"
 #include "util/win/scoped_handle.h"
@@ -33,21 +33,21 @@
 namespace test {
 namespace {
 
-base::string16 GetStringFromSid(PSID sid) {
+std::wstring GetStringFromSid(PSID sid) {
   LPWSTR sid_str;
   if (!ConvertSidToStringSid(sid, &sid_str)) {
     PLOG(ERROR) << "ConvertSidToStringSid";
-    return base::string16();
+    return std::wstring();
   }
   ScopedLocalAlloc sid_str_ptr(sid_str);
   return sid_str;
 }
 
-base::string16 GetUserSidString() {
+std::wstring GetUserSidString() {
   HANDLE token_handle;
   if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token_handle)) {
     PLOG(ERROR) << "OpenProcessToken";
-    return base::string16();
+    return std::wstring();
   }
 
   ScopedKernelHANDLE token(token_handle);
@@ -55,14 +55,14 @@
   GetTokenInformation(token.get(), TokenUser, nullptr, 0, &user_size);
   if (user_size == 0) {
     PLOG(ERROR) << "GetTokenInformation Size";
-    return base::string16();
+    return std::wstring();
   }
 
   std::vector<char> user(user_size);
   if (!GetTokenInformation(
           token.get(), TokenUser, user.data(), user_size, &user_size)) {
     PLOG(ERROR) << "GetTokenInformation";
-    return base::string16();
+    return std::wstring();
   }
 
   TOKEN_USER* user_ptr = reinterpret_cast<TOKEN_USER*>(user.data());
@@ -73,7 +73,7 @@
               DWORD index,
               BYTE check_ace_type,
               ACCESS_MASK check_mask,
-              const base::string16& check_sid) {
+              const std::wstring& check_sid) {
   ASSERT_FALSE(check_sid.empty());
   void* ace_ptr;
   ASSERT_TRUE(GetAce(acl, index, &ace_ptr));