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

Unified Diff: base/metrics/persistent_histogram_allocator.cc

Issue 2938263002: Put BrowserMetrics with embedded profiles into subdir for auto-upload. (Closed)
Patch Set: use std::string::append() where possible Created 3 years, 6 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
« no previous file with comments | « base/metrics/persistent_histogram_allocator.h ('k') | chrome/browser/chrome_browser_field_trials.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_histogram_allocator.cc
diff --git a/base/metrics/persistent_histogram_allocator.cc b/base/metrics/persistent_histogram_allocator.cc
index 13b51b1dba641af0a59078aa763bbe5546aba198..250b74a984fd98d4ad3ca91393b5dbe3745b42a9 100644
--- a/base/metrics/persistent_histogram_allocator.cc
+++ b/base/metrics/persistent_histogram_allocator.cc
@@ -21,6 +21,7 @@
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
+#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
namespace base {
@@ -819,19 +820,43 @@ void GlobalHistogramAllocator::ConstructFilePaths(const FilePath& dir,
FilePath* out_base_path,
FilePath* out_active_path,
FilePath* out_spare_path) {
- if (out_base_path) {
- *out_base_path = dir.AppendASCII(name).AddExtension(
- PersistentMemoryAllocator::kFileExtension);
+ if (out_base_path)
+ *out_base_path = MakeMetricsFilePath(dir, name);
+
+ if (out_active_path) {
+ *out_active_path =
+ MakeMetricsFilePath(dir, name.as_string().append("-active"));
}
+
+ if (out_spare_path) {
+ *out_spare_path =
+ MakeMetricsFilePath(dir, name.as_string().append("-spare"));
+ }
+}
+
+// static
+void GlobalHistogramAllocator::ConstructFilePathsForUploadDir(
+ const FilePath& active_dir,
+ const FilePath& upload_dir,
+ const std::string& name,
+ FilePath* out_upload_path,
+ FilePath* out_active_path,
+ FilePath* out_spare_path) {
+ if (out_upload_path) {
+ std::string name_stamp =
+ StringPrintf("%s-%X", name.c_str(),
+ static_cast<unsigned int>(Time::Now().ToTimeT()));
+ *out_upload_path = MakeMetricsFilePath(upload_dir, name_stamp);
+ }
+
if (out_active_path) {
*out_active_path =
- dir.AppendASCII(name.as_string() + std::string("-active"))
- .AddExtension(PersistentMemoryAllocator::kFileExtension);
+ MakeMetricsFilePath(active_dir, name + std::string("-active"));
}
+
if (out_spare_path) {
*out_spare_path =
- dir.AppendASCII(name.as_string() + std::string("-spare"))
- .AddExtension(PersistentMemoryAllocator::kFileExtension);
+ MakeMetricsFilePath(active_dir, name + std::string("-spare"));
}
}
@@ -1021,4 +1046,11 @@ void GlobalHistogramAllocator::ImportHistogramsToStatisticsRecorder() {
}
}
+// static
+FilePath GlobalHistogramAllocator::MakeMetricsFilePath(const FilePath& dir,
+ StringPiece name) {
+ return dir.AppendASCII(name).AddExtension(
+ PersistentMemoryAllocator::kFileExtension);
+}
+
} // namespace base
« no previous file with comments | « base/metrics/persistent_histogram_allocator.h ('k') | chrome/browser/chrome_browser_field_trials.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698