| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/allocator/features.h" | 10 #include "base/allocator/features.h" |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 // At the moment the periodic support is limited to at most one periodic | 834 // At the moment the periodic support is limited to at most one periodic |
| 835 // trigger per dump mode. All intervals should be an integer multiple of the | 835 // trigger per dump mode. All intervals should be an integer multiple of the |
| 836 // smallest interval specified. | 836 // smallest interval specified. |
| 837 periodic_dumps_count_ = 0; | 837 periodic_dumps_count_ = 0; |
| 838 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max(); | 838 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max(); |
| 839 uint32_t light_dump_period_ms = 0; | 839 uint32_t light_dump_period_ms = 0; |
| 840 uint32_t heavy_dump_period_ms = 0; | 840 uint32_t heavy_dump_period_ms = 0; |
| 841 DCHECK_LE(triggers_list.size(), 3u); | 841 DCHECK_LE(triggers_list.size(), 3u); |
| 842 auto* mdm = MemoryDumpManager::GetInstance(); | 842 auto* mdm = MemoryDumpManager::GetInstance(); |
| 843 for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) { | 843 for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) { |
| 844 DCHECK_NE(0u, config.periodic_interval_ms); | 844 DCHECK_NE(0u, config.min_time_between_dumps_ms); |
| 845 DCHECK_EQ(MemoryDumpType::PERIODIC_INTERVAL, config.trigger_type) |
| 846 << "Only periodic_interval triggers are suppported"; |
| 845 switch (config.level_of_detail) { | 847 switch (config.level_of_detail) { |
| 846 case MemoryDumpLevelOfDetail::BACKGROUND: | 848 case MemoryDumpLevelOfDetail::BACKGROUND: |
| 847 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::BACKGROUND)); | 849 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::BACKGROUND)); |
| 848 break; | 850 break; |
| 849 case MemoryDumpLevelOfDetail::LIGHT: | 851 case MemoryDumpLevelOfDetail::LIGHT: |
| 850 DCHECK_EQ(0u, light_dump_period_ms); | 852 DCHECK_EQ(0u, light_dump_period_ms); |
| 851 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::LIGHT)); | 853 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::LIGHT)); |
| 852 light_dump_period_ms = config.periodic_interval_ms; | 854 light_dump_period_ms = config.min_time_between_dumps_ms; |
| 853 break; | 855 break; |
| 854 case MemoryDumpLevelOfDetail::DETAILED: | 856 case MemoryDumpLevelOfDetail::DETAILED: |
| 855 DCHECK_EQ(0u, heavy_dump_period_ms); | 857 DCHECK_EQ(0u, heavy_dump_period_ms); |
| 856 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::DETAILED)); | 858 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::DETAILED)); |
| 857 heavy_dump_period_ms = config.periodic_interval_ms; | 859 heavy_dump_period_ms = config.min_time_between_dumps_ms; |
| 858 break; | 860 break; |
| 859 } | 861 } |
| 860 min_timer_period_ms = | 862 min_timer_period_ms = |
| 861 std::min(min_timer_period_ms, config.periodic_interval_ms); | 863 std::min(min_timer_period_ms, config.min_time_between_dumps_ms); |
| 862 } | 864 } |
| 863 | 865 |
| 864 DCHECK_EQ(0u, light_dump_period_ms % min_timer_period_ms); | 866 DCHECK_EQ(0u, light_dump_period_ms % min_timer_period_ms); |
| 865 light_dump_rate_ = light_dump_period_ms / min_timer_period_ms; | 867 light_dump_rate_ = light_dump_period_ms / min_timer_period_ms; |
| 866 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms); | 868 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms); |
| 867 heavy_dump_rate_ = heavy_dump_period_ms / min_timer_period_ms; | 869 heavy_dump_rate_ = heavy_dump_period_ms / min_timer_period_ms; |
| 868 | 870 |
| 869 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(min_timer_period_ms), | 871 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(min_timer_period_ms), |
| 870 base::Bind(&PeriodicGlobalDumpTimer::RequestPeriodicGlobalDump, | 872 base::Bind(&PeriodicGlobalDumpTimer::RequestPeriodicGlobalDump, |
| 871 base::Unretained(this))); | 873 base::Unretained(this))); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 888 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) | 890 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) |
| 889 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; | 891 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; |
| 890 ++periodic_dumps_count_; | 892 ++periodic_dumps_count_; |
| 891 | 893 |
| 892 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 894 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
| 893 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); | 895 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); |
| 894 } | 896 } |
| 895 | 897 |
| 896 } // namespace trace_event | 898 } // namespace trace_event |
| 897 } // namespace base | 899 } // namespace base |
| OLD | NEW |