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

Side by Side Diff: components/metrics/file_metrics_provider.cc

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed some build problems Created 4 years, 8 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 "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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.get()); 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 = histogram_iter.GetNext(); 182 scoped_ptr<base::HistogramBase> histogram = histogram_iter.GetNext();
183 if (!histogram) 183 if (!histogram)
184 break; 184 break;
185 if (file->type == FILE_HISTOGRAMS_ATOMIC) 185 if (file->type == FILE_HISTOGRAMS_ATOMIC)
186 snapshot_manager->PrepareAbsoluteTakingOwnership(std::move(histogram)); 186 snapshot_manager->PrepareDifferenceTakingOwnership(std::move(histogram));
Ilya Sherman 2016/04/19 00:57:46 So, why is it important here that we take the (ide
bcwhite 2016/04/19 16:33:38 Because in some situations, the data may be read-o
Ilya Sherman 2016/04/20 07:12:14 I'd prefer to back-out the PrepareDifference chang
bcwhite 2016/04/20 16:47:45 Done.
187 else 187 else
188 snapshot_manager->PrepareDeltaTakingOwnership(std::move(histogram)); 188 snapshot_manager->PrepareDeltaTakingOwnership(std::move(histogram));
189 ++histogram_count; 189 ++histogram_count;
190 } 190 }
191 191
192 DVLOG(1) << "Reported " << histogram_count << " histograms from " 192 DVLOG(1) << "Reported " << histogram_count << " histograms from "
193 << file->path.value(); 193 << file->path.value();
194 } 194 }
195 195
196 void FileMetricsProvider::CreateAllocatorForFile(FileInfo* file) { 196 void FileMetricsProvider::CreateAllocatorForFile(FileInfo* file) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (file->type == FILE_HISTOGRAMS_ATOMIC) { 282 if (file->type == FILE_HISTOGRAMS_ATOMIC) {
283 DCHECK(!file->mapped); 283 DCHECK(!file->mapped);
284 file->allocator.reset(); 284 file->allocator.reset();
285 file->data.clear(); 285 file->data.clear();
286 RecordFileAsSeen(file.get()); 286 RecordFileAsSeen(file.get());
287 } 287 }
288 } 288 }
289 } 289 }
290 290
291 } // namespace metrics 291 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698