[code coverage] Added Windows-specific path for sandbox file injection.

Also deleted an unnecessary include of unistd.h.

Bug: 990480
Change-Id: I5caa9a1dabcbb9e90bab1372bc38b8079c5a640e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1797644
Reviewed-by: Kentaro Hara <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Commit-Queue: Sajjad Mirza <[email protected]>
Cr-Commit-Position: refs/heads/master@{#695848}
diff --git a/content/common/coverage_utils.cc b/content/common/coverage_utils.cc
index 00794b2..609f503 100644
--- a/content/common/coverage_utils.cc
+++ b/content/common/coverage_utils.cc
@@ -15,8 +15,11 @@
 #include "base/path_service.h"
 #include "base/rand_util.h"
 #include "base/strings/strcat.h"
+#include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
+#include "build/build_config.h"
 
 namespace content {
 
@@ -26,7 +29,11 @@
   std::string prof_template;
   base::FilePath path;
   if (env->GetVar("LLVM_PROFILE_FILE", &prof_template)) {
+#if defined(OS_WIN)
+    path = base::FilePath(base::UTF8ToUTF16(prof_template)).DirName();
+#else
     path = base::FilePath(prof_template).DirName();
+#endif
     base::CreateDirectory(path);
   } else {
     base::PathService::Get(base::DIR_CURRENT, &path);
@@ -37,7 +44,11 @@
   int pool_index = base::RandInt(0, 3);
   std::string filename = base::StrCat(
       {"child_pool-", base::NumberToString(pool_index), ".profraw"});
+#if defined(OS_WIN)
+  path = path.Append(base::UTF8ToUTF16(filename));
+#else
   path = path.Append(filename);
+#endif
   uint32_t flags = base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ |
                    base::File::FLAG_WRITE;