Index: base/test/perf_log.cc |
diff --git a/base/test/perf_log.cc b/base/test/perf_log.cc |
index 22884b8e69b0953ad01de9b16d3c31435116daba..27f9a351bab645e16e23c93204ebcb1639426c5b 100644 |
--- a/base/test/perf_log.cc |
+++ b/base/test/perf_log.cc |
@@ -4,21 +4,38 @@ |
#include "base/test/perf_log.h" |
+#include "base/command_line.h" |
+#include "base/files/file_path.h" |
#include "base/files/file_util.h" |
#include "base/logging.h" |
+#include "base/path_service.h" |
+#include "build/build_config.h" |
namespace base { |
static FILE* perf_log_file = NULL; |
-bool InitPerfLog(const FilePath& log_file) { |
+bool InitPerfLog() { |
if (perf_log_file) { |
// trying to initialize twice |
NOTREACHED(); |
return false; |
} |
- perf_log_file = OpenFile(log_file, "w"); |
+ FilePath log_path = |
+ CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); |
+ if (log_path.empty()) { |
+ PathService::Get(FILE_EXE, &log_path); |
+#if defined(OS_ANDROID) |
+ base::FilePath tmp_dir; |
+ PathService::Get(base::DIR_CACHE, &tmp_dir); |
+ log_path = tmp_dir.Append(log_path.BaseName()); |
+#endif |
+ log_path = log_path.ReplaceExtension(FILE_PATH_LITERAL("log")); |
+ log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); |
+ } |
+ |
+ perf_log_file = OpenFile(log_path, "w"); |
return perf_log_file != NULL; |
} |