Remove code that's always #if'd out $ rg 'if defined\(OS_NACL\)$' $ rg 'if defined\(OS_FREEBSD\)$' $ rg 'if defined\(OS_AIX\)$' $ rg 'if defined\(OS_FUCHSIA\)$' $ rg 'if defined\(OS_CHROMEOS\)$' $ rg 'if defined\(OS_ANDROID\)$' There's more that are in complex #ifs still. Change-Id: I748e283c7c195493d64b4589303c90b8395a3413 Reviewed-on: https://gn-review.googlesource.com/1601 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/base/files/file_enumerator_posix.cc b/base/files/file_enumerator_posix.cc index a0c5d45..a1a93d2 100644 --- a/base/files/file_enumerator_posix.cc +++ b/base/files/file_enumerator_posix.cc
@@ -111,21 +111,6 @@ directory_entries_.clear(); -#if defined(OS_FUCHSIA) - // Fuchsia does not support .. on the file system server side, see - // https://fuchsia.googlesource.com/docs/+/master/dotdot.md and - // https://crbug.com/735540. However, for UI purposes, having the parent - // directory show up in directory listings makes sense, so we add it here to - // match the expectation on other operating systems. In cases where this - // is useful it should be resolvable locally. - FileInfo dotdot; - dotdot.stat_.st_mode = S_IFDIR; - dotdot.filename_ = FilePath(".."); - if (!ShouldSkip(dotdot.filename_)) { - directory_entries_.push_back(std::move(dotdot)); - } -#endif // OS_FUCHSIA - current_directory_entry_ = 0; struct dirent* dent; while ((dent = readdir(dir))) {
diff --git a/base/files/file_path.cc b/base/files/file_path.cc index 146796b..969a977 100644 --- a/base/files/file_path.cc +++ b/base/files/file_path.cc
@@ -1305,10 +1305,4 @@ #endif } -#if defined(OS_ANDROID) -bool FilePath::IsContentUri() const { - return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); -} -#endif - } // namespace base
diff --git a/base/files/file_path.h b/base/files/file_path.h index 340375d..be70317 100644 --- a/base/files/file_path.h +++ b/base/files/file_path.h
@@ -427,15 +427,6 @@ StringPieceType string2); #endif -#if defined(OS_ANDROID) - // On android, file selection dialog can return a file with content uri - // scheme(starting with content://). Content uri needs to be opened with - // ContentResolver to guarantee that the app has appropriate permissions - // to access it. - // Returns true if the path is a content uri, or false otherwise. - bool IsContentUri() const; -#endif - private: // Remove trailing separators from this object. If the path is absolute, it // will never be stripped any more than to refer to the absolute root
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc index 630f1ff..344621f 100644 --- a/base/files/file_posix.cc +++ b/base/files/file_posix.cc
@@ -115,14 +115,7 @@ int64_t last_accessed_nsec = stat_info.st_atim.tv_nsec; time_t creation_time_sec = stat_info.st_ctim.tv_sec; int64_t creation_time_nsec = stat_info.st_ctim.tv_nsec; -#elif defined(OS_ANDROID) - time_t last_modified_sec = stat_info.st_mtime; - int64_t last_modified_nsec = stat_info.st_mtime_nsec; - time_t last_accessed_sec = stat_info.st_atime; - int64_t last_accessed_nsec = stat_info.st_atime_nsec; - time_t creation_time_sec = stat_info.st_ctime; - int64_t creation_time_nsec = stat_info.st_ctime_nsec; -#elif defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_BSD) +#elif defined(OS_MACOSX) time_t last_modified_sec = stat_info.st_mtimespec.tv_sec; int64_t last_modified_nsec = stat_info.st_mtimespec.tv_nsec; time_t last_accessed_sec = stat_info.st_atimespec.tv_sec; @@ -130,12 +123,7 @@ time_t creation_time_sec = stat_info.st_ctimespec.tv_sec; int64_t creation_time_nsec = stat_info.st_ctimespec.tv_nsec; #else - time_t last_modified_sec = stat_info.st_mtime; - int64_t last_modified_nsec = 0; - time_t last_accessed_sec = stat_info.st_atime; - int64_t last_accessed_nsec = 0; - time_t creation_time_sec = stat_info.st_ctime; - int64_t creation_time_nsec = 0; +#error #endif last_modified = @@ -176,15 +164,9 @@ int64_t File::Seek(Whence whence, int64_t offset) { DCHECK(IsValid()); -#if defined(OS_ANDROID) - static_assert(sizeof(int64_t) == sizeof(off64_t), "off64_t must be 64 bits"); - return lseek64(file_.get(), static_cast<off64_t>(offset), - static_cast<int>(whence)); -#else static_assert(sizeof(int64_t) == sizeof(off_t), "off_t must be 64 bits"); return lseek(file_.get(), static_cast<off_t>(offset), static_cast<int>(whence)); -#endif } int File::Read(int64_t offset, char* data, int size) { @@ -435,10 +417,6 @@ static_assert(O_RDONLY == 0, "O_RDONLY must equal zero"); int mode = S_IRUSR | S_IWUSR; -#if defined(OS_CHROMEOS) - mode |= S_IRGRP | S_IROTH; -#endif - int descriptor = HANDLE_EINTR(open(path.value().c_str(), open_flags, mode)); if (flags & FLAG_OPEN_ALWAYS) { @@ -473,10 +451,7 @@ bool File::Flush() { DCHECK(IsValid()); -#if defined(OS_NACL) - NOTIMPLEMENTED(); // NaCl doesn't implement fsync. - return true; -#elif defined(OS_LINUX) || defined(OS_ANDROID) +#if defined(OS_LINUX) return !HANDLE_EINTR(fdatasync(file_.get())); #else return !HANDLE_EINTR(fsync(file_.get()));
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc index 774735c..6fb43bd 100644 --- a/base/files/file_util_posix.cc +++ b/base/files/file_util_posix.cc
@@ -48,12 +48,6 @@ #include <grp.h> #endif -// We need to do this on AIX due to some inconsistencies in how AIX -// handles XOPEN_SOURCE and ALL_SOURCE. -#if defined(OS_AIX) -extern "C" char* mkdtemp(char* path); -#endif - namespace base { namespace { @@ -310,8 +304,6 @@ // set of permissions than it does on other POSIX platforms. #if defined(OS_MACOSX) int mode = 0600 | (stat_at_use.st_mode & 0177); -#elif defined(OS_CHROMEOS) - int mode = 0644; #else int mode = 0600; #endif @@ -466,11 +458,6 @@ } bool PathExists(const FilePath& path) { -#if defined(OS_ANDROID) - if (path.IsContentUri()) { - return ContentUriExists(path); - } -#endif return access(path.value().c_str(), F_OK) == 0; } @@ -608,10 +595,6 @@ if (home_dir && home_dir[0]) return FilePath(home_dir); -#if defined(OS_ANDROID) - DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; -#endif - FilePath rv; if (GetTempDir(&rv)) return rv; @@ -746,19 +729,8 @@ bool GetFileInfo(const FilePath& file_path, File::Info* results) { stat_wrapper_t file_info; -#if defined(OS_ANDROID) - if (file_path.IsContentUri()) { - File file = OpenContentUriForRead(file_path); - if (!file.IsValid()) - return false; - return file.GetInfo(results); - } else { -#endif // defined(OS_ANDROID) - if (CallStat(file_path.value().c_str(), &file_info) != 0) - return false; -#if defined(OS_ANDROID) - } -#endif // defined(OS_ANDROID) + if (CallStat(file_path.value().c_str(), &file_info) != 0) + return false; results->FromStat(file_info); return true; @@ -941,17 +913,9 @@ #endif // defined(OS_MACOSX) && !defined(OS_IOS) int GetMaximumPathComponentLength(const FilePath& path) { -#if defined(OS_FUCHSIA) - // Return a value we do not expect anyone ever to reach, but which is small - // enough to guard against e.g. bugs causing multi-megabyte paths. - return 1024; -#else return pathconf(path.value().c_str(), _PC_NAME_MAX); -#endif } -#if !defined(OS_ANDROID) -// This is implemented in file_util_android.cc for that platform. bool GetShmemTempDir(bool executable, FilePath* path) { #if defined(OS_LINUX) || defined(OS_AIX) bool use_dev_shm = true; @@ -966,21 +930,12 @@ #endif // defined(OS_LINUX) || defined(OS_AIX) return GetTempDir(path); } -#endif // !defined(OS_ANDROID) #if !defined(OS_MACOSX) // Mac has its own implementation, this is for all other Posix systems. bool CopyFile(const FilePath& from_path, const FilePath& to_path) { File infile; -#if defined(OS_ANDROID) - if (from_path.IsContentUri()) { - infile = OpenContentUriForRead(from_path); - } else { - infile = File(from_path, File::FLAG_OPEN | File::FLAG_READ); - } -#else infile = File(from_path, File::FLAG_OPEN | File::FLAG_READ); -#endif if (!infile.IsValid()) return false;
diff --git a/base/linux_util.cc b/base/linux_util.cc index 5c57d78..f2d29ec 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc
@@ -106,19 +106,9 @@ // We use this static string to hold the Linux distro info. If we // crash, the crash handler code will send this in the crash dump. -char g_linux_distro[kDistroSize] = -#if defined(OS_CHROMEOS) - "CrOS"; -#elif defined(OS_ANDROID) - "Android"; -#else // if defined(OS_LINUX) - "Unknown"; -#endif +char g_linux_distro[kDistroSize] = "Unknown"; std::string GetLinuxDistro() { -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) - return g_linux_distro; -#elif defined(OS_LINUX) LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::GetInstance(); LinuxDistroState state = distro_state_singleton->State(); if (STATE_CHECK_FINISHED == state) @@ -143,10 +133,6 @@ } distro_state_singleton->CheckFinished(); return g_linux_distro; -#else - NOTIMPLEMENTED(); - return "Unknown"; -#endif } void SetLinuxDistro(const std::string& distro) {
diff --git a/base/logging.cc b/base/logging.cc index 83ad556..aacc90c 100644 --- a/base/logging.cc +++ b/base/logging.cc
@@ -47,21 +47,9 @@ #include <mach-o/dyld.h> #elif defined(OS_POSIX) || defined(OS_FUCHSIA) -#if defined(OS_NACL) -#include <sys/time.h> // timespec doesn't seem to be in <time.h> -#endif #include <time.h> #endif -#if defined(OS_FUCHSIA) -#include <zircon/process.h> -#include <zircon/syscalls.h> -#endif - -#if defined(OS_ANDROID) -#include <android/log.h> -#endif - #if defined(OS_POSIX) || defined(OS_FUCHSIA) #include <errno.h> #include <paths.h> @@ -150,11 +138,6 @@ int32_t CurrentProcessId() { #if defined(OS_WIN) return GetCurrentProcessId(); -#elif defined(OS_FUCHSIA) - zx_info_handle_basic_t basic = {}; - zx_object_get_info(zx_process_self(), ZX_INFO_HANDLE_BASIC, &basic, - sizeof(basic), nullptr, nullptr); - return basic.koid; #elif defined(OS_POSIX) return getpid(); #endif @@ -163,15 +146,8 @@ uint64_t TickCount() { #if defined(OS_WIN) return GetTickCount(); -#elif defined(OS_FUCHSIA) - return zx_clock_get(ZX_CLOCK_MONOTONIC) / - static_cast<zx_time_t>(base::Time::kNanosecondsPerMicrosecond); #elif defined(OS_MACOSX) return mach_absolute_time(); -#elif defined(OS_NACL) - // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h - // So we have to use clock() for now. - return clock(); #elif defined(OS_POSIX) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -186,9 +162,7 @@ void DeleteFilePath(const PathString& log_name) { #if defined(OS_WIN) DeleteFile(log_name.c_str()); -#elif defined(OS_NACL) - // Do nothing; unlink() isn't supported on NaCl. -#elif defined(OS_POSIX) || defined(OS_FUCHSIA) +#elif defined(OS_POSIX) unlink(log_name.c_str()); #else #error Unsupported platform @@ -386,10 +360,6 @@ delete_old(APPEND_TO_OLD_LOG_FILE) {} bool BaseInitLoggingImpl(const LoggingSettings& settings) { -#if defined(OS_NACL) - // Can log only to the system debug log. - CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); -#endif g_logging_destination = settings.logging_dest; // ignore file options unless logging to file is set. @@ -694,24 +664,6 @@ str_newline.c_str()); #endif // defined(USE_ASL) } -#elif defined(OS_ANDROID) - android_LogPriority priority = - (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN; - switch (severity_) { - case LOG_INFO: - priority = ANDROID_LOG_INFO; - break; - case LOG_WARNING: - priority = ANDROID_LOG_WARN; - break; - case LOG_ERROR: - priority = ANDROID_LOG_ERROR; - break; - case LOG_FATAL: - priority = ANDROID_LOG_FATAL; - break; - } - __android_log_write(priority, "chromium", str_newline.c_str()); #endif ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr)); fflush(stderr);
diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc index c551502..69a1a5b 100644 --- a/base/process/internal_linux.cc +++ b/base/process/internal_linux.cc
@@ -18,11 +18,6 @@ #include "base/strings/string_util.h" #include "base/time/time.h" -// Not defined on AIX by default. -#if defined(OS_AIX) -#define NAME_MAX 255 -#endif - namespace base { namespace internal {
diff --git a/base/process/kill.h b/base/process/kill.h index 03c057c..384087c 100644 --- a/base/process/kill.h +++ b/base/process/kill.h
@@ -51,17 +51,6 @@ TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault TERMINATION_STATUS_STILL_RUNNING, // child hasn't exited yet -#if defined(OS_CHROMEOS) - // Used for the case when oom-killer kills a process on ChromeOS. - TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM, -#endif -#if defined(OS_ANDROID) - // On Android processes are spawned from the system Zygote and we do not get - // the termination status. We can't know if the termination was a crash or an - // oom kill for sure, but we can use status of the strong process bindings as - // a hint. - TERMINATION_STATUS_OOM_PROTECTED, // child was protected from oom kill -#endif TERMINATION_STATUS_LAUNCH_FAILED, // child process never launched TERMINATION_STATUS_OOM, // Process died due to oom TERMINATION_STATUS_MAX_ENUM
diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc index 4027c6f..e6d658c 100644 --- a/base/process/kill_posix.cc +++ b/base/process/kill_posix.cc
@@ -53,11 +53,6 @@ case SIGSYS: return TERMINATION_STATUS_PROCESS_CRASHED; case SIGKILL: -#if defined(OS_CHROMEOS) - // On ChromeOS, only way a process gets kill by SIGKILL - // is by oom-killer. - return TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM; -#endif case SIGINT: case SIGTERM: return TERMINATION_STATUS_PROCESS_WAS_KILLED;
diff --git a/base/process/launch.h b/base/process/launch.h index 0a08750..eb53c0f 100644 --- a/base/process/launch.h +++ b/base/process/launch.h
@@ -23,12 +23,9 @@ #if defined(OS_WIN) #include <windows.h> -#elif defined(OS_FUCHSIA) -#include <launchpad/launchpad.h> -#include <zircon/types.h> #endif -#if defined(OS_POSIX) || defined(OS_FUCHSIA) +#if defined(OS_POSIX) #include "base/posix/file_descriptor_shuffle.h" #endif @@ -38,13 +35,6 @@ #if defined(OS_WIN) typedef std::vector<HANDLE> HandlesToInheritVector; -#elif defined(OS_FUCHSIA) -struct HandleToTransfer { - uint32_t id; - zx_handle_t handle; -}; -typedef std::vector<HandleToTransfer> HandlesToTransferVector; -typedef std::vector<std::pair<int, int>> FileHandleMappingVector; #elif defined(OS_POSIX) typedef std::vector<std::pair<int, int>> FileHandleMappingVector; #endif // defined(OS_WIN) @@ -52,7 +42,7 @@ // Options for launching a subprocess that are passed to LaunchProcess(). // The default constructor constructs the object with default options. struct BASE_EXPORT LaunchOptions { -#if defined(OS_POSIX) || defined(OS_FUCHSIA) +#if defined(OS_POSIX) // Delegate to be run in between fork and exec in the subprocess (see // pre_exec_delegate below) class BASE_EXPORT PreExecDelegate { @@ -152,7 +142,7 @@ // If set to true, permission to bring windows to the foreground is passed to // the launched process if the current process has such permission. bool grant_foreground_privilege = false; -#elif defined(OS_POSIX) || defined(OS_FUCHSIA) +#elif defined(OS_POSIX) // Set/unset environment variables. These are applied on top of the parent // process environment. Empty (the default) means to inherit the same // environment. See AlterEnvironment(). @@ -182,36 +172,6 @@ bool kill_on_parent_death = false; #endif // defined(OS_LINUX) -#if defined(OS_FUCHSIA) - // If valid, launches the application in that job object. - zx_handle_t job_handle = ZX_HANDLE_INVALID; - - // Specifies additional handles to transfer (not duplicate) to the child - // process. The handles remain valid in this process if launch fails. - // Each entry is an <id,handle> pair, with an |id| created using the PA_HND() - // macro. The child retrieves the handle |zx_get_startup_handle(id)|. - HandlesToTransferVector handles_to_transfer; - - // If set, specifies which capabilities should be granted (cloned) to the - // child process. - // A zero value indicates that the child process will receive - // no capabilities. - // By default the child will inherit the same capabilities, job, and CWD - // from the parent process. - uint32_t clone_flags = - LP_CLONE_FDIO_NAMESPACE | LP_CLONE_DEFAULT_JOB | LP_CLONE_FDIO_STDIO; - - // Specifies the namespace paths which are to be cloned in the child process' - // namespace. If left unset, the child process will be launched with an empty - // namespace. - // This flag allows the parent to pass only the bare minimum OS capabilities - // to the child process, so that the potential attack surface is reduced in - // case child process is compromised. - // Cannot be combined with the clone flag LP_CLONE_FDIO_NAMESPACE, which is - // equivalent to cloning every path. - std::vector<FilePath> paths_to_map; -#endif // defined(OS_FUCHSIA) - #if defined(OS_POSIX) // If not empty, launch the specified executable instead of // cmdline.GetProgram(). This is useful when it is necessary to pass a custom @@ -236,12 +196,6 @@ // will be the same as its pid. bool new_process_group = false; #endif // defined(OS_POSIX) - -#if defined(OS_CHROMEOS) - // If non-negative, the specified file descriptor will be set as the launched - // process' controlling terminal. - int ctrl_terminal_fd = -1; -#endif // defined(OS_CHROMEOS) }; // Launch a process via the command line |cmdline|. @@ -282,7 +236,7 @@ BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline, const LaunchOptions& options); -#elif defined(OS_POSIX) || defined(OS_FUCHSIA) +#elif defined(OS_POSIX) // A POSIX-specific version of LaunchProcess that takes an argv array // instead of a CommandLine. Useful for situations where you need to // control the command line arguments directly, but prefer the @@ -328,7 +282,7 @@ // instead of a CommandLine object. Useful for situations where you need to // control the command line arguments directly. BASE_EXPORT bool GetAppOutput(const StringPiece16& cl, std::string* output); -#elif defined(OS_POSIX) || defined(OS_FUCHSIA) +#elif defined(OS_POSIX) // A POSIX-specific version of GetAppOutput that takes an argv array // instead of a CommandLine. Useful for situations where you need to // control the command line arguments directly.
diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc index 454b2cb..2369802 100644 --- a/base/process/launch_posix.cc +++ b/base/process/launch_posix.cc
@@ -45,15 +45,6 @@ #include <sys/prctl.h> #endif -#if defined(OS_CHROMEOS) -#include <sys/ioctl.h> -#endif - -#if defined(OS_FREEBSD) -#include <sys/event.h> -#include <sys/ucontext.h> -#endif - #if defined(OS_MACOSX) #include <crt_externs.h> #include <sys/event.h> @@ -105,15 +96,7 @@ // the previous signal mask. sigset_t SetSignalMask(const sigset_t& new_sigmask) { sigset_t old_sigmask; -#if defined(OS_ANDROID) - // POSIX says pthread_sigmask() must be used in multi-threaded processes, - // but Android's pthread_sigmask() was broken until 4.1: - // https://code.google.com/p/android/issues/detail?id=15337 - // http://stackoverflow.com/questions/13777109/pthread-sigmask-on-android-not-working - RAW_CHECK(sigprocmask(SIG_SETMASK, &new_sigmask, &old_sigmask) == 0); -#else RAW_CHECK(pthread_sigmask(SIG_SETMASK, &new_sigmask, &old_sigmask) == 0); -#endif return old_sigmask; } @@ -219,14 +202,6 @@ static const char kFDDir[] = "/proc/self/fd"; #elif defined(OS_MACOSX) static const char kFDDir[] = "/dev/fd"; -#elif defined(OS_SOLARIS) -static const char kFDDir[] = "/dev/fd"; -#elif defined(OS_FREEBSD) -static const char kFDDir[] = "/dev/fd"; -#elif defined(OS_OPENBSD) -static const char kFDDir[] = "/dev/fd"; -#elif defined(OS_ANDROID) -static const char kFDDir[] = "/proc/self/fd"; #endif void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { @@ -440,20 +415,6 @@ memset(reinterpret_cast<void*>(malloc), 0xff, 8); #endif // 0 -#if defined(OS_CHROMEOS) - if (options.ctrl_terminal_fd >= 0) { - // Set process' controlling terminal. - if (HANDLE_EINTR(setsid()) != -1) { - if (HANDLE_EINTR( - ioctl(options.ctrl_terminal_fd, TIOCSCTTY, nullptr)) == -1) { - RAW_LOG(WARNING, "ioctl(TIOCSCTTY), ctrl terminal not set"); - } - } else { - RAW_LOG(WARNING, "setsid failed, ctrl terminal not set"); - } - } -#endif // defined(OS_CHROMEOS) - // Cannot use STL iterators here, since debug iterators use locks. for (size_t i = 0; i < options.fds_to_remap.size(); ++i) { const FileHandleMappingVector::value_type& value =
diff --git a/base/process/process.h b/base/process/process.h index 2826be3..2633355 100644 --- a/base/process/process.h +++ b/base/process/process.h
@@ -15,10 +15,6 @@ #include "base/win/scoped_handle.h" #endif -#if defined(OS_FUCHSIA) -#include "base/fuchsia/scoped_zx_handle.h" -#endif - #if defined(OS_MACOSX) #include "base/process/port_provider_mac.h" #endif @@ -172,37 +168,20 @@ // of this value is OS dependent. int GetPriority() const; -#if defined(OS_CHROMEOS) - // Get the PID in its PID namespace. - // If the process is not in a PID namespace or /proc/<pid>/status does not - // report NSpid, kNullProcessId is returned. - ProcessId GetPidInNamespace() const; -#endif - private: #if defined(OS_WIN) win::ScopedHandle process_; -#elif defined(OS_FUCHSIA) - ScopedZxHandle process_; #else ProcessHandle process_; #endif -#if defined(OS_WIN) || defined(OS_FUCHSIA) +#if defined(OS_WIN) bool is_current_process_; #endif DISALLOW_COPY_AND_ASSIGN(Process); }; -#if defined(OS_CHROMEOS) -// Exposed for testing. -// Given the contents of the /proc/<pid>/cgroup file, determine whether the -// process is backgrounded or not. -BASE_EXPORT bool IsProcessBackgroundedCGroup( - const StringPiece& cgroup_contents); -#endif // defined(OS_CHROMEOS) - } // namespace base #endif // BASE_PROCESS_PROCESS_H_
diff --git a/base/process/process_handle.h b/base/process/process_handle.h index bf9a720..8079e56 100644 --- a/base/process/process_handle.h +++ b/base/process/process_handle.h
@@ -16,10 +16,6 @@ #include "base/win/windows_types.h" #endif -#if defined(OS_FUCHSIA) -#include <zircon/types.h> -#endif - namespace base { // ProcessHandle is a platform specific type which represents the underlying OS @@ -31,11 +27,6 @@ typedef HANDLE UserTokenHandle; const ProcessHandle kNullProcessHandle = NULL; const ProcessId kNullProcessId = 0; -#elif defined(OS_FUCHSIA) -typedef zx_handle_t ProcessHandle; -typedef zx_koid_t ProcessId; -const ProcessHandle kNullProcessHandle = ZX_HANDLE_INVALID; -const ProcessId kNullProcessId = ZX_KOID_INVALID; #elif defined(OS_POSIX) // On POSIX, our ProcessHandle will just be the PID. typedef pid_t ProcessHandle; @@ -47,7 +38,7 @@ // To print ProcessIds portably use CrPRIdPid (based on PRIuS and friends from // C99 and format_macros.h) like this: // base::StringPrintf("PID is %" CrPRIdPid ".\n", pid); -#if defined(OS_WIN) || defined(OS_FUCHSIA) +#if defined(OS_WIN) #define CrPRIdPid "ld" #else #define CrPRIdPid "d"
diff --git a/base/process/process_handle_linux.cc b/base/process/process_handle_linux.cc index f921b42..43e9ce2 100644 --- a/base/process/process_handle_linux.cc +++ b/base/process/process_handle_linux.cc
@@ -6,20 +6,12 @@ #include "base/files/file_util.h" #include "base/process/internal_linux.h" -#if defined(OS_AIX) -#include "base/process/internal_aix.h" -#endif namespace base { ProcessId GetParentProcessId(ProcessHandle process) { ProcessId pid = -#if defined(OS_AIX) - internalAIX::ReadProcStatsAndGetFieldAsInt64(process, - internalAIX::VM_PPID); -#else internal::ReadProcStatsAndGetFieldAsInt64(process, internal::VM_PPID); -#endif // TODO(zijiehe): Returns 0 if |process| does not have a parent process. if (pid) return pid;
diff --git a/base/process/process_iterator.cc b/base/process/process_iterator.cc index bc8c0a8..792237b 100644 --- a/base/process/process_iterator.cc +++ b/base/process/process_iterator.cc
@@ -39,17 +39,6 @@ const FilePath::StringType& executable_name, const ProcessFilter* filter) : ProcessIterator(filter), executable_name_(executable_name) { -#if defined(OS_ANDROID) - // On Android, the process name contains only the last 15 characters, which - // is in file /proc/<pid>/stat, the string between open parenthesis and close - // parenthesis. Please See ProcessIterator::CheckForNextProcess for details. - // Now if the length of input process name is greater than 15, only save the - // last 15 characters. - if (executable_name_.size() > 15) { - executable_name_ = FilePath::StringType(executable_name_, - executable_name_.size() - 15, 15); - } -#endif } NamedProcessIterator::~NamedProcessIterator() = default;
diff --git a/base/process/process_iterator.h b/base/process/process_iterator.h index 672d58b..e563567 100644 --- a/base/process/process_iterator.h +++ b/base/process/process_iterator.h
@@ -24,8 +24,6 @@ #include <tlhelp32.h> #elif defined(OS_MACOSX) || defined(OS_OPENBSD) #include <sys/sysctl.h> -#elif defined(OS_FREEBSD) -#include <sys/user.h> #elif defined(OS_POSIX) || defined(OS_FUCHSIA) #include <dirent.h> #endif
diff --git a/base/process/process_linux.cc b/base/process/process_linux.cc index 173daf9..066c647 100644 --- a/base/process/process_linux.cc +++ b/base/process/process_linux.cc
@@ -15,63 +15,13 @@ #include "base/synchronization/lock.h" #include "build_config.h" -// Not defined on AIX by default. -#if defined(OS_AIX) -#define RLIMIT_NICE 20 -#endif - namespace base { namespace { const int kForegroundPriority = 0; -#if defined(OS_CHROMEOS) -// We are more aggressive in our lowering of background process priority -// for chromeos as we have much more control over other processes running -// on the machine. -// -// TODO(davemoore) Refactor this by adding support for higher levels to set -// the foregrounding / backgrounding process so we don't have to keep -// chrome / chromeos specific logic here. -const int kBackgroundPriority = 19; -const char kControlPath[] = "/sys/fs/cgroup/cpu%s/cgroup.procs"; -const char kForeground[] = "/chrome_renderers/foreground"; -const char kBackground[] = "/chrome_renderers/background"; -const char kProcPath[] = "/proc/%d/cgroup"; - -struct CGroups { - // Check for cgroups files. ChromeOS supports these by default. It creates - // a cgroup mount in /sys/fs/cgroup and then configures two cpu task groups, - // one contains at most a single foreground renderer and the other contains - // all background renderers. This allows us to limit the impact of background - // renderers on foreground ones to a greater level than simple renicing. - bool enabled; - base::FilePath foreground_file; - base::FilePath background_file; - - CGroups() { - foreground_file = - base::FilePath(base::StringPrintf(kControlPath, kForeground)); - background_file = - base::FilePath(base::StringPrintf(kControlPath, kBackground)); - base::FileSystemType foreground_type; - base::FileSystemType background_type; - enabled = - base::GetFileSystemType(foreground_file, &foreground_type) && - base::GetFileSystemType(background_file, &background_type) && - foreground_type == FILE_SYSTEM_CGROUP && - background_type == FILE_SYSTEM_CGROUP; - } - - static CGroups& Get() { - static auto& groups = *new CGroups; - return groups; - } -}; -#else const int kBackgroundPriority = 5; -#endif // defined(OS_CHROMEOS) bool CanReraisePriority() { // We won't be able to raise the priority if we don't have the right rlimit. @@ -85,11 +35,6 @@ // static bool Process::CanBackgroundProcesses() { -#if defined(OS_CHROMEOS) - if (CGroups::Get().enabled) - return true; -#endif // defined(OS_CHROMEOS) - static const bool can_reraise_priority = CanReraisePriority(); return can_reraise_priority; } @@ -97,32 +42,12 @@ bool Process::IsProcessBackgrounded() const { DCHECK(IsValid()); -#if defined(OS_CHROMEOS) - if (CGroups::Get().enabled) { - std::string proc; - if (base::ReadFileToString( - base::FilePath(StringPrintf(kProcPath, process_)), &proc)) { - return IsProcessBackgroundedCGroup(proc); - } - return false; - } -#endif // defined(OS_CHROMEOS) - return GetPriority() == kBackgroundPriority; } bool Process::SetProcessBackgrounded(bool background) { DCHECK(IsValid()); -#if defined(OS_CHROMEOS) - if (CGroups::Get().enabled) { - std::string pid = IntToString(process_); - const base::FilePath file = background ? CGroups::Get().background_file - : CGroups::Get().foreground_file; - return base::WriteFile(file, pid.c_str(), pid.size()) > 0; - } -#endif // defined(OS_CHROMEOS) - if (!CanBackgroundProcesses()) return false; @@ -132,65 +57,4 @@ return result == 0; } -#if defined(OS_CHROMEOS) -bool IsProcessBackgroundedCGroup(const StringPiece& cgroup_contents) { - // The process can be part of multiple control groups, and for each cgroup - // hierarchy there's an entry in the file. We look for a control group - // named "/chrome_renderers/background" to determine if the process is - // backgrounded. crbug.com/548818. - std::vector<StringPiece> lines = SplitStringPiece( - cgroup_contents, "\n", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); - for (const auto& line : lines) { - std::vector<StringPiece> fields = - SplitStringPiece(line, ":", TRIM_WHITESPACE, SPLIT_WANT_ALL); - if (fields.size() != 3U) { - NOTREACHED(); - continue; - } - if (fields[2] == kBackground) - return true; - } - - return false; -} -#endif // defined(OS_CHROMEOS) - -#if defined(OS_CHROMEOS) -// Reads /proc/<pid>/status and returns the PID in its PID namespace. -// If the process is not in a PID namespace or /proc/<pid>/status does not -// report NSpid, kNullProcessId is returned. -ProcessId Process::GetPidInNamespace() const { - std::string status; - { - FilePath status_file = - FilePath("/proc").Append(IntToString(process_)).Append("status"); - if (!ReadFileToString(status_file, &status)) { - return kNullProcessId; - } - } - - StringPairs pairs; - SplitStringIntoKeyValuePairs(status, ':', '\n', &pairs); - for (const auto& pair : pairs) { - const std::string& key = pair.first; - const std::string& value_str = pair.second; - if (key == "NSpid") { - std::vector<StringPiece> split_value_str = SplitStringPiece( - value_str, "\t", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY); - if (split_value_str.size() <= 1) { - return kNullProcessId; - } - int value; - // The last value in the list is the PID in the namespace. - if (!StringToInt(split_value_str.back(), &value)) { - NOTREACHED(); - return kNullProcessId; - } - return value; - } - } - return kNullProcessId; -} -#endif // defined(OS_CHROMEOS) - } // namespace base
diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc index 4dbb35d..13ecaf5 100644 --- a/base/rand_util_posix.cc +++ b/base/rand_util_posix.cc
@@ -22,17 +22,9 @@ // we can use LazyInstance to handle opening it on the first access. class URandomFd { public: -#if defined(OS_AIX) - // AIX has no 64-bit support for open falgs such as - - // O_CLOEXEC, O_NOFOLLOW and O_TTY_INIT - URandomFd() : fd_(HANDLE_EINTR(open("/dev/urandom", O_RDONLY))) { - DCHECK_GE(fd_, 0) << "Cannot open /dev/urandom: " << errno; - } -#else URandomFd() : fd_(HANDLE_EINTR(open("/dev/urandom", O_RDONLY | O_CLOEXEC))) { DCHECK_GE(fd_, 0) << "Cannot open /dev/urandom: " << errno; } -#endif ~URandomFd() { close(fd_); }
diff --git a/base/synchronization/condition_variable_posix.cc b/base/synchronization/condition_variable_posix.cc index 7d6824d..229b529 100644 --- a/base/synchronization/condition_variable_posix.cc +++ b/base/synchronization/condition_variable_posix.cc
@@ -75,18 +75,10 @@ #else // The timeout argument to pthread_cond_timedwait is in absolute time. struct timespec absolute_time; -#if defined(OS_NACL) - // See comment in constructor for why this is different in NaCl. - struct timeval now; - gettimeofday(&now, NULL); - absolute_time.tv_sec = now.tv_sec; - absolute_time.tv_nsec = now.tv_usec * Time::kNanosecondsPerMicrosecond; -#else struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); absolute_time.tv_sec = now.tv_sec; absolute_time.tv_nsec = now.tv_nsec; -#endif absolute_time.tv_sec += relative_time.tv_sec; absolute_time.tv_nsec += relative_time.tv_nsec;
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h index 7668c1c..c249bc2 100644 --- a/base/threading/platform_thread.h +++ b/base/threading/platform_thread.h
@@ -18,8 +18,6 @@ #if defined(OS_WIN) #include "base/win/windows_types.h" -#elif defined(OS_FUCHSIA) -#include <zircon/types.h> #elif defined(OS_MACOSX) #include <mach/mach_types.h> #elif defined(OS_POSIX) @@ -32,8 +30,6 @@ // Used for logging. Always an integer value. #if defined(OS_WIN) typedef DWORD PlatformThreadId; -#elif defined(OS_FUCHSIA) -typedef zx_handle_t PlatformThreadId; #elif defined(OS_MACOSX) typedef mach_port_t PlatformThreadId; #elif defined(OS_POSIX)
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index ce47a30..32a052a 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc
@@ -22,11 +22,7 @@ #include <sys/syscall.h> #endif -#if defined(OS_FUCHSIA) -#include <zircon/process.h> -#else #include <sys/resource.h> -#endif namespace base { @@ -114,21 +110,8 @@ return pthread_mach_thread_np(pthread_self()); #elif defined(OS_LINUX) return syscall(__NR_gettid); -#elif defined(OS_ANDROID) - return gettid(); -#elif defined(OS_FUCHSIA) - return zx_thread_self(); -#elif defined(OS_SOLARIS) || defined(OS_QNX) - return pthread_self(); -#elif defined(OS_NACL) && defined(__GLIBC__) - return pthread_self(); -#elif defined(OS_NACL) && !defined(__GLIBC__) - // Pointers are 32-bits in NaCl. - return reinterpret_cast<int32_t>(pthread_self()); -#elif defined(OS_POSIX) && defined(OS_AIX) - return pthread_self(); -#elif defined(OS_POSIX) && !defined(OS_AIX) - return reinterpret_cast<int64_t>(pthread_self()); +#else +#error #endif }
diff --git a/base/time/time.h b/base/time/time.h index a760c55..936c746 100644 --- a/base/time/time.h +++ b/base/time/time.h
@@ -63,21 +63,13 @@ #include "base/numerics/safe_math.h" #include "build_config.h" -#if defined(OS_FUCHSIA) -#include <zircon/types.h> -#endif - #if defined(OS_MACOSX) #include <CoreFoundation/CoreFoundation.h> // Avoid Mac system header macro leak. #undef TYPE_BOOL #endif -#if defined(OS_ANDROID) -#include <jni.h> -#endif - -#if defined(OS_POSIX) || defined(OS_FUCHSIA) +#if defined(OS_POSIX) #include <unistd.h> #include <sys/time.h> #endif @@ -473,18 +465,9 @@ #if defined(OS_WIN) static constexpr int kExplodedMinYear = 1601; static constexpr int kExplodedMaxYear = 30827; -#elif defined(OS_IOS) - static constexpr int kExplodedMinYear = std::numeric_limits<int>::min(); - static constexpr int kExplodedMaxYear = std::numeric_limits<int>::max(); #elif defined(OS_MACOSX) static constexpr int kExplodedMinYear = 1902; static constexpr int kExplodedMaxYear = std::numeric_limits<int>::max(); -#elif defined(OS_ANDROID) - // Though we use 64-bit time APIs on both 32 and 64 bit Android, some OS - // versions like KitKat (ARM but not x86 emulator) can't handle some early - // dates (e.g. before 1170). So we set min conservatively here. - static constexpr int kExplodedMinYear = 1902; - static constexpr int kExplodedMaxYear = std::numeric_limits<int>::max(); #else static constexpr int kExplodedMinYear = (sizeof(time_t) == 4 ? 1902 : std::numeric_limits<int>::min()); @@ -840,12 +823,6 @@ // considered to have an ambiguous ordering.) static bool IsConsistentAcrossProcesses() WARN_UNUSED_RESULT; -#if defined(OS_FUCHSIA) - // Converts between TimeTicks and an ZX_CLOCK_MONOTONIC zx_time_t value. - static TimeTicks FromZxTime(zx_time_t nanos_since_boot); - zx_time_t ToZxTime() const; -#endif - #if defined(OS_WIN) // Translates an absolute QPC timestamp into a TimeTicks value. The returned // value has the same origin as Now(). Do NOT attempt to use this if @@ -857,14 +834,6 @@ static TimeTicks FromMachAbsoluteTime(uint64_t mach_absolute_time); #endif // defined(OS_MACOSX) && !defined(OS_IOS) -#if defined(OS_ANDROID) - // Converts to TimeTicks the value obtained from SystemClock.uptimeMillis(). - // Note: this convertion may be non-monotonic in relation to previously - // obtained TimeTicks::Now() values because of the truncation (to - // milliseconds) performed by uptimeMillis(). - static TimeTicks FromUptimeMillis(jlong uptime_millis_value); -#endif - // Get an estimate of the TimeTick value at the time of the UnixEpoch. Because // Time and TimeTicks respond differently to user-set time and NTP // adjustments, this number is only an estimate. Nevertheless, this can be
diff --git a/base/time/time_exploded_posix.cc b/base/time/time_exploded_posix.cc index 26eaed9..ae1b4df 100644 --- a/base/time/time_exploded_posix.cc +++ b/base/time/time_exploded_posix.cc
@@ -34,68 +34,6 @@ // Define a system-specific SysTime that wraps either to a time_t or // a time64_t depending on the host system, and associated convertion. // See crbug.com/162007 -#if defined(OS_ANDROID) && !defined(__LP64__) -typedef time64_t SysTime; - -SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { - base::AutoLock locked(*GetSysTimeToTimeStructLock()); - if (is_local) - return mktime64(timestruct); - else - return timegm64(timestruct); -} - -void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) { - base::AutoLock locked(*GetSysTimeToTimeStructLock()); - if (is_local) - localtime64_r(&t, timestruct); - else - gmtime64_r(&t, timestruct); -} - -#elif defined(OS_AIX) - -// The function timegm is not available on AIX. -time_t aix_timegm(struct tm* tm) { - time_t ret; - char* tz; - - tz = getenv("TZ"); - if (tz) { - tz = strdup(tz); - } - setenv("TZ", "GMT0", 1); - tzset(); - ret = mktime(tm); - if (tz) { - setenv("TZ", tz, 1); - free(tz); - } else { - unsetenv("TZ"); - } - tzset(); - return ret; -} - -typedef time_t SysTime; - -SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { - base::AutoLock locked(*GetSysTimeToTimeStructLock()); - if (is_local) - return mktime(timestruct); - else - return aix_timegm(timestruct); -} - -void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) { - base::AutoLock locked(*GetSysTimeToTimeStructLock()); - if (is_local) - localtime_r(&t, timestruct); - else - gmtime_r(&t, timestruct); -} - -#else // OS_ANDROID && !__LP64__ typedef time_t SysTime; SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { @@ -113,7 +51,6 @@ else gmtime_r(&t, timestruct); } -#endif // OS_ANDROID } // namespace
diff --git a/src/build_config.h b/src/build_config.h index 89d0ff7..addd7cf 100644 --- a/src/build_config.h +++ b/src/build_config.h
@@ -179,8 +179,6 @@ // Type detection for wchar_t. #if defined(OS_WIN) #define WCHAR_T_IS_UTF16 -#elif defined(OS_FUCHSIA) -#define WCHAR_T_IS_UTF32 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) #define WCHAR_T_IS_UTF32 @@ -195,13 +193,4 @@ #error Please add support for your compiler in build_config.h #endif -#if defined(OS_ANDROID) -// The compiler thinks std::string::const_iterator and "const char*" are -// equivalent types. -#define STD_STRING_ITERATOR_IS_CHAR_POINTER -// The compiler thinks base::string16::const_iterator and "char16*" are -// equivalent types. -#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER -#endif - #endif // BUILD_BUILD_CONFIG_H_
diff --git a/tools/gn/args.cc b/tools/gn/args.cc index c7cd60f..f861dd1 100644 --- a/tools/gn/args.cc +++ b/tools/gn/args.cc
@@ -302,14 +302,6 @@ os = "mac"; #elif defined(OS_LINUX) os = "linux"; -#elif defined(OS_ANDROID) - os = "android"; -#elif defined(OS_NETBSD) - os = "netbsd"; -#elif defined(OS_AIX) - os = "aix"; -#elif defined(OS_FUCHSIA) - os = "fuchsia"; #else #error Unknown OS type. #endif