Chromium Code Reviews| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 bool read_complete = false; | 99 bool read_complete = false; |
| 100 | 100 |
| 101 // Once a file has been recognized as needing to be read, it is mapped | 101 // Once a file has been recognized as needing to be read, it is mapped |
| 102 // into memory and assigned to an |allocator| object. | 102 // into memory and assigned to an |allocator| object. |
| 103 std::unique_ptr<base::PersistentHistogramAllocator> allocator; | 103 std::unique_ptr<base::PersistentHistogramAllocator> allocator; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(SourceInfo); | 106 DISALLOW_COPY_AND_ASSIGN(SourceInfo); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 bool FileMetricsProvider::stability_metrics_enabled_ = true; | |
| 110 | |
| 109 FileMetricsProvider::FileMetricsProvider( | 111 FileMetricsProvider::FileMetricsProvider( |
| 110 const scoped_refptr<base::TaskRunner>& task_runner, | 112 const scoped_refptr<base::TaskRunner>& task_runner, |
| 111 PrefService* local_state) | 113 PrefService* local_state) |
| 112 : task_runner_(task_runner), | 114 : task_runner_(task_runner), |
| 113 pref_service_(local_state), | 115 pref_service_(local_state), |
| 114 weak_factory_(this) { | 116 weak_factory_(this) { |
| 115 } | 117 } |
| 116 | 118 |
| 117 FileMetricsProvider::~FileMetricsProvider() {} | 119 FileMetricsProvider::~FileMetricsProvider() {} |
| 118 | 120 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 // being reported in RecordInitialHistogramSnapshots because the data | 465 // being reported in RecordInitialHistogramSnapshots because the data |
| 464 // will continue to be used by the caller after that method returns. Once | 466 // will continue to be used by the caller after that method returns. Once |
| 465 // here, though, all actions to be done on the data have been completed. | 467 // here, though, all actions to be done on the data have been completed. |
| 466 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_) | 468 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_) |
| 467 DeleteFileAsync(source->path); | 469 DeleteFileAsync(source->path); |
| 468 sources_for_previous_run_.clear(); | 470 sources_for_previous_run_.clear(); |
| 469 } | 471 } |
| 470 | 472 |
| 471 bool FileMetricsProvider::HasInitialStabilityMetrics() { | 473 bool FileMetricsProvider::HasInitialStabilityMetrics() { |
| 472 DCHECK(thread_checker_.CalledOnValidThread()); | 474 DCHECK(thread_checker_.CalledOnValidThread()); |
| 475 if (!stability_metrics_enabled_) | |
|
Alexei Svitkine (slow)
2016/11/25 19:44:42
Instead of the extra boolean, why not check the pa
bcwhite
2016/11/28 15:35:46
I could. I thought it would be better to keep exp
Alexei Svitkine (slow)
2016/11/28 16:08:49
All other things being equal, I agree.
However, h
bcwhite
2016/11/29 19:09:07
Done.
| |
| 476 return false; | |
| 473 | 477 |
| 474 // Measure the total time spent checking all sources as well as the time | 478 // Measure the total time spent checking all sources as well as the time |
| 475 // per individual file. This method is called during startup and thus blocks | 479 // per individual file. This method is called during startup and thus blocks |
| 476 // the initial showing of the browser window so it's important to know the | 480 // the initial showing of the browser window so it's important to know the |
| 477 // total delay. | 481 // total delay. |
| 478 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total"); | 482 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total"); |
| 479 | 483 |
| 480 // Check all sources for previous run to see if they need to be read. | 484 // Check all sources for previous run to see if they need to be read. |
| 481 for (auto iter = sources_for_previous_run_.begin(); | 485 for (auto iter = sources_for_previous_run_.begin(); |
| 482 iter != sources_for_previous_run_.end();) { | 486 iter != sources_for_previous_run_.end();) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 | 548 |
| 545 // Dump all histograms contained within the source to the snapshot-manager. | 549 // Dump all histograms contained within the source to the snapshot-manager. |
| 546 RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); | 550 RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); |
| 547 | 551 |
| 548 // Update the last-seen time so it isn't read again unless it changes. | 552 // Update the last-seen time so it isn't read again unless it changes. |
| 549 RecordSourceAsRead(source.get()); | 553 RecordSourceAsRead(source.get()); |
| 550 } | 554 } |
| 551 } | 555 } |
| 552 | 556 |
| 553 } // namespace metrics | 557 } // namespace metrics |
| OLD | NEW |