| 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 "components/metrics/file_metrics_provider.h" | 5 #include "components/metrics/file_metrics_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 // Test the validity of the file contents. | 319 // Test the validity of the file contents. |
| 320 const bool read_only = kSourceOptions[source->type].is_read_only; | 320 const bool read_only = kSourceOptions[source->type].is_read_only; |
| 321 if (!base::FilePersistentMemoryAllocator::IsFileAcceptable(*mapped, | 321 if (!base::FilePersistentMemoryAllocator::IsFileAcceptable(*mapped, |
| 322 read_only)) { | 322 read_only)) { |
| 323 return ACCESS_RESULT_INVALID_CONTENTS; | 323 return ACCESS_RESULT_INVALID_CONTENTS; |
| 324 } | 324 } |
| 325 | 325 |
| 326 // Create an allocator for the mapped file. Ownership passes to the allocator. | 326 // Create an allocator for the mapped file. Ownership passes to the allocator. |
| 327 source->allocator.reset(new base::PersistentHistogramAllocator( | 327 source->allocator.reset(new base::PersistentHistogramAllocator( |
| 328 base::WrapUnique(new base::FilePersistentMemoryAllocator( | 328 base::MakeUnique<base::FilePersistentMemoryAllocator>( |
| 329 std::move(mapped), 0, 0, base::StringPiece(), read_only)))); | 329 std::move(mapped), 0, 0, base::StringPiece(), read_only))); |
| 330 | 330 |
| 331 return ACCESS_RESULT_SUCCESS; | 331 return ACCESS_RESULT_SUCCESS; |
| 332 } | 332 } |
| 333 | 333 |
| 334 // static | 334 // static |
| 335 void FileMetricsProvider::MergeHistogramDeltasFromSource(SourceInfo* source) { | 335 void FileMetricsProvider::MergeHistogramDeltasFromSource(SourceInfo* source) { |
| 336 DCHECK(source->allocator); | 336 DCHECK(source->allocator); |
| 337 base::PersistentHistogramAllocator::Iterator histogram_iter( | 337 base::PersistentHistogramAllocator::Iterator histogram_iter( |
| 338 source->allocator.get()); | 338 source->allocator.get()); |
| 339 | 339 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 544 |
| 545 // Dump all histograms contained within the source to the snapshot-manager. | 545 // Dump all histograms contained within the source to the snapshot-manager. |
| 546 RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); | 546 RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); |
| 547 | 547 |
| 548 // Update the last-seen time so it isn't read again unless it changes. | 548 // Update the last-seen time so it isn't read again unless it changes. |
| 549 RecordSourceAsRead(source.get()); | 549 RecordSourceAsRead(source.get()); |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 | 552 |
| 553 } // namespace metrics | 553 } // namespace metrics |
| OLD | NEW |