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

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

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 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 // Gets a pointer to the global histogram allocator. 235 // Gets a pointer to the global histogram allocator.
236 static GlobalHistogramAllocator* Get(); 236 static GlobalHistogramAllocator* Get();
237 237
238 // This access to the persistent allocator is only for testing; it extracts 238 // This access to the persistent allocator is only for testing; it extracts
239 // the current allocator completely. This allows easy creation of histograms 239 // the current allocator completely. This allows easy creation of histograms
240 // within persistent memory segments which can then be extracted and used 240 // within persistent memory segments which can then be extracted and used
241 // in other ways. 241 // in other ways.
242 static std::unique_ptr<GlobalHistogramAllocator> ReleaseForTesting(); 242 static std::unique_ptr<GlobalHistogramAllocator> ReleaseForTesting();
243 243
244 // Stores a pathname to which the contents of this allocator should be saved
245 // in order to persist the data for a later use.
246 void SetPersistentLocation(FilePath location);
Ilya Sherman 2016/04/19 00:57:46 nit: Are FilePaths usually passed by copy or by co
bcwhite 2016/04/19 16:33:38 I've seen it both ways. If I make this a ref then
Ilya Sherman 2016/04/20 07:12:14 There was recently a thread on chromium-dev about
bcwhite 2016/04/20 16:47:45 Interesting. Better to pass-by-ref for maintainab
247
248 // Writes the internal data to a previously set location. This is generally
249 // called when a process is exiting from a section of code that may not know
250 // the filesystem. The data is written in an atomic manner. The return value
251 // indicates success.
252 bool WritePersistentLocation();
Ilya Sherman 2016/04/19 00:57:46 nit: Perhaps "WriteTo" rather than just "Write"?
bcwhite 2016/04/19 16:33:38 Done.
253
244 private: 254 private:
245 friend class StatisticsRecorder; 255 friend class StatisticsRecorder;
246 256
247 explicit GlobalHistogramAllocator( 257 explicit GlobalHistogramAllocator(
248 std::unique_ptr<PersistentMemoryAllocator> memory); 258 std::unique_ptr<PersistentMemoryAllocator> memory);
249 259
250 // Import new histograms from the global histogram allocator. It's possible 260 // Import new histograms from the global histogram allocator. It's possible
251 // for other processes to create histograms in the active memory segment; 261 // for other processes to create histograms in the active memory segment;
252 // this adds those to the internal list of known histograms to avoid creating 262 // this adds those to the internal list of known histograms to avoid creating
253 // duplicates that would have to be merged during reporting. Every call to 263 // duplicates that would have to be merged during reporting. Every call to
254 // this method resumes from the last entry it saw; it costs nothing if 264 // this method resumes from the last entry it saw; it costs nothing if
255 // nothing new has been added. 265 // nothing new has been added.
256 void ImportHistogramsToStatisticsRecorder(); 266 void ImportHistogramsToStatisticsRecorder();
257 267
258 // Import always continues from where it left off, making use of a single 268 // Import always continues from where it left off, making use of a single
259 // iterator to continue the work. 269 // iterator to continue the work.
260 Iterator import_iterator_; 270 Iterator import_iterator_;
261 271
272 // The location to which the data should be persisted.
273 FilePath persistent_location_;
Ilya Sherman 2016/04/19 00:57:46 nit: Can this be const?
bcwhite 2016/04/19 16:33:37 Const values have to be set in the constructor. T
274
262 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator); 275 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator);
263 }; 276 };
264 277
265 } // namespace base 278 } // namespace base
266 279
267 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 280 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698