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

Unified Diff: base/metrics/persistent_histogram_allocator.cc

Issue 2938263002: Put BrowserMetrics with embedded profiles into subdir for auto-upload. (Closed)
Patch Set: rebased 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
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..462515a377172eb1045e1d92733fe9992ca1578c 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 {
@@ -836,6 +837,34 @@ void GlobalHistogramAllocator::ConstructFilePaths(const FilePath& dir,
}
// 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 =
+ upload_dir.AppendASCII(name_stamp)
+ .AddExtension(PersistentMemoryAllocator::kFileExtension);
Alexei Svitkine (slow) 2017/06/28 17:30:35 Nit: Given this pattern is used a lot, make a help
bcwhite 2017/06/28 18:52:08 Done.
+ }
+ if (out_active_path) {
+ *out_active_path =
+ active_dir.AppendASCII(name + std::string("-active"))
+ .AddExtension(PersistentMemoryAllocator::kFileExtension);
+ }
+ if (out_spare_path) {
+ *out_spare_path =
+ active_dir.AppendASCII(name + std::string("-spare"))
+ .AddExtension(PersistentMemoryAllocator::kFileExtension);
+ }
+}
+
+// static
bool GlobalHistogramAllocator::CreateSpareFile(const FilePath& spare_path,
size_t size) {
FilePath temp_spare_path = spare_path.AddExtension(FILE_PATH_LITERAL(".tmp"));

Powered by Google App Engine
This is Rietveld 408576698