Revert "Move GetFileSize() to ext/base"

This reverts commit b2b829cabe0928f33e604c99d80153b67e33f00c.

Reason for revert: Doesn't build on windows

Change-Id: I55516922fc7727f5206b02772b3653d7c683aafb
diff --git a/include/perfetto/ext/base/file_utils.h b/include/perfetto/ext/base/file_utils.h
index b3d8978..a99d4a3 100644
--- a/include/perfetto/ext/base/file_utils.h
+++ b/include/perfetto/ext/base/file_utils.h
@@ -20,7 +20,6 @@
 #include <fcntl.h>  // For mode_t & O_RDONLY/RDWR. Exists also on Windows.
 #include <stddef.h>
 
-#include <optional>
 #include <string>
 #include <vector>
 
@@ -101,9 +100,6 @@
 base::Status SetFilePermissions(const std::string& path,
                                 const std::string& group_name,
                                 const std::string& mode_bits);
-
-std::optional<size_t> GetFileSize(const std::string& path);
-
 }  // namespace base
 }  // namespace perfetto
 
diff --git a/src/base/file_utils.cc b/src/base/file_utils.cc
index 9ea7c55..0969515 100644
--- a/src/base/file_utils.cc
+++ b/src/base/file_utils.cc
@@ -408,34 +408,5 @@
 #endif
 }
 
-std::optional<size_t> GetFileSize(const std::string& file_path) {
-#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
-  HANDLE file =
-      CreateFileA(file_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr,
-                  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
-  if (file == INVALID_HANDLE_VALUE) {
-    return std::nullopt;
-  }
-  LARGE_INTEGER file_size;
-  file_size.QuadPart = 0;
-  std::optional res;
-  if (GetFileSizeEx(file, &file_size)) {
-    res = static_cast<size_t>(file_size.QuadPart);
-  }
-  CloseHandle(file);
-  return res;
-#else
-  base::ScopedFile fd(base::OpenFile(file_path, O_RDONLY | O_CLOEXEC));
-  if (!fd) {
-    return std::nullopt;
-  }
-  struct stat buf;
-  if (fstat(*fd, &buf) == -1) {
-    return std::nullopt;
-  }
-  return static_cast<size_t>(buf.st_size);
-#endif
-}
-
 }  // namespace base
 }  // namespace perfetto
diff --git a/src/profiling/symbolizer/filesystem.h b/src/profiling/symbolizer/filesystem.h
index 8009eaa..d9cf87c 100644
--- a/src/profiling/symbolizer/filesystem.h
+++ b/src/profiling/symbolizer/filesystem.h
@@ -23,6 +23,7 @@
 namespace profiling {
 
 using FileCallback = std::function<void(const char*, size_t)>;
+size_t GetFileSize(const std::string& file_path);
 bool WalkDirectories(std::vector<std::string> dirs, FileCallback fn);
 
 }  // namespace profiling
diff --git a/src/profiling/symbolizer/filesystem_posix.cc b/src/profiling/symbolizer/filesystem_posix.cc
index d0c8bed..cc983e2 100644
--- a/src/profiling/symbolizer/filesystem_posix.cc
+++ b/src/profiling/symbolizer/filesystem_posix.cc
@@ -51,10 +51,25 @@
   return true;
 }
 
+size_t GetFileSize(const std::string& file_path) {
+  base::ScopedFile fd(base::OpenFile(file_path, O_RDONLY | O_CLOEXEC));
+  if (!fd) {
+    PERFETTO_PLOG("Failed to get file size %s", file_path.c_str());
+    return 0;
+  }
+  struct stat buf;
+  if (fstat(*fd, &buf) == -1) {
+    return 0;
+  }
+  return static_cast<size_t>(buf.st_size);
+}
 #else
 bool WalkDirectories(std::vector<std::string>, FileCallback) {
   return false;
 }
+size_t GetFileSize(const std::string&) {
+  return 0;
+}
 #endif
 
 }  // namespace profiling
diff --git a/src/profiling/symbolizer/filesystem_windows.cc b/src/profiling/symbolizer/filesystem_windows.cc
index 6a9cbef..04cd685 100644
--- a/src/profiling/symbolizer/filesystem_windows.cc
+++ b/src/profiling/symbolizer/filesystem_windows.cc
@@ -52,6 +52,23 @@
   return true;
 }
 
+size_t GetFileSize(const std::string& file_path) {
+  HANDLE file =
+      CreateFileA(file_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr,
+                  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+  if (file == INVALID_HANDLE_VALUE) {
+    PERFETTO_PLOG("Failed to get file size %s", file_path.c_str());
+    return 0;
+  }
+  LARGE_INTEGER file_size;
+  file_size.QuadPart = 0;
+  if (!GetFileSizeEx(file, &file_size)) {
+    PERFETTO_PLOG("Failed to get file size %s", file_path.c_str());
+  }
+  CloseHandle(file);
+  return static_cast<size_t>(file_size.QuadPart);
+}
+
 }  // namespace profiling
 }  // namespace perfetto
 
diff --git a/src/profiling/symbolizer/local_symbolizer.cc b/src/profiling/symbolizer/local_symbolizer.cc
index 9ade8b4..0382556 100644
--- a/src/profiling/symbolizer/local_symbolizer.cc
+++ b/src/profiling/symbolizer/local_symbolizer.cc
@@ -352,18 +352,14 @@
     return std::nullopt;
   }
   // Openfile opens the file with an exclusive lock on windows.
-  std::optional<size_t> size = base::GetFileSize(symbol_file);
-  if (!size.has_value()) {
-    PERFETTO_PLOG("Failed to get file size %s", symbol_file.c_str());
-    return std::nullopt;
-  }
+  size_t size = GetFileSize(symbol_file);
 
-  if (*size == 0) {
+  if (size == 0) {
     return std::nullopt;
   }
 
   std::optional<BuildIdAndLoadBias> build_id_and_load_bias =
-      GetBuildIdAndLoadBias(symbol_file.c_str(), *size);
+      GetBuildIdAndLoadBias(symbol_file.c_str(), size);
   if (!build_id_and_load_bias)
     return std::nullopt;
   if (build_id_and_load_bias->build_id != build_id) {