Remove PathService and base_paths, add simple src/exe_path

Change-Id: I65353d1ed955358b368bd114625c1270d86a55c7
Reviewed-on: https://gn-review.googlesource.com/1544
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/base/base_paths.cc b/base/base_paths.cc
deleted file mode 100644
index e3f322e..0000000
--- a/base/base_paths.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/base_paths.h"
-
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/path_service.h"
-
-namespace base {
-
-bool PathProvider(int key, FilePath* result) {
-  // NOTE: DIR_CURRENT is a special case in PathService::Get
-
-  switch (key) {
-    case DIR_EXE:
-      if (!PathService::Get(FILE_EXE, result))
-        return false;
-      *result = result->DirName();
-      return true;
-    case DIR_MODULE:
-      if (!PathService::Get(FILE_MODULE, result))
-        return false;
-      *result = result->DirName();
-      return true;
-    case DIR_ASSETS:
-      return PathService::Get(DIR_MODULE, result);
-    case DIR_TEMP:
-      return GetTempDir(result);
-    case base::DIR_HOME:
-      *result = GetHomeDir();
-      return true;
-    case DIR_TEST_DATA: {
-      FilePath test_data_path;
-      if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path))
-        return false;
-      test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base"));
-      test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test"));
-      test_data_path = test_data_path.Append(FILE_PATH_LITERAL("data"));
-      if (!PathExists(test_data_path))  // We don't want to create this.
-        return false;
-      *result = test_data_path;
-      return true;
-    }
-    default:
-      return false;
-  }
-}
-
-}  // namespace base
diff --git a/base/base_paths.h b/base/base_paths.h
deleted file mode 100644
index b67e3db..0000000
--- a/base/base_paths.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_PATHS_H_
-#define BASE_BASE_PATHS_H_
-
-// This file declares path keys for the base module.  These can be used with
-// the PathService to access various special directories and files.
-
-#include "build_config.h"
-
-#if defined(OS_WIN)
-#include "base/base_paths_win.h"
-#elif defined(OS_MACOSX)
-#include "base/base_paths_mac.h"
-#elif defined(OS_ANDROID)
-#include "base/base_paths_android.h"
-#endif
-
-#if defined(OS_POSIX) || defined(OS_FUCHSIA)
-#include "base/base_paths_posix.h"
-#endif
-
-namespace base {
-
-enum BasePathKey {
-  PATH_START = 0,
-
-  DIR_CURRENT,       // Current directory.
-  DIR_EXE,           // Directory containing FILE_EXE.
-  DIR_MODULE,        // Directory containing FILE_MODULE.
-  DIR_ASSETS,        // Directory that contains application assets.
-  DIR_TEMP,          // Temporary directory.
-  DIR_HOME,          // User's root home directory. On Windows this will look
-                     // like "C:\Users\<user>"  which isn't necessarily a great
-                     // place to put files.
-  FILE_EXE,          // Path and filename of the current executable.
-  FILE_MODULE,       // Path and filename of the module containing the code for
-                     // the PathService (which could differ from FILE_EXE if the
-                     // PathService were compiled into a shared object, for
-                     // example).
-  DIR_SOURCE_ROOT,   // Returns the root of the source tree. This key is useful
-                     // for tests that need to locate various resources. It
-                     // should not be used outside of test code.
-  DIR_USER_DESKTOP,  // The current user's Desktop.
-
-  DIR_TEST_DATA,  // Used only for testing.
-
-  PATH_END
-};
-
-}  // namespace base
-
-#endif  // BASE_BASE_PATHS_H_
diff --git a/base/base_paths_mac.h b/base/base_paths_mac.h
deleted file mode 100644
index ac75402..0000000
--- a/base/base_paths_mac.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_PATHS_MAC_H_
-#define BASE_BASE_PATHS_MAC_H_
-
-// This file declares Mac-specific path keys for the base module.
-// These can be used with the PathService to access various special
-// directories and files.
-
-namespace base {
-
-enum {
-  PATH_MAC_START = 200,
-
-  DIR_APP_DATA,  // ~/Library/Application Support
-
-  PATH_MAC_END
-};
-
-}  // namespace base
-
-#endif  // BASE_BASE_PATHS_MAC_H_
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
deleted file mode 100644
index 6eb6e07..0000000
--- a/base/base_paths_mac.mm
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Defines base::PathProviderMac which replaces base::PathProviderPosix for Mac
-// in base/path_service.cc.
-
-#include <dlfcn.h>
-#import <Foundation/Foundation.h>
-#include <mach-o/dyld.h>
-#include <stdint.h>
-
-#include "base/base_paths.h"
-#include "base/compiler_specific.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/mac/bundle_locations.h"
-#include "base/mac/foundation_util.h"
-#include "base/path_service.h"
-#include "base/strings/string_util.h"
-#include "base/threading/thread_restrictions.h"
-#include "build_config.h"
-
-namespace {
-
-void GetNSExecutablePath(base::FilePath* path) {
-  DCHECK(path);
-  // Executable path can have relative references ("..") depending on
-  // how the app was launched.
-  uint32_t executable_length = 0;
-  _NSGetExecutablePath(NULL, &executable_length);
-  DCHECK_GT(executable_length, 1u);
-  std::string executable_path;
-  int rv = _NSGetExecutablePath(
-      base::WriteInto(&executable_path, executable_length),
-                      &executable_length);
-  DCHECK_EQ(rv, 0);
-
-  // _NSGetExecutablePath may return paths containing ./ or ../ which makes
-  // FilePath::DirName() work incorrectly, convert it to absolute path so that
-  // paths such as DIR_SOURCE_ROOT can work, since we expect absolute paths to
-  // be returned here.
-  // TODO(bauerb): http://crbug.com/259796, http://crbug.com/373477
-  base::ThreadRestrictions::ScopedAllowIO allow_io;
-  *path = base::MakeAbsoluteFilePath(base::FilePath(executable_path));
-}
-
-// Returns true if the module for |address| is found. |path| will contain
-// the path to the module. Note that |path| may not be absolute.
-bool GetModulePathForAddress(base::FilePath* path,
-                             const void* address) WARN_UNUSED_RESULT;
-
-bool GetModulePathForAddress(base::FilePath* path, const void* address) {
-  Dl_info info;
-  if (dladdr(address, &info) == 0)
-    return false;
-  *path = base::FilePath(info.dli_fname);
-  return true;
-}
-
-}  // namespace
-
-namespace base {
-
-bool PathProviderMac(int key, base::FilePath* result) {
-  switch (key) {
-    case base::FILE_EXE:
-      GetNSExecutablePath(result);
-      return true;
-    case base::FILE_MODULE:
-      return GetModulePathForAddress(result,
-          reinterpret_cast<const void*>(&base::PathProviderMac));
-    case base::DIR_APP_DATA: {
-      bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory,
-                                                 result);
-#if defined(OS_IOS)
-      // On IOS, this directory does not exist unless it is created explicitly.
-      if (success && !base::PathExists(*result))
-        success = base::CreateDirectory(*result);
-#endif  // defined(OS_IOS)
-      return success;
-    }
-    case base::DIR_SOURCE_ROOT:
-      // Go through PathService to catch overrides.
-      if (!PathService::Get(base::FILE_EXE, result))
-        return false;
-
-      // Start with the executable's directory.
-      *result = result->DirName();
-
-#if !defined(OS_IOS)
-      if (base::mac::AmIBundled()) {
-        // The bundled app executables (Chromium, TestShell, etc) live five
-        // levels down, eg:
-        // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium
-        *result = result->DirName().DirName().DirName().DirName().DirName();
-      } else {
-        // Unit tests execute two levels deep from the source root, eg:
-        // src/xcodebuild/{Debug|Release}/base_unittests
-        *result = result->DirName().DirName();
-      }
-#endif
-      return true;
-    case base::DIR_USER_DESKTOP:
-#if defined(OS_IOS)
-      // iOS does not have desktop directories.
-      NOTIMPLEMENTED();
-      return false;
-#else
-      return base::mac::GetUserDirectory(NSDesktopDirectory, result);
-#endif
-    case base::DIR_ASSETS:
-      if (!base::mac::AmIBundled()) {
-        return PathService::Get(base::DIR_MODULE, result);
-      }
-      *result = base::mac::FrameworkBundlePath().Append(
-          FILE_PATH_LITERAL("Resources"));
-      return true;
-    case base::DIR_CACHE:
-      return base::mac::GetUserDirectory(NSCachesDirectory, result);
-    default:
-      return false;
-  }
-}
-
-}  // namespace base
diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc
deleted file mode 100644
index 2319755..0000000
--- a/base/base_paths_posix.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Defines base::PathProviderPosix, default path provider on POSIX OSes that
-// don't have their own base_paths_OS.cc implementation (i.e. all but Mac and
-// Android).
-
-#include "base/base_paths.h"
-
-#include <limits.h>
-#include <stddef.h>
-
-#include <memory>
-#include <ostream>
-#include <string>
-
-#include "base/environment.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/path_service.h"
-#include "base/process/process_metrics.h"
-#include "build_config.h"
-
-#if defined(OS_FREEBSD)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#elif defined(OS_SOLARIS) || defined(OS_AIX)
-#include <stdlib.h>
-#endif
-
-namespace base {
-
-bool PathProviderPosix(int key, FilePath* result) {
-  switch (key) {
-    case FILE_EXE:
-    case FILE_MODULE: {  // TODO(evanm): is this correct?
-#if defined(OS_LINUX)
-      FilePath bin_dir;
-      if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) {
-        NOTREACHED() << "Unable to resolve " << kProcSelfExe << ".";
-        return false;
-      }
-      *result = bin_dir;
-      return true;
-#elif defined(OS_FREEBSD)
-      int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
-      char bin_dir[PATH_MAX + 1];
-      size_t length = sizeof(bin_dir);
-      // Upon return, |length| is the number of bytes written to |bin_dir|
-      // including the string terminator.
-      int error = sysctl(name, 4, bin_dir, &length, NULL, 0);
-      if (error < 0 || length <= 1) {
-        NOTREACHED() << "Unable to resolve path.";
-        return false;
-      }
-      *result = FilePath(FilePath::StringType(bin_dir, length - 1));
-      return true;
-#elif defined(OS_SOLARIS)
-      char bin_dir[PATH_MAX + 1];
-      if (realpath(getexecname(), bin_dir) == NULL) {
-        NOTREACHED() << "Unable to resolve " << getexecname() << ".";
-        return false;
-      }
-      *result = FilePath(bin_dir);
-      return true;
-#elif defined(OS_OPENBSD) || defined(OS_AIX)
-      // There is currently no way to get the executable path on OpenBSD
-      char* cpath;
-      if ((cpath = getenv("CHROME_EXE_PATH")) != NULL)
-        *result = FilePath(cpath);
-      else
-        *result = FilePath("/usr/local/chrome/chrome");
-      return true;
-#endif
-    }
-    case DIR_SOURCE_ROOT: {
-      // Allow passing this in the environment, for more flexibility in build
-      // tree configurations (sub-project builds, gyp --output_dir, etc.)
-      std::unique_ptr<Environment> env(Environment::Create());
-      std::string cr_source_root;
-      FilePath path;
-      if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) {
-        path = FilePath(cr_source_root);
-        if (PathExists(path)) {
-          *result = path;
-          return true;
-        }
-        DLOG(WARNING) << "CR_SOURCE_ROOT is set, but it appears to not "
-                      << "point to a directory.";
-      }
-      // On POSIX, unit tests execute two levels deep from the source root.
-      // For example:  out/{Debug|Release}/net_unittest
-      if (PathService::Get(DIR_EXE, &path)) {
-        *result = path.DirName().DirName();
-        return true;
-      }
-
-      DLOG(ERROR) << "Couldn't find your source root.  "
-                  << "Try running from your chromium/src directory.";
-      return false;
-    }
-  }
-  return false;
-}
-
-}  // namespace base
diff --git a/base/base_paths_posix.h b/base/base_paths_posix.h
deleted file mode 100644
index ef002ae..0000000
--- a/base/base_paths_posix.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_PATHS_POSIX_H_
-#define BASE_BASE_PATHS_POSIX_H_
-
-// This file declares windows-specific path keys for the base module.
-// These can be used with the PathService to access various special
-// directories and files.
-
-namespace base {
-
-enum {
-  PATH_POSIX_START = 400,
-
-  DIR_CACHE,    // Directory where to put cache data.  Note this is
-                // *not* where the browser cache lives, but the
-                // browser cache can be a subdirectory.
-                // This is $XDG_CACHE_HOME on Linux and
-                // ~/Library/Caches on Mac.
-  PATH_POSIX_END
-};
-
-}  // namespace base
-
-#endif  // BASE_BASE_PATHS_POSIX_H_
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
deleted file mode 100644
index e7e5d1f..0000000
--- a/base/base_paths_win.cc
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windows.h>
-#include <KnownFolders.h>
-#include <shlobj.h>
-
-#include "base/base_paths.h"
-#include "base/environment.h"
-#include "base/files/file_path.h"
-#include "base/path_service.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/win/current_module.h"
-#include "base/win/scoped_co_mem.h"
-#include "base/win/windows_version.h"
-
-using base::FilePath;
-
-namespace base {
-
-bool PathProviderWin(int key, FilePath* result) {
-  // We need to go compute the value. It would be nice to support paths with
-  // names longer than MAX_PATH, but the system functions don't seem to be
-  // designed for it either, with the exception of GetTempPath (but other
-  // things will surely break if the temp path is too long, so we don't bother
-  // handling it.
-  wchar_t system_buffer[MAX_PATH];
-  system_buffer[0] = 0;
-
-  FilePath cur;
-  switch (key) {
-    case base::FILE_EXE:
-      if (GetModuleFileName(NULL, system_buffer, MAX_PATH) == 0)
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::FILE_MODULE: {
-      // the resource containing module is assumed to be the one that
-      // this code lives in, whether that's a dll or exe
-      if (GetModuleFileName(CURRENT_MODULE(), system_buffer, MAX_PATH) == 0)
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    }
-    case base::DIR_WINDOWS:
-      GetWindowsDirectory(system_buffer, MAX_PATH);
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_SYSTEM:
-      GetSystemDirectory(system_buffer, MAX_PATH);
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_PROGRAM_FILESX86:
-      if (base::win::OSInfo::GetInstance()->architecture() !=
-          base::win::OSInfo::X86_ARCHITECTURE) {
-        if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL,
-                                   SHGFP_TYPE_CURRENT, system_buffer)))
-          return false;
-        cur = FilePath(system_buffer);
-        break;
-      }
-      // Fall through to base::DIR_PROGRAM_FILES if we're on an X86 machine.
-      FALLTHROUGH;
-    case base::DIR_PROGRAM_FILES:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_PROGRAM_FILES6432:
-#if !defined(_WIN64)
-      if (base::win::OSInfo::GetInstance()->wow64_status() ==
-          base::win::OSInfo::WOW64_ENABLED) {
-        std::unique_ptr<base::Environment> env(base::Environment::Create());
-        std::string programfiles_w6432;
-        // 32-bit process running in WOW64 sets ProgramW6432 environment
-        // variable. See
-        // https://msdn.microsoft.com/library/windows/desktop/aa384274.aspx.
-        if (!env->GetVar("ProgramW6432", &programfiles_w6432))
-          return false;
-        // GetVar returns UTF8 - convert back to Wide.
-        cur = FilePath(UTF8ToWide(programfiles_w6432));
-        break;
-      }
-#endif
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_IE_INTERNET_CACHE:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_COMMON_START_MENU:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_PROGRAMS, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_START_MENU:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAMS, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_APP_DATA:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
-                                 system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_COMMON_APP_DATA:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_LOCAL_APP_DATA:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer)))
-        return false;
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_SOURCE_ROOT: {
-      FilePath executableDir;
-      // On Windows, unit tests execute two levels deep from the source root.
-      // For example:  chrome/{Debug|Release}/ui_tests.exe
-      PathService::Get(base::DIR_EXE, &executableDir);
-      cur = executableDir.DirName().DirName();
-      break;
-    }
-    case base::DIR_APP_SHORTCUTS: {
-      if (win::GetVersion() < win::VERSION_WIN8)
-        return false;
-
-      base::win::ScopedCoMem<wchar_t> path_buf;
-      if (FAILED(SHGetKnownFolderPath(FOLDERID_ApplicationShortcuts, 0, NULL,
-                                      &path_buf)))
-        return false;
-
-      cur = FilePath(string16(path_buf));
-      break;
-    }
-    case base::DIR_USER_DESKTOP:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer))) {
-        return false;
-      }
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_COMMON_DESKTOP:
-      if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, NULL,
-                                 SHGFP_TYPE_CURRENT, system_buffer))) {
-        return false;
-      }
-      cur = FilePath(system_buffer);
-      break;
-    case base::DIR_USER_QUICK_LAUNCH:
-      if (!PathService::Get(base::DIR_APP_DATA, &cur))
-        return false;
-      // According to various sources, appending
-      // "Microsoft\Internet Explorer\Quick Launch" to %appdata% is the only
-      // reliable way to get the quick launch folder across all versions of
-      // Windows.
-      // http://stackoverflow.com/questions/76080/how-do-you-reliably-get-the-quick-
-      // http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0901.mspx
-      cur = cur.Append(FILE_PATH_LITERAL("Microsoft"))
-                .Append(FILE_PATH_LITERAL("Internet Explorer"))
-                .Append(FILE_PATH_LITERAL("Quick Launch"));
-      break;
-    case base::DIR_TASKBAR_PINS:
-      if (!PathService::Get(base::DIR_USER_QUICK_LAUNCH, &cur))
-        return false;
-      cur = cur.Append(FILE_PATH_LITERAL("User Pinned"))
-                .Append(FILE_PATH_LITERAL("TaskBar"));
-      break;
-    case base::DIR_IMPLICIT_APP_SHORTCUTS:
-      if (!PathService::Get(base::DIR_USER_QUICK_LAUNCH, &cur))
-        return false;
-      cur = cur.Append(FILE_PATH_LITERAL("User Pinned"))
-                .Append(FILE_PATH_LITERAL("ImplicitAppShortcuts"));
-      break;
-    case base::DIR_WINDOWS_FONTS:
-      if (FAILED(SHGetFolderPath(
-              NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, system_buffer))) {
-        return false;
-      }
-      cur = FilePath(system_buffer);
-      break;
-    default:
-      return false;
-  }
-
-  *result = cur;
-  return true;
-}
-
-}  // namespace base
diff --git a/base/base_paths_win.h b/base/base_paths_win.h
deleted file mode 100644
index 2db16a6..0000000
--- a/base/base_paths_win.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_PATHS_WIN_H_
-#define BASE_BASE_PATHS_WIN_H_
-
-// This file declares windows-specific path keys for the base module.
-// These can be used with the PathService to access various special
-// directories and files.
-
-namespace base {
-
-enum {
-  PATH_WIN_START = 100,
-
-  DIR_WINDOWS,  // Windows directory, usually "c:\windows"
-  DIR_SYSTEM,   // Usually c:\windows\system32"
-  //                         32-bit     32-bit on 64-bit   64-bit on 64-bit
-  // DIR_PROGRAM_FILES         1               2                  1
-  // DIR_PROGRAM_FILESX86      1               2                  2
-  // DIR_PROGRAM_FILES6432     1               1                  1
-  // 1 - C:\Program Files   2 - C:\Program Files (x86)
-  DIR_PROGRAM_FILES,      // See table above.
-  DIR_PROGRAM_FILESX86,   // See table above.
-  DIR_PROGRAM_FILES6432,  // See table above.
-
-  DIR_IE_INTERNET_CACHE,       // Temporary Internet Files directory.
-  DIR_COMMON_START_MENU,       // Usually "C:\ProgramData\Microsoft\Windows\
-                               // Start Menu\Programs"
-  DIR_START_MENU,              // Usually "C:\Users\<user>\AppData\Roaming\
-                               // Microsoft\Windows\Start Menu\Programs"
-  DIR_APP_DATA,                // Application Data directory under the user
-                               // profile.
-  DIR_LOCAL_APP_DATA,          // "Local Settings\Application Data" directory
-                               // under the user profile.
-  DIR_COMMON_APP_DATA,         // Usually "C:\ProgramData".
-  DIR_APP_SHORTCUTS,           // Where tiles on the start screen are stored,
-                               // only for Windows 8. Maps to "Local\AppData\
-                               // Microsoft\Windows\Application Shortcuts\".
-  DIR_COMMON_DESKTOP,          // Directory for the common desktop (visible
-                               // on all user's Desktop).
-  DIR_USER_QUICK_LAUNCH,       // Directory for the quick launch shortcuts.
-  DIR_TASKBAR_PINS,            // Directory for the shortcuts pinned to taskbar.
-  DIR_IMPLICIT_APP_SHORTCUTS,  // The implicit user pinned shortcut directory.
-  DIR_WINDOWS_FONTS,           // Usually C:\Windows\Fonts.
-
-  PATH_WIN_END
-};
-
-}  // namespace base
-
-#endif  // BASE_BASE_PATHS_WIN_H_
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index 0ecbc13..ac327c3 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -31,7 +31,6 @@
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/memory/singleton.h"
-#include "base/path_service.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/stl_util.h"
 #include "base/strings/string_split.h"
@@ -616,12 +615,8 @@
     return true;
   }
 
-#if defined(OS_ANDROID)
-  return PathService::Get(DIR_CACHE, path);
-#else
   *path = FilePath("/tmp");
   return true;
-#endif
 }
 #endif  // !defined(OS_MACOSX)
 
diff --git a/base/path_service.cc b/base/path_service.cc
deleted file mode 100644
index 2843dce..0000000
--- a/base/path_service.cc
+++ /dev/null
@@ -1,339 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/path_service.h"
-
-#include <unordered_map>
-
-#if defined(OS_WIN)
-#include <windows.h>
-#include <shellapi.h>
-#include <shlobj.h>
-#endif
-
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/synchronization/lock.h"
-#include "build_config.h"
-
-namespace base {
-
-bool PathProvider(int key, FilePath* result);
-
-#if defined(OS_WIN)
-bool PathProviderWin(int key, FilePath* result);
-#elif defined(OS_MACOSX)
-bool PathProviderMac(int key, FilePath* result);
-#elif defined(OS_ANDROID)
-bool PathProviderAndroid(int key, FilePath* result);
-#elif defined(OS_FUCHSIA)
-bool PathProviderFuchsia(int key, FilePath* result);
-#elif defined(OS_POSIX)
-// PathProviderPosix is the default path provider on POSIX OSes other than
-// Mac and Android.
-bool PathProviderPosix(int key, FilePath* result);
-#endif
-
-namespace {
-
-typedef std::unordered_map<int, FilePath> PathMap;
-
-// We keep a linked list of providers.  In a debug build we ensure that no two
-// providers claim overlapping keys.
-struct Provider {
-  PathService::ProviderFunc func;
-  struct Provider* next;
-#ifndef NDEBUG
-  int key_start;
-  int key_end;
-#endif
-  bool is_static;
-};
-
-Provider base_provider = {PathProvider, nullptr,
-#ifndef NDEBUG
-                          PATH_START, PATH_END,
-#endif
-                          true};
-
-#if defined(OS_WIN)
-Provider base_provider_win = {
-  PathProviderWin,
-  &base_provider,
-#ifndef NDEBUG
-  PATH_WIN_START,
-  PATH_WIN_END,
-#endif
-  true
-};
-#endif
-
-#if defined(OS_MACOSX)
-Provider base_provider_mac = {
-  PathProviderMac,
-  &base_provider,
-#ifndef NDEBUG
-  PATH_MAC_START,
-  PATH_MAC_END,
-#endif
-  true
-};
-#endif
-
-#if defined(OS_ANDROID)
-Provider base_provider_android = {
-  PathProviderAndroid,
-  &base_provider,
-#ifndef NDEBUG
-  PATH_ANDROID_START,
-  PATH_ANDROID_END,
-#endif
-  true
-};
-#endif
-
-#if defined(OS_FUCHSIA)
-Provider base_provider_fuchsia = {PathProviderFuchsia, &base_provider,
-#ifndef NDEBUG
-                                  0, 0,
-#endif
-                                  true};
-#endif
-
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
-    !defined(OS_FUCHSIA)
-Provider base_provider_posix = {
-  PathProviderPosix,
-  &base_provider,
-#ifndef NDEBUG
-  PATH_POSIX_START,
-  PATH_POSIX_END,
-#endif
-  true
-};
-#endif
-
-
-struct PathData {
-  Lock lock;
-  PathMap cache;        // Cache mappings from path key to path value.
-  PathMap overrides;    // Track path overrides.
-  Provider* providers;  // Linked list of path service providers.
-  bool cache_disabled;  // Don't use cache if true;
-
-  PathData() : cache_disabled(false) {
-#if defined(OS_WIN)
-    providers = &base_provider_win;
-#elif defined(OS_MACOSX)
-    providers = &base_provider_mac;
-#elif defined(OS_ANDROID)
-    providers = &base_provider_android;
-#elif defined(OS_FUCHSIA)
-    providers = &base_provider_fuchsia;
-#elif defined(OS_POSIX)
-    providers = &base_provider_posix;
-#endif
-  }
-};
-
-static PathData* GetPathData() {
-  static auto* path_data = new PathData();
-  return path_data;
-}
-
-// Tries to find |key| in the cache. |path_data| should be locked by the caller!
-bool LockedGetFromCache(int key, const PathData* path_data, FilePath* result) {
-  if (path_data->cache_disabled)
-    return false;
-  // check for a cached version
-  PathMap::const_iterator it = path_data->cache.find(key);
-  if (it != path_data->cache.end()) {
-    *result = it->second;
-    return true;
-  }
-  return false;
-}
-
-// Tries to find |key| in the overrides map. |path_data| should be locked by the
-// caller!
-bool LockedGetFromOverrides(int key, PathData* path_data, FilePath* result) {
-  // check for an overridden version.
-  PathMap::const_iterator it = path_data->overrides.find(key);
-  if (it != path_data->overrides.end()) {
-    if (!path_data->cache_disabled)
-      path_data->cache[key] = it->second;
-    *result = it->second;
-    return true;
-  }
-  return false;
-}
-
-}  // namespace
-
-// TODO(brettw): this function does not handle long paths (filename > MAX_PATH)
-// characters). This isn't supported very well by Windows right now, so it is
-// moot, but we should keep this in mind for the future.
-// static
-bool PathService::Get(int key, FilePath* result) {
-  PathData* path_data = GetPathData();
-  DCHECK(path_data);
-  DCHECK(result);
-  DCHECK_GE(key, DIR_CURRENT);
-
-  // special case the current directory because it can never be cached
-  if (key == DIR_CURRENT)
-    return GetCurrentDirectory(result);
-
-  Provider* provider = nullptr;
-  {
-    AutoLock scoped_lock(path_data->lock);
-    if (LockedGetFromCache(key, path_data, result))
-      return true;
-
-    if (LockedGetFromOverrides(key, path_data, result))
-      return true;
-
-    // Get the beginning of the list while it is still locked.
-    provider = path_data->providers;
-  }
-
-  FilePath path;
-
-  // Iterating does not need the lock because only the list head might be
-  // modified on another thread.
-  while (provider) {
-    if (provider->func(key, &path))
-      break;
-    DCHECK(path.empty()) << "provider should not have modified path";
-    provider = provider->next;
-  }
-
-  if (path.empty())
-    return false;
-
-  if (path.ReferencesParent()) {
-    // Make sure path service never returns a path with ".." in it.
-    path = MakeAbsoluteFilePath(path);
-    if (path.empty())
-      return false;
-  }
-  *result = path;
-
-  AutoLock scoped_lock(path_data->lock);
-  if (!path_data->cache_disabled)
-    path_data->cache[key] = path;
-
-  return true;
-}
-
-// static
-bool PathService::Override(int key, const FilePath& path) {
-  // Just call the full function with true for the value of |create|, and
-  // assume that |path| may not be absolute yet.
-  return OverrideAndCreateIfNeeded(key, path, false, true);
-}
-
-// static
-bool PathService::OverrideAndCreateIfNeeded(int key,
-                                            const FilePath& path,
-                                            bool is_absolute,
-                                            bool create) {
-  PathData* path_data = GetPathData();
-  DCHECK(path_data);
-  DCHECK_GT(key, DIR_CURRENT) << "invalid path key";
-
-  FilePath file_path = path;
-
-  // For some locations this will fail if called from inside the sandbox there-
-  // fore we protect this call with a flag.
-  if (create) {
-    // Make sure the directory exists. We need to do this before we translate
-    // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails
-    // if called on a non-existent path.
-    if (!PathExists(file_path) && !CreateDirectory(file_path))
-      return false;
-  }
-
-  // We need to have an absolute path.
-  if (!is_absolute) {
-    file_path = MakeAbsoluteFilePath(file_path);
-    if (file_path.empty())
-      return false;
-  }
-  DCHECK(file_path.IsAbsolute());
-
-  AutoLock scoped_lock(path_data->lock);
-
-  // Clear the cache now. Some of its entries could have depended
-  // on the value we are overriding, and are now out of sync with reality.
-  path_data->cache.clear();
-
-  path_data->overrides[key] = file_path;
-
-  return true;
-}
-
-// static
-bool PathService::RemoveOverride(int key) {
-  PathData* path_data = GetPathData();
-  DCHECK(path_data);
-
-  AutoLock scoped_lock(path_data->lock);
-
-  if (path_data->overrides.find(key) == path_data->overrides.end())
-    return false;
-
-  // Clear the cache now. Some of its entries could have depended on the value
-  // we are going to remove, and are now out of sync.
-  path_data->cache.clear();
-
-  path_data->overrides.erase(key);
-
-  return true;
-}
-
-// static
-void PathService::RegisterProvider(ProviderFunc func, int key_start,
-                                   int key_end) {
-  PathData* path_data = GetPathData();
-  DCHECK(path_data);
-  DCHECK_GT(key_end, key_start);
-
-  Provider* p;
-
-  p = new Provider;
-  p->is_static = false;
-  p->func = func;
-#ifndef NDEBUG
-  p->key_start = key_start;
-  p->key_end = key_end;
-#endif
-
-  AutoLock scoped_lock(path_data->lock);
-
-#ifndef NDEBUG
-  Provider *iter = path_data->providers;
-  while (iter) {
-    DCHECK(key_start >= iter->key_end || key_end <= iter->key_start) <<
-      "path provider collision";
-    iter = iter->next;
-  }
-#endif
-
-  p->next = path_data->providers;
-  path_data->providers = p;
-}
-
-// static
-void PathService::DisableCache() {
-  PathData* path_data = GetPathData();
-  DCHECK(path_data);
-
-  AutoLock scoped_lock(path_data->lock);
-  path_data->cache.clear();
-  path_data->cache_disabled = true;
-}
-
-}  // namespace base
diff --git a/base/path_service.h b/base/path_service.h
deleted file mode 100644
index f92fead..0000000
--- a/base/path_service.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_PATH_SERVICE_H_
-#define BASE_PATH_SERVICE_H_
-
-#include <string>
-
-#include "base/base_export.h"
-#include "base/base_paths.h"
-#include "base/gtest_prod_util.h"
-#include "build_config.h"
-
-namespace base {
-
-class FilePath;
-class ScopedPathOverride;
-
-// The path service is a global table mapping keys to file system paths.  It is
-// OK to use this service from multiple threads.
-//
-class BASE_EXPORT PathService {
- public:
-  // Retrieves a path to a special directory or file and places it into the
-  // string pointed to by 'path'. If you ask for a directory it is guaranteed
-  // to NOT have a path separator at the end. For example, "c:\windows\temp"
-  // Directories are also guaranteed to exist when this function succeeds.
-  //
-  // Returns true if the directory or file was successfully retrieved. On
-  // failure, 'path' will not be changed.
-  static bool Get(int key, FilePath* path);
-
-  // Overrides the path to a special directory or file.  This cannot be used to
-  // change the value of DIR_CURRENT, but that should be obvious.  Also, if the
-  // path specifies a directory that does not exist, the directory will be
-  // created by this method.  This method returns true if successful.
-  //
-  // If the given path is relative, then it will be resolved against
-  // DIR_CURRENT.
-  //
-  // WARNING: Consumers of PathService::Get may expect paths to be constant
-  // over the lifetime of the app, so this method should be used with caution.
-  //
-  // Unit tests generally should use ScopedPathOverride instead. Overrides from
-  // one test should not carry over to another.
-  static bool Override(int key, const FilePath& path);
-
-  // This function does the same as PathService::Override but it takes extra
-  // parameters:
-  // - |is_absolute| indicates that |path| has already been expanded into an
-  // absolute path, otherwise MakeAbsoluteFilePath() will be used. This is
-  // useful to override paths that may not exist yet, since MakeAbsoluteFilePath
-  // fails for those. Note that MakeAbsoluteFilePath also expands symbolic
-  // links, even if path.IsAbsolute() is already true.
-  // - |create| guides whether the directory to be overriden must
-  // be created in case it doesn't exist already.
-  static bool OverrideAndCreateIfNeeded(int key,
-                                        const FilePath& path,
-                                        bool is_absolute,
-                                        bool create);
-
-  // To extend the set of supported keys, you can register a path provider,
-  // which is just a function mirroring PathService::Get.  The ProviderFunc
-  // returns false if it cannot provide a non-empty path for the given key.
-  // Otherwise, true is returned.
-  //
-  // WARNING: This function could be called on any thread from which the
-  // PathService is used, so a the ProviderFunc MUST BE THREADSAFE.
-  //
-  typedef bool (*ProviderFunc)(int, FilePath*);
-
-  // Call to register a path provider.  You must specify the range "[key_start,
-  // key_end)" of supported path keys.
-  static void RegisterProvider(ProviderFunc provider,
-                               int key_start,
-                               int key_end);
-
-  // Disable internal cache.
-  static void DisableCache();
-
- private:
-  friend class ScopedPathOverride;
-  FRIEND_TEST_ALL_PREFIXES(PathServiceTest, RemoveOverride);
-
-  // Removes an override for a special directory or file. Returns true if there
-  // was an override to remove or false if none was present.
-  // NOTE: This function is intended to be used by tests only!
-  static bool RemoveOverride(int key);
-};
-
-}  // namespace base
-
-#endif  // BASE_PATH_SERVICE_H_
diff --git a/build/gen.py b/build/gen.py
index 90fe58a..02278d1 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -226,7 +226,6 @@
   static_libraries = {
       'base': {'sources': [
         'base/at_exit.cc',
-        'base/base_paths.cc',
         'base/base_switches.cc',
         'base/callback_helpers.cc',
         'base/callback_internal.cc',
@@ -261,7 +260,6 @@
         'base/message_loop/message_pump_default.cc',
         'base/message_loop/watchable_io_message_pump_posix.cc',
         'base/observer_list_threadsafe.cc',
-        'base/path_service.cc',
         'base/pending_task.cc',
         'base/process/kill.cc',
         'base/process/memory.cc',
@@ -334,6 +332,7 @@
         'base/values.cc',
       ], 'tool': 'cxx', 'include_dirs': []},
       'gn_lib': {'sources': [
+        'src/exe_path.cc',
         'tools/gn/action_target_generator.cc',
         'tools/gn/action_values.cc',
         'tools/gn/analyzer.cc',
@@ -536,7 +535,6 @@
 
   if is_posix:
     static_libraries['base']['sources'].extend([
-        'base/base_paths_posix.cc',
         'base/files/file_enumerator_posix.cc',
         'base/files/file_descriptor_watcher_posix.cc',
         'base/files/file_posix.cc',
@@ -615,7 +613,6 @@
 
   if is_mac:
     static_libraries['base']['sources'].extend([
-        'base/base_paths_mac.mm',
         'base/files/file_util_mac.mm',
         'base/mac/bundle_locations.mm',
         'base/mac/call_with_eh_frame.cc',
@@ -654,7 +651,6 @@
 
   if is_win:
     static_libraries['base']['sources'].extend([
-        'base/base_paths_win.cc',
         'base/cpu.cc',
         'base/files/file_enumerator_win.cc',
         'base/files/file_path_watcher_win.cc',
diff --git a/src/exe_path.cc b/src/exe_path.cc
new file mode 100644
index 0000000..84f9aba
--- /dev/null
+++ b/src/exe_path.cc
@@ -0,0 +1,50 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "exe_path.h"
+
+#include "base/files/file_util.h"
+#include "base/logging.h"
+#include "base/strings/string_util.h"
+#include "build_config.h"
+
+#if defined(OS_MACOSX)
+#include <mach-o/dyld.h>
+
+base::FilePath GetExePath() {
+  // Executable path can have relative references ("..") depending on
+  // how the app was launched.
+  uint32_t executable_length = 0;
+  _NSGetExecutablePath(NULL, &executable_length);
+  DCHECK_GT(executable_length, 1u);
+  std::string executable_path;
+  int rv = _NSGetExecutablePath(
+      base::WriteInto(&executable_path, executable_length),
+                      &executable_length);
+  DCHECK_EQ(rv, 0);
+
+  // _NSGetExecutablePath may return paths containing ./ or ../ which makes
+  // FilePath::DirName() work incorrectly, convert it to absolute path so that
+  // paths such as DIR_SOURCE_ROOT can work, since we expect absolute paths to
+  // be returned here.
+  return base::MakeAbsoluteFilePath(base::FilePath(executable_path));
+}
+
+#elif defined(OS_WIN)
+
+#error
+
+#else
+
+base::FilePath GetExePath() {
+  base::FilePath result;
+  const char kProcSelfExe[] = "/proc/self/exe";
+  if (!ReadSymbolicLink(base::FilePath(kProcSelfExe), &result)) {
+    NOTREACHED() << "Unable to resolve " << kProcSelfExe << ".";
+    return base::FilePath();
+  }
+  return result;
+}
+
+#endif
diff --git a/src/exe_path.h b/src/exe_path.h
new file mode 100644
index 0000000..0c9d395
--- /dev/null
+++ b/src/exe_path.h
@@ -0,0 +1,12 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXE_PATH_H_
+#define EXE_PATH_H_
+
+#include "base/files/file_path.h"
+
+base::FilePath GetExePath();
+
+#endif  // EXE_PATH_H_
diff --git a/tools/gn/command_format_unittest.cc b/tools/gn/command_format_unittest.cc
index f0dd0ea..df24425 100644
--- a/tools/gn/command_format_unittest.cc
+++ b/tools/gn/command_format_unittest.cc
@@ -5,8 +5,8 @@
 #include "tools/gn/command_format.h"
 
 #include "base/files/file_util.h"
-#include "base/path_service.h"
 #include "base/strings/string_util.h"
+#include "exe_path.h"
 #include "test/test.h"
 #include "tools/gn/commands.h"
 #include "tools/gn/setup.h"
@@ -19,6 +19,8 @@
     ::Setup setup;                                                          \
     std::string out;                                                        \
     std::string expected;                                                   \
+    base::FilePath src_dir = GetExePath().DirName().Append("..");           \
+    base::SetCurrentDirectory(src_dir);                                     \
     EXPECT_TRUE(commands::FormatFileToString(                               \
         &setup, SourceFile("//tools/gn/format_test_data/" #n ".gn"), false, \
         &out));                                                             \
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc
index 3af49dd..0f40226 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -12,11 +12,11 @@
 
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/path_service.h"
 #include "base/process/process_handle.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build_config.h"
+#include "exe_path.h"
 #include "tools/gn/build_settings.h"
 #include "tools/gn/builder.h"
 #include "tools/gn/err.h"
@@ -51,8 +51,7 @@
   const base::FilePath build_path =
       build_settings->build_dir().Resolve(build_settings->root_path());
 
-  base::FilePath exe_path;
-  base::PathService::Get(base::FILE_EXE, &exe_path);
+  base::FilePath exe_path = GetExePath();
   if (build_path.IsAbsolute())
     exe_path = MakeAbsoluteFilePathRelativeIfPossible(build_path, exe_path);