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

Side by Side Diff: base/metrics/persistent_histogram_allocator.cc

Issue 2010173005: Support experiment to store persistent metrics in memory-mapped file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/persistent_histogram_allocator.h" 5 #include "base/metrics/persistent_histogram_allocator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } 805 }
806 806
807 g_allocator = nullptr; 807 g_allocator = nullptr;
808 return WrapUnique(histogram_allocator); 808 return WrapUnique(histogram_allocator);
809 }; 809 };
810 810
811 void GlobalHistogramAllocator::SetPersistentLocation(const FilePath& location) { 811 void GlobalHistogramAllocator::SetPersistentLocation(const FilePath& location) {
812 persistent_location_ = location; 812 persistent_location_ = location;
813 } 813 }
814 814
815 const FilePath& GlobalHistogramAllocator::GetPersistentLocation() {
816 return persistent_location_;
817 }
818
815 bool GlobalHistogramAllocator::WriteToPersistentLocation() { 819 bool GlobalHistogramAllocator::WriteToPersistentLocation() {
816 #if defined(OS_NACL) 820 #if defined(OS_NACL)
817 // NACL doesn't support file operations, including ImportantFileWriter. 821 // NACL doesn't support file operations, including ImportantFileWriter.
818 NOTREACHED(); 822 NOTREACHED();
819 return false; 823 return false;
820 #else 824 #else
821 // Stop if no destination is set. 825 // Stop if no destination is set.
822 if (persistent_location_.empty()) { 826 if (persistent_location_.empty()) {
823 NOTREACHED() << "Could not write \"" << Name() << "\" persistent histograms" 827 NOTREACHED() << "Could not write \"" << Name() << "\" persistent histograms"
824 << " to file because no location was set."; 828 << " to file because no location was set.";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 while (true) { 861 while (true) {
858 std::unique_ptr<HistogramBase> histogram = 862 std::unique_ptr<HistogramBase> histogram =
859 import_iterator_.GetNextWithIgnore(record_to_ignore); 863 import_iterator_.GetNextWithIgnore(record_to_ignore);
860 if (!histogram) 864 if (!histogram)
861 break; 865 break;
862 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); 866 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release());
863 } 867 }
864 } 868 }
865 869
866 } // namespace base 870 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698