| OLD | NEW |
| 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/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 LOG(ERROR) << "Could not write \"" << Name() << "\" persistent histograms" | 898 LOG(ERROR) << "Could not write \"" << Name() << "\" persistent histograms" |
| 899 << " to file: " << persistent_location_.value(); | 899 << " to file: " << persistent_location_.value(); |
| 900 return false; | 900 return false; |
| 901 } | 901 } |
| 902 | 902 |
| 903 return true; | 903 return true; |
| 904 #endif | 904 #endif |
| 905 } | 905 } |
| 906 | 906 |
| 907 void GlobalHistogramAllocator::DeletePersistentLocation() { | 907 void GlobalHistogramAllocator::DeletePersistentLocation() { |
| 908 memory_allocator()->SetMemoryState(PersistentMemoryAllocator::MEMORY_DELETED); |
| 909 |
| 908 #if defined(OS_NACL) | 910 #if defined(OS_NACL) |
| 909 NOTREACHED(); | 911 NOTREACHED(); |
| 910 #else | 912 #else |
| 911 if (persistent_location_.empty()) | 913 if (persistent_location_.empty()) |
| 912 return; | 914 return; |
| 913 | 915 |
| 914 // Open (with delete) and then immediately close the file by going out of | 916 // Open (with delete) and then immediately close the file by going out of |
| 915 // scope. This is the only cross-platform safe way to delete a file that may | 917 // scope. This is the only cross-platform safe way to delete a file that may |
| 916 // be open elsewhere. Open handles will continue to operate normally but | 918 // be open elsewhere. Open handles will continue to operate normally but |
| 917 // new opens will not be possible. | 919 // new opens will not be possible. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 944 while (true) { | 946 while (true) { |
| 945 std::unique_ptr<HistogramBase> histogram = | 947 std::unique_ptr<HistogramBase> histogram = |
| 946 import_iterator_.GetNextWithIgnore(record_to_ignore); | 948 import_iterator_.GetNextWithIgnore(record_to_ignore); |
| 947 if (!histogram) | 949 if (!histogram) |
| 948 break; | 950 break; |
| 949 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); | 951 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); |
| 950 } | 952 } |
| 951 } | 953 } |
| 952 | 954 |
| 953 } // namespace base | 955 } // namespace base |
| OLD | NEW |