Use 31 instead of 15-bit int for temp dir names

unit_tests creates two temporary directories for each test process. When
run with --test-launcher-batch-limit=1 this means about 21,800
directories, 10,900 of each naming pattern.

This is a problem because CreateTemporaryDirInDir uses a 15-bit random
number to generate directory names. After we have generated just 214
names there is a greater than 50% probability of a collision and after
10,900 names there will have been thousands of collisions. These
collisions are handled but they harm startup performance (especially
when running with --test-launcher-batch-limit=1) and if we add enough
tests or if directory cleanup isn't perfect then the slowdown can go
asymptotic.

Using a GUID would avoid all collisions but causes failures because
a GUID is 36 characters - 31 longer - and we sometimes have nested
temp directories. The extra 62 characters hits path length limits. Using
31-bit ints means the dir names are only 5 characters longer.

Bug: 955038, 956723
Change-Id: Id8d921eba0a59a3e4031470ccb5ae5368f6144db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1584743
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654287}
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
index 69207dc..6d9e5178 100644
--- a/base/files/file_util_win.cc
+++ b/base/files/file_util_win.cc
@@ -572,7 +572,7 @@
     new_dir_name.append(NumberToString16(GetCurrentProcId()));
     new_dir_name.push_back('_');
     new_dir_name.append(
-        NumberToString16(RandInt(0, std::numeric_limits<int16_t>::max())));
+        NumberToString16(RandInt(0, std::numeric_limits<int32_t>::max())));
 
     path_to_create = base_dir.Append(new_dir_name);
     if (::CreateDirectory(as_wcstr(path_to_create.value()), NULL)) {