Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Unified Diff: base/test/perf_log.cc

Issue 2358063002: Preparing components_perftests (Closed)
Patch Set: Attempt to guess how generate_perf_json.py works Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698