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_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 base::Bind(&FileMetricsProvider::CheckAndMapNewMetricFilesOnTaskRunner, | 167 base::Bind(&FileMetricsProvider::CheckAndMapNewMetricFilesOnTaskRunner, |
168 base::Unretained(check_list)), | 168 base::Unretained(check_list)), |
169 base::Bind(&FileMetricsProvider::RecordFilesChecked, | 169 base::Bind(&FileMetricsProvider::RecordFilesChecked, |
170 weak_factory_.GetWeakPtr(), base::Owned(check_list))); | 170 weak_factory_.GetWeakPtr(), base::Owned(check_list))); |
171 } | 171 } |
172 | 172 |
173 void FileMetricsProvider::RecordHistogramSnapshotsFromFile( | 173 void FileMetricsProvider::RecordHistogramSnapshotsFromFile( |
174 base::HistogramSnapshotManager* snapshot_manager, | 174 base::HistogramSnapshotManager* snapshot_manager, |
175 FileInfo* file) { | 175 FileInfo* file) { |
176 DCHECK(thread_checker_.CalledOnValidThread()); | 176 DCHECK(thread_checker_.CalledOnValidThread()); |
177 base::PersistentHistogramAllocator::Iterator histogram_iter; | 177 base::PersistentHistogramAllocator::Iterator histogram_iter( |
178 file->allocator->CreateIterator(&histogram_iter); | 178 file->allocator.get()); |
179 | 179 |
180 int histogram_count = 0; | 180 int histogram_count = 0; |
181 while (true) { | 181 while (true) { |
182 scoped_ptr<base::HistogramBase> histogram = | 182 scoped_ptr<base::HistogramBase> histogram = histogram_iter.GetNext(); |
183 file->allocator->GetNextHistogram(&histogram_iter); | |
184 if (!histogram) | 183 if (!histogram) |
185 break; | 184 break; |
186 if (file->type == FILE_HISTOGRAMS_ATOMIC) | 185 if (file->type == FILE_HISTOGRAMS_ATOMIC) |
187 snapshot_manager->PrepareAbsoluteTakingOwnership(std::move(histogram)); | 186 snapshot_manager->PrepareAbsoluteTakingOwnership(std::move(histogram)); |
188 else | 187 else |
189 snapshot_manager->PrepareDeltaTakingOwnership(std::move(histogram)); | 188 snapshot_manager->PrepareDeltaTakingOwnership(std::move(histogram)); |
190 ++histogram_count; | 189 ++histogram_count; |
191 } | 190 } |
192 | 191 |
193 DVLOG(1) << "Reported " << histogram_count << " histograms from " | 192 DVLOG(1) << "Reported " << histogram_count << " histograms from " |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (file->type == FILE_HISTOGRAMS_ATOMIC) { | 282 if (file->type == FILE_HISTOGRAMS_ATOMIC) { |
284 DCHECK(!file->mapped); | 283 DCHECK(!file->mapped); |
285 file->allocator.reset(); | 284 file->allocator.reset(); |
286 file->data.clear(); | 285 file->data.clear(); |
287 RecordFileAsSeen(file.get()); | 286 RecordFileAsSeen(file.get()); |
288 } | 287 } |
289 } | 288 } |
290 } | 289 } |
291 | 290 |
292 } // namespace metrics | 291 } // namespace metrics |
OLD | NEW |