| 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/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 return; | 651 return; |
| 652 } | 652 } |
| 653 | 653 |
| 654 // Enable periodic dumps. At the moment the periodic support is limited to at | 654 // Enable periodic dumps. At the moment the periodic support is limited to at |
| 655 // most one low-detail periodic dump and at most one high-detail periodic | 655 // most one low-detail periodic dump and at most one high-detail periodic |
| 656 // dump. If both are specified the high-detail period must be an integer | 656 // dump. If both are specified the high-detail period must be an integer |
| 657 // multiple of the low-level one. | 657 // multiple of the low-level one. |
| 658 g_periodic_dumps_count = 0; | 658 g_periodic_dumps_count = 0; |
| 659 const TraceConfig trace_config = | 659 const TraceConfig trace_config = |
| 660 TraceLog::GetInstance()->GetCurrentTraceConfig(); | 660 TraceLog::GetInstance()->GetCurrentTraceConfig(); |
| 661 const TraceConfig::MemoryDumpConfig& config_list = | 661 session_state_->SetMemoryDumpConfig(trace_config.memory_dump_config()); |
| 662 trace_config.memory_dump_config(); | 662 const std::vector<TraceConfig::MemoryDumpConfig::Trigger>& triggers_list = |
| 663 if (config_list.empty()) | 663 trace_config.memory_dump_config().triggers; |
| 664 if (triggers_list.empty()) |
| 664 return; | 665 return; |
| 665 | 666 |
| 666 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max(); | 667 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max(); |
| 667 uint32_t heavy_dump_period_ms = 0; | 668 uint32_t heavy_dump_period_ms = 0; |
| 668 DCHECK_LE(config_list.size(), 2u); | 669 DCHECK_LE(triggers_list.size(), 2u); |
| 669 for (const TraceConfig::MemoryDumpTriggerConfig& config : config_list) { | 670 for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) { |
| 670 DCHECK(config.periodic_interval_ms); | 671 DCHECK(config.periodic_interval_ms); |
| 671 if (config.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) | 672 if (config.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) |
| 672 heavy_dump_period_ms = config.periodic_interval_ms; | 673 heavy_dump_period_ms = config.periodic_interval_ms; |
| 673 min_timer_period_ms = | 674 min_timer_period_ms = |
| 674 std::min(min_timer_period_ms, config.periodic_interval_ms); | 675 std::min(min_timer_period_ms, config.periodic_interval_ms); |
| 675 } | 676 } |
| 676 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms); | 677 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms); |
| 677 g_heavy_dumps_rate = heavy_dump_period_ms / min_timer_period_ms; | 678 g_heavy_dumps_rate = heavy_dump_period_ms / min_timer_period_ms; |
| 678 | 679 |
| 679 periodic_dump_timer_.Start(FROM_HERE, | 680 periodic_dump_timer_.Start(FROM_HERE, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 if (iter == process_dumps.end()) { | 756 if (iter == process_dumps.end()) { |
| 756 std::unique_ptr<ProcessMemoryDump> new_pmd( | 757 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 757 new ProcessMemoryDump(session_state)); | 758 new ProcessMemoryDump(session_state)); |
| 758 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 759 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 759 } | 760 } |
| 760 return iter->second.get(); | 761 return iter->second.get(); |
| 761 } | 762 } |
| 762 | 763 |
| 763 } // namespace trace_event | 764 } // namespace trace_event |
| 764 } // namespace base | 765 } // namespace base |
| OLD | NEW |