From 9f90acaa4d420530d7b4ddd37112518df68e373a Mon Sep 17 00:00:00 2001 From: Simon Que Date: Tue, 19 Feb 2013 17:19:52 -0800 Subject: [PATCH] Replace FilePath declaration with file_path.h include Fixes a clang error. Also use "base::FilePath" since FilePath has been moved to the base namespace. BUG=chromium-os:39046 TEST=The following command passes: USE="chrome_internal" CFLAGS="-clang -print-cmdline" CXXFLAGS="-clang -print-cmdline" emerge-x86-alex crash-reporter Change-Id: I7da82093c5685b5b556cba971b1e1b14ac0f59c4 Signed-off-by: Simon Que Reviewed-on: https://gerrit.chromium.org/gerrit/43577 Reviewed-by: Ben Chan --- crash_reporter/crash_collector.cc | 2 ++ crash_reporter/crash_collector.h | 24 +++++++------- crash_reporter/crash_collector_test.cc | 1 + crash_reporter/crash_reporter.cc | 3 +- crash_reporter/kernel_collector.cc | 2 ++ crash_reporter/kernel_collector.h | 8 ++--- crash_reporter/kernel_collector_test.cc | 1 + crash_reporter/udev_collector.cc | 2 ++ crash_reporter/udev_collector.h | 5 ++- crash_reporter/udev_collector_test.cc | 2 ++ crash_reporter/unclean_shutdown_collector.cc | 2 ++ crash_reporter/unclean_shutdown_collector.h | 6 ++-- .../unclean_shutdown_collector_test.cc | 1 + crash_reporter/user_collector.cc | 2 ++ crash_reporter/user_collector.h | 32 +++++++++---------- crash_reporter/user_collector_test.cc | 1 + 16 files changed, 54 insertions(+), 40 deletions(-) diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc index d6fb3a4f0..990ef034f 100644 --- a/crash_reporter/crash_collector.cc +++ b/crash_reporter/crash_collector.cc @@ -54,6 +54,8 @@ static const uid_t kRootGroup = 0; // number of core files or minidumps reaches this number. const int CrashCollector::kMaxCrashDirectorySize = 32; +using base::FilePath; + CrashCollector::CrashCollector() : forced_crash_directory_(NULL), lsb_release_(kLsbRelease), diff --git a/crash_reporter/crash_collector.h b/crash_reporter/crash_collector.h index 650f5366a..3f0a27d99 100644 --- a/crash_reporter/crash_collector.h +++ b/crash_reporter/crash_collector.h @@ -60,7 +60,7 @@ class CrashCollector { // Writes |data| of |size| to |filename|, which must be a new file. // If the file already exists or writing fails, return a negative value. // Otherwise returns the number of bytes written. - int WriteNewFile(const FilePath &filename, const char *data, int size); + int WriteNewFile(const base::FilePath &filename, const char *data, int size); // Return a filename that has only [a-z0-1_] characters by mapping // all others into '_'. @@ -72,7 +72,7 @@ class CrashCollector { forced_crash_directory_ = forced_directory; } - FilePath GetCrashDirectoryInfo(uid_t process_euid, + base::FilePath GetCrashDirectoryInfo(uid_t process_euid, uid_t default_user_id, gid_t default_user_group, mode_t *mode, @@ -88,7 +88,7 @@ class CrashCollector { // true whether or not directory needed to be created, false on any // failure. If the crash directory is at capacity, returns false. bool GetCreatedCrashDirectoryByEuid(uid_t euid, - FilePath *crash_file_path, + base::FilePath *crash_file_path, bool *out_of_capacity); // Format crash name based on components. @@ -98,28 +98,28 @@ class CrashCollector { // Create a file path to a file in |crash_directory| with the given // |basename| and |extension|. - FilePath GetCrashPath(const FilePath &crash_directory, - const std::string &basename, - const std::string &extension); + base::FilePath GetCrashPath(const base::FilePath &crash_directory, + const std::string &basename, + const std::string &extension); // Check given crash directory still has remaining capacity for another // crash. - bool CheckHasCapacity(const FilePath &crash_directory); + bool CheckHasCapacity(const base::FilePath &crash_directory); // Checks if the line starts with '#' after optional whitespace. static bool IsCommentLine(const std::string &line); // Read the given file of form [\n...] and return // a map of its contents. - bool ReadKeyValueFile(const FilePath &file, + bool ReadKeyValueFile(const base::FilePath &file, char separator, std::map *dictionary); // Write a log applicable to |exec_name| to |output_file| based on the // log configuration file at |config_path|. - bool GetLogContents(const FilePath &config_path, + bool GetLogContents(const base::FilePath &config_path, const std::string &exec_name, - const FilePath &output_file); + const base::FilePath &output_file); // Add non-standard meta data to the crash metadata file. Call // before calling WriteCrashMetaData. Key must not contain "=" or @@ -127,7 +127,7 @@ class CrashCollector { void AddCrashMetaData(const std::string &key, const std::string &value); // Write a file of metadata about crash. - void WriteCrashMetaData(const FilePath &meta_path, + void WriteCrashMetaData(const base::FilePath &meta_path, const std::string &exec_name, const std::string &payload_path); @@ -146,7 +146,7 @@ class CrashCollector { std::string extra_metadata_; const char *forced_crash_directory_; const char *lsb_release_; - FilePath log_config_path_; + base::FilePath log_config_path_; }; #endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ diff --git a/crash_reporter/crash_collector_test.cc b/crash_reporter/crash_collector_test.cc index 2635bbfcc..fff22b53f 100644 --- a/crash_reporter/crash_collector_test.cc +++ b/crash_reporter/crash_collector_test.cc @@ -19,6 +19,7 @@ static const char kBinCp[] = "/bin/cp"; static const char kBinEcho[] = "/bin/echo"; static const char kBinFalse[] = "/bin/false"; +using base::FilePath; using chromeos::FindLog; void CountCrash() { diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc index 401448e7f..e76c5c82f 100644 --- a/crash_reporter/crash_reporter.cc +++ b/crash_reporter/crash_reporter.cc @@ -41,7 +41,6 @@ static const char kKernelCrashDetected[] = "/var/run/kernel-crash-detected"; static const char kUncleanShutdownDetected[] = "/var/run/unclean-shutdown-detected"; - // Enumeration of kinds of crashes to be used in the CrashCounter histogram. enum CrashKinds { kCrashKindUncleanShutdown = 1, @@ -53,6 +52,8 @@ enum CrashKinds { static MetricsLibrary s_metrics_lib; +using base::FilePath; + static bool IsFeedbackAllowed() { return s_metrics_lib.AreMetricsEnabled(); } diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc index 83eca8a16..579014001 100644 --- a/crash_reporter/kernel_collector.cc +++ b/crash_reporter/kernel_collector.cc @@ -45,6 +45,8 @@ static const char *s_pc_regex[] = { " RIP \\[<.*>\\] ([^\\+ ]+).*", // X86_64 uses RIP for the program counter }; +using base::FilePath; + COMPILE_ASSERT(arraysize(s_pc_regex) == KernelCollector::archCount, missing_arch_pc_regexp); diff --git a/crash_reporter/kernel_collector.h b/crash_reporter/kernel_collector.h index b4f3c1a70..17b55a0fe 100644 --- a/crash_reporter/kernel_collector.h +++ b/crash_reporter/kernel_collector.h @@ -13,8 +13,6 @@ #include "crash-reporter/crash_collector.h" #include "gtest/gtest_prod.h" // for FRIEND_TEST -class FilePath; - // Kernel crash collector. class KernelCollector : public CrashCollector { public: @@ -32,7 +30,7 @@ class KernelCollector : public CrashCollector { virtual ~KernelCollector(); - void OverridePreservedDumpPath(const FilePath &file_path); + void OverridePreservedDumpPath(const base::FilePath &file_path); // Enable collection. bool Enable(); @@ -66,7 +64,7 @@ class KernelCollector : public CrashCollector { bool LoadPreservedDump(std::string *contents); void StripSensitiveData(std::string *kernel_dump); - void GetRamoopsRecordPath(FilePath *path, size_t record); + void GetRamoopsRecordPath(base::FilePath *path, size_t record); virtual bool LoadParameters(); bool HasMoreRecords(); @@ -98,7 +96,7 @@ class KernelCollector : public CrashCollector { enum ArchKind GetCompilerArch(void); bool is_enabled_; - FilePath ramoops_dump_path_; + base::FilePath ramoops_dump_path_; size_t records_; // The architecture of kernel dump strings we are working with. diff --git a/crash_reporter/kernel_collector_test.cc b/crash_reporter/kernel_collector_test.cc index ee96f058e..2dc50b403 100644 --- a/crash_reporter/kernel_collector_test.cc +++ b/crash_reporter/kernel_collector_test.cc @@ -19,6 +19,7 @@ static bool s_metrics = false; static const char kTestKCrash[] = "test/kcrash"; static const char kTestCrashDirectory[] = "test/crash_directory"; +using base::FilePath; using chromeos::FindLog; using chromeos::GetLog; diff --git a/crash_reporter/udev_collector.cc b/crash_reporter/udev_collector.cc index 138ec4bda..4e4b21340 100644 --- a/crash_reporter/udev_collector.cc +++ b/crash_reporter/udev_collector.cc @@ -16,6 +16,8 @@ static const char kGzipPath[] = "/bin/gzip"; static const char kUdevExecName[] = "udev"; static const char kUdevSignatureKey[] = "sig"; +using base::FilePath; + UdevCollector::UdevCollector() {} UdevCollector::~UdevCollector() {} diff --git a/crash_reporter/udev_collector.h b/crash_reporter/udev_collector.h index acb09cba0..29c19ef78 100644 --- a/crash_reporter/udev_collector.h +++ b/crash_reporter/udev_collector.h @@ -7,11 +7,10 @@ #include +#include "base/file_path.h" #include "crash-reporter/crash_collector.h" #include "gtest/gtest_prod.h" // for FRIEND_TEST -class FilePath; - // Udev crash collector. class UdevCollector : public CrashCollector { public: @@ -30,7 +29,7 @@ class UdevCollector : public CrashCollector { // Mutator for unit testing. void set_log_config_path(const std::string& path) { - log_config_path_ = FilePath(path); + log_config_path_ = base::FilePath(path); } }; diff --git a/crash_reporter/udev_collector_test.cc b/crash_reporter/udev_collector_test.cc index 4d2bbe6db..31fdbf4f7 100644 --- a/crash_reporter/udev_collector_test.cc +++ b/crash_reporter/udev_collector_test.cc @@ -9,6 +9,8 @@ #include "crash-reporter/udev_collector.h" #include "gtest/gtest.h" +using base::FilePath; + namespace { // Dummy log config file name. diff --git a/crash_reporter/unclean_shutdown_collector.cc b/crash_reporter/unclean_shutdown_collector.cc index ad7386f26..b1462ad37 100644 --- a/crash_reporter/unclean_shutdown_collector.cc +++ b/crash_reporter/unclean_shutdown_collector.cc @@ -17,6 +17,8 @@ static const char kPowerdSuspended[] = "powerd_suspended"; // Presence of this file indicates that the battery was critically low. static const char kPowerdLowBattery[] = "powerd_low_battery"; +using base::FilePath; + UncleanShutdownCollector::UncleanShutdownCollector() : unclean_shutdown_file_(kUncleanShutdownFile), powerd_trace_path_(kPowerdTracePath), diff --git a/crash_reporter/unclean_shutdown_collector.h b/crash_reporter/unclean_shutdown_collector.h index 7e10e7f28..37eb4dffb 100644 --- a/crash_reporter/unclean_shutdown_collector.h +++ b/crash_reporter/unclean_shutdown_collector.h @@ -40,9 +40,9 @@ class UncleanShutdownCollector : public CrashCollector { bool DeadBatteryCausedUncleanShutdown(); const char *unclean_shutdown_file_; - FilePath powerd_trace_path_; - FilePath powerd_suspended_file_; - FilePath powerd_low_battery_file_; + base::FilePath powerd_trace_path_; + base::FilePath powerd_suspended_file_; + base::FilePath powerd_low_battery_file_; }; #endif // _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ diff --git a/crash_reporter/unclean_shutdown_collector_test.cc b/crash_reporter/unclean_shutdown_collector_test.cc index 8adb4d384..1bb0c9431 100644 --- a/crash_reporter/unclean_shutdown_collector_test.cc +++ b/crash_reporter/unclean_shutdown_collector_test.cc @@ -20,6 +20,7 @@ static const char kTestLowBattery[] = "test/low_battery"; static const char kTestSuspended[] = "test/suspended"; static const char kTestUnclean[] = "test/unclean"; +using base::FilePath; using ::chromeos::FindLog; void CountCrash() { diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc index 26c7dc1ea..a89ea8169 100644 --- a/crash_reporter/user_collector.cc +++ b/crash_reporter/user_collector.cc @@ -53,6 +53,8 @@ static const uid_t kUnknownUid = -1; const char *UserCollector::kUserId = "Uid:\t"; const char *UserCollector::kGroupId = "Gid:\t"; +using base::FilePath; + UserCollector::UserCollector() : generate_diagnostics_(false), core_pattern_file_(kCorePatternFile), diff --git a/crash_reporter/user_collector.h b/crash_reporter/user_collector.h index 26f2b721c..c7ac0de50 100644 --- a/crash_reporter/user_collector.h +++ b/crash_reporter/user_collector.h @@ -8,10 +8,10 @@ #include #include +#include "base/file_path.h" #include "crash-reporter/crash_collector.h" #include "gtest/gtest_prod.h" // for FRIEND_TEST -class FilePath; class SystemLogging; // User crash collector. @@ -101,9 +101,9 @@ class UserCollector : public CrashCollector { std::string GetPattern(bool enabled) const; bool SetUpInternal(bool enabled); - FilePath GetProcessPath(pid_t pid); - bool GetSymlinkTarget(const FilePath &symlink, - FilePath *target); + base::FilePath GetProcessPath(pid_t pid); + bool GetSymlinkTarget(const base::FilePath &symlink, + base::FilePath *target); bool GetExecutableBaseNameFromPid(pid_t pid, std::string *base_name); // Returns, via |line|, the first line in |lines| that starts with |prefix|. @@ -129,38 +129,38 @@ class UserCollector : public CrashCollector { void EnqueueCollectionErrorLog(pid_t pid, ErrorType error_type, const std::string &exec_name); - bool CopyOffProcFiles(pid_t pid, const FilePath &container_dir); + bool CopyOffProcFiles(pid_t pid, const base::FilePath &container_dir); // Validates the proc files at |container_dir| and returns true if they // are usable for the core-to-minidump conversion later. For instance, if // a process is reaped by the kernel before the copying of its proc files // takes place, some proc files like /proc//maps may contain nothing // and thus become unusable. - bool ValidateProcFiles(const FilePath &container_dir) const; + bool ValidateProcFiles(const base::FilePath &container_dir) const; // Validates the core file at |core_path| and returns kErrorNone if // the file contains the ELF magic bytes and an ELF class that matches the // platform (i.e. 32-bit ELF on a 32-bit platform or 64-bit ELF on a 64-bit // platform), which is due to the limitation in core2md. It returns an error // type otherwise. - ErrorType ValidateCoreFile(const FilePath &core_path) const; + ErrorType ValidateCoreFile(const base::FilePath &core_path) const; // Determines the crash directory for given pid based on pid's owner, // and creates the directory if necessary with appropriate permissions. // Returns true whether or not directory needed to be created, false on // any failure. bool GetCreatedCrashDirectory(pid_t pid, uid_t supplied_ruid, - FilePath *crash_file_path, + base::FilePath *crash_file_path, bool *out_of_capacity); - bool CopyStdinToCoreFile(const FilePath &core_path); - bool RunCoreToMinidump(const FilePath &core_path, - const FilePath &procfs_directory, - const FilePath &minidump_path, - const FilePath &temp_directory); + bool CopyStdinToCoreFile(const base::FilePath &core_path); + bool RunCoreToMinidump(const base::FilePath &core_path, + const base::FilePath &procfs_directory, + const base::FilePath &minidump_path, + const base::FilePath &temp_directory); ErrorType ConvertCoreToMinidump(pid_t pid, - const FilePath &container_dir, - const FilePath &core_path, - const FilePath &minidump_path); + const base::FilePath &container_dir, + const base::FilePath &core_path, + const base::FilePath &minidump_path); ErrorType ConvertAndEnqueueCrash(pid_t pid, const std::string &exec_name, uid_t supplied_ruid, bool *out_of_capacity); bool ParseCrashAttributes(const std::string &crash_attributes, diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc index 4c919ded8..d1a3bcf04 100644 --- a/crash_reporter/user_collector_test.cc +++ b/crash_reporter/user_collector_test.cc @@ -20,6 +20,7 @@ static bool s_metrics = false; static const char kFilePath[] = "/my/path"; +using base::FilePath; using chromeos::FindLog; void CountCrash() {