| 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 #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 <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // The spare path is a file that can be pre-created and moved to be active | 428 // The spare path is a file that can be pre-created and moved to be active |
| 429 // without any startup penalty that comes from constructing the file. |name| | 429 // without any startup penalty that comes from constructing the file. |name| |
| 430 // will be used as the basename of the file inside |dir|. |out_base_path|, | 430 // will be used as the basename of the file inside |dir|. |out_base_path|, |
| 431 // |out_active_path|, or |out_spare_path| may be null if not needed. | 431 // |out_active_path|, or |out_spare_path| may be null if not needed. |
| 432 static void ConstructFilePaths(const FilePath& dir, | 432 static void ConstructFilePaths(const FilePath& dir, |
| 433 StringPiece name, | 433 StringPiece name, |
| 434 FilePath* out_base_path, | 434 FilePath* out_base_path, |
| 435 FilePath* out_active_path, | 435 FilePath* out_active_path, |
| 436 FilePath* out_spare_path); | 436 FilePath* out_spare_path); |
| 437 | 437 |
| 438 // As above but puts the base files in a different "upload" directory. This |
| 439 // is useful when moving all completed files into a single directory for easy |
| 440 // upload management. |
| 441 static void ConstructFilePathsForUploadDir(const FilePath& active_dir, |
| 442 const FilePath& upload_dir, |
| 443 const std::string& name, |
| 444 FilePath* out_upload_path, |
| 445 FilePath* out_active_path, |
| 446 FilePath* out_spare_path); |
| 447 |
| 438 // Create a "spare" file that can later be made the "active" file. This | 448 // Create a "spare" file that can later be made the "active" file. This |
| 439 // should be done on a background thread if possible. | 449 // should be done on a background thread if possible. |
| 440 static bool CreateSpareFile(const FilePath& spare_path, size_t size); | 450 static bool CreateSpareFile(const FilePath& spare_path, size_t size); |
| 441 | 451 |
| 442 // Same as above but uses standard names. |name| is the name of the allocator | 452 // Same as above but uses standard names. |name| is the name of the allocator |
| 443 // and is also used to create the correct filename. | 453 // and is also used to create the correct filename. |
| 444 static bool CreateSpareFileInDir(const FilePath& dir_path, | 454 static bool CreateSpareFileInDir(const FilePath& dir_path, |
| 445 size_t size, | 455 size_t size, |
| 446 StringPiece name); | 456 StringPiece name); |
| 447 #endif | 457 #endif |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 std::unique_ptr<PersistentMemoryAllocator> memory); | 507 std::unique_ptr<PersistentMemoryAllocator> memory); |
| 498 | 508 |
| 499 // Import new histograms from the global histogram allocator. It's possible | 509 // Import new histograms from the global histogram allocator. It's possible |
| 500 // for other processes to create histograms in the active memory segment; | 510 // for other processes to create histograms in the active memory segment; |
| 501 // this adds those to the internal list of known histograms to avoid creating | 511 // this adds those to the internal list of known histograms to avoid creating |
| 502 // duplicates that would have to be merged during reporting. Every call to | 512 // duplicates that would have to be merged during reporting. Every call to |
| 503 // this method resumes from the last entry it saw; it costs nothing if | 513 // this method resumes from the last entry it saw; it costs nothing if |
| 504 // nothing new has been added. | 514 // nothing new has been added. |
| 505 void ImportHistogramsToStatisticsRecorder(); | 515 void ImportHistogramsToStatisticsRecorder(); |
| 506 | 516 |
| 517 // Builds a FilePath for a metrics file. |
| 518 static FilePath MakeMetricsFilePath(const FilePath& dir, StringPiece name); |
| 519 |
| 507 // Import always continues from where it left off, making use of a single | 520 // Import always continues from where it left off, making use of a single |
| 508 // iterator to continue the work. | 521 // iterator to continue the work. |
| 509 Iterator import_iterator_; | 522 Iterator import_iterator_; |
| 510 | 523 |
| 511 // The location to which the data should be persisted. | 524 // The location to which the data should be persisted. |
| 512 FilePath persistent_location_; | 525 FilePath persistent_location_; |
| 513 | 526 |
| 514 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator); | 527 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator); |
| 515 }; | 528 }; |
| 516 | 529 |
| 517 } // namespace base | 530 } // namespace base |
| 518 | 531 |
| 519 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ | 532 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ |
| OLD | NEW |