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 <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43577
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc
index d6fb3a4..990ef03 100644
--- a/crash_reporter/crash_collector.cc
+++ b/crash_reporter/crash_collector.cc
@@ -54,6 +54,8 @@
// 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 650f536..3f0a27d 100644
--- a/crash_reporter/crash_collector.h
+++ b/crash_reporter/crash_collector.h
@@ -60,7 +60,7 @@
// 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 @@
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 @@
// 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 @@
// 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 [<key><separator><value>\n...] and return
// a map of its contents.
- bool ReadKeyValueFile(const FilePath &file,
+ bool ReadKeyValueFile(const base::FilePath &file,
char separator,
std::map<std::string, std::string> *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 @@
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 @@
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 2635bbf..fff22b5 100644
--- a/crash_reporter/crash_collector_test.cc
+++ b/crash_reporter/crash_collector_test.cc
@@ -19,6 +19,7 @@
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 401448e..e76c5c8 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -41,7 +41,6 @@
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 @@
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 83eca8a..5790140 100644
--- a/crash_reporter/kernel_collector.cc
+++ b/crash_reporter/kernel_collector.cc
@@ -45,6 +45,8 @@
" 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 b4f3c1a..17b55a0 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 @@
virtual ~KernelCollector();
- void OverridePreservedDumpPath(const FilePath &file_path);
+ void OverridePreservedDumpPath(const base::FilePath &file_path);
// Enable collection.
bool Enable();
@@ -66,7 +64,7 @@
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 @@
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 ee96f05..2dc50b4 100644
--- a/crash_reporter/kernel_collector_test.cc
+++ b/crash_reporter/kernel_collector_test.cc
@@ -19,6 +19,7 @@
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 138ec4b..4e4b213 100644
--- a/crash_reporter/udev_collector.cc
+++ b/crash_reporter/udev_collector.cc
@@ -16,6 +16,8 @@
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 acb09cb..29c19ef 100644
--- a/crash_reporter/udev_collector.h
+++ b/crash_reporter/udev_collector.h
@@ -7,11 +7,10 @@
#include <string>
+#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 @@
// 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 4d2bbe6..31fdbf4 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 ad7386f..b1462ad 100644
--- a/crash_reporter/unclean_shutdown_collector.cc
+++ b/crash_reporter/unclean_shutdown_collector.cc
@@ -17,6 +17,8 @@
// 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 7e10e7f..37eb4df 100644
--- a/crash_reporter/unclean_shutdown_collector.h
+++ b/crash_reporter/unclean_shutdown_collector.h
@@ -40,9 +40,9 @@
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 8adb4d3..1bb0c94 100644
--- a/crash_reporter/unclean_shutdown_collector_test.cc
+++ b/crash_reporter/unclean_shutdown_collector_test.cc
@@ -20,6 +20,7 @@
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 26c7dc1..a89ea81 100644
--- a/crash_reporter/user_collector.cc
+++ b/crash_reporter/user_collector.cc
@@ -53,6 +53,8 @@
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 26f2b72..c7ac0de 100644
--- a/crash_reporter/user_collector.h
+++ b/crash_reporter/user_collector.h
@@ -8,10 +8,10 @@
#include <string>
#include <vector>
+#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 @@
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 @@
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/<pid>/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 4c919de..d1a3bcf 100644
--- a/crash_reporter/user_collector_test.cc
+++ b/crash_reporter/user_collector_test.cc
@@ -20,6 +20,7 @@
static const char kFilePath[] = "/my/path";
+using base::FilePath;
using chromeos::FindLog;
void CountCrash() {