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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 | 539 |
| 540 bool success = false; | 540 bool success = false; |
| 541 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_ATTEMPT); | 541 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_ATTEMPT); |
| 542 if (PersistentSystemProfile::GetSystemProfile( | 542 if (PersistentSystemProfile::GetSystemProfile( |
| 543 *source->allocator->memory_allocator(), system_profile_proto)) { | 543 *source->allocator->memory_allocator(), system_profile_proto)) { |
| 544 RecordHistogramSnapshotsFromSource(snapshot_manager, source); | 544 RecordHistogramSnapshotsFromSource(snapshot_manager, source); |
| 545 success = true; | 545 success = true; |
| 546 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_FOUND); | 546 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_FOUND); |
| 547 } else { | 547 } else { |
| 548 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_DROPPED); | 548 RecordEmbeddedProfileResult(EMBEDDED_PROFILE_DROPPED); |
| 549 | |
| 550 // TODO(bcwhite): Remove these once crbug/695880 is resolved. | |
| 551 | |
| 552 int histogram_count = 0; | |
| 553 base::PersistentHistogramAllocator::Iterator histogram_iter( | |
| 554 source->allocator.get()); | |
| 555 while (true) { | |
| 556 std::unique_ptr<base::HistogramBase> histogram = | |
| 557 histogram_iter.GetNext(); | |
| 558 if (!histogram) | |
| 559 break; | |
| 560 ++histogram_count; | |
| 561 } | |
|
Alexei Svitkine (slow)
2017/06/30 14:50:10
Nit: How about:
while (histogram_iter.GetNext())
bcwhite
2017/06/30 15:12:15
Done.
| |
| 562 UMA_HISTOGRAM_COUNTS_1000( | |
|
Alexei Svitkine (slow)
2017/06/30 14:50:10
Nit: Suggest using 10k version of the macro becaus
bcwhite
2017/06/30 15:12:16
Done. It doesn't really matter either way. If it
| |
| 563 "UMA.FileMetricsProvider.EmbeddedProfile.DroppedHistogramCount", | |
| 564 histogram_count); | |
| 565 | |
| 566 base::File::Info info; | |
| 567 if (base::GetFileInfo(source->path, &info)) { | |
| 568 UMA_HISTOGRAM_CUSTOM_TIMES( | |
| 569 "UMA.FileMetricsProvider.EmbeddedProfile.DroppedFileAge", | |
| 570 base::Time::Now() - info.last_modified, | |
| 571 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); | |
|
Alexei Svitkine (slow)
2017/06/30 14:50:10
I think logging in ms is not useful here, so you d
bcwhite
2017/06/30 15:12:16
Done.
| |
| 572 } | |
| 549 } | 573 } |
| 550 | 574 |
| 551 // Regardless of whether this source was successfully recorded, it is never | 575 // Regardless of whether this source was successfully recorded, it is never |
| 552 // read again. | 576 // read again. |
| 553 source->read_complete = true; | 577 source->read_complete = true; |
| 554 RecordSourceAsRead(source); | 578 RecordSourceAsRead(source); |
| 555 sources_to_check_.splice(sources_to_check_.end(), sources_with_profile_, | 579 sources_to_check_.splice(sources_to_check_.end(), sources_with_profile_, |
| 556 sources_with_profile_.begin()); | 580 sources_with_profile_.begin()); |
| 557 if (success) | 581 if (success) |
| 558 return true; | 582 return true; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 652 // important to know how much total "jank" may be introduced. | 676 // important to know how much total "jank" may be introduced. |
| 653 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total"); | 677 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total"); |
| 654 | 678 |
| 655 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) { | 679 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) { |
| 656 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File"); | 680 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File"); |
| 657 MergeHistogramDeltasFromSource(source.get()); | 681 MergeHistogramDeltasFromSource(source.get()); |
| 658 } | 682 } |
| 659 } | 683 } |
| 660 | 684 |
| 661 } // namespace metrics | 685 } // namespace metrics |
| OLD | NEW |