| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_scheduler.h" | 5 #include "base/trace_event/memory_dump_scheduler.h" |
| 6 | 6 |
| 7 #include "base/process/process_metrics.h" | 7 #include "base/process/process_metrics.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "base/trace_event/memory_dump_manager.h" | 10 #include "base/trace_event/memory_dump_manager.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 level_of_detail = MemoryDumpLevelOfDetail::LIGHT; | 164 level_of_detail = MemoryDumpLevelOfDetail::LIGHT; |
| 165 if (periodic_state_->heavy_dumps_rate > 0 && | 165 if (periodic_state_->heavy_dumps_rate > 0 && |
| 166 periodic_state_->dump_count % periodic_state_->heavy_dumps_rate == 0) | 166 periodic_state_->dump_count % periodic_state_->heavy_dumps_rate == 0) |
| 167 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; | 167 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; |
| 168 ++periodic_state_->dump_count; | 168 ++periodic_state_->dump_count; |
| 169 | 169 |
| 170 mdm_->RequestGlobalDump(MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); | 170 mdm_->RequestGlobalDump(MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void MemoryDumpScheduler::PollMemoryOnPollingThread() { | 173 void MemoryDumpScheduler::PollMemoryOnPollingThread() { |
| 174 if (polling_state_->current_state != PollingTriggerState::ENABLED) | 174 if (!polling_state_) |
| 175 return; | 175 return; |
| 176 | 176 |
| 177 DCHECK_EQ(PollingTriggerState::ENABLED, polling_state_->current_state); |
| 178 |
| 177 uint64_t polled_memory = 0; | 179 uint64_t polled_memory = 0; |
| 178 bool res = mdm_->PollFastMemoryTotal(&polled_memory); | 180 bool res = mdm_->PollFastMemoryTotal(&polled_memory); |
| 179 DCHECK(res); | 181 DCHECK(res); |
| 180 if (polling_state_->level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | 182 if (polling_state_->level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
| 181 TRACE_COUNTER1(MemoryDumpManager::kTraceCategory, "PolledMemoryMB", | 183 TRACE_COUNTER1(MemoryDumpManager::kTraceCategory, "PolledMemoryMB", |
| 182 polled_memory / 1024 / 1024); | 184 polled_memory / 1024 / 1024); |
| 183 } | 185 } |
| 184 | 186 |
| 185 if (ShouldTriggerDump(polled_memory)) { | 187 if (ShouldTriggerDump(polled_memory)) { |
| 186 TRACE_EVENT_INSTANT1(MemoryDumpManager::kTraceCategory, | 188 TRACE_EVENT_INSTANT1(MemoryDumpManager::kTraceCategory, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 last_memory_totals_kb[last_memory_totals_kb_index] * 1024; | 319 last_memory_totals_kb[last_memory_totals_kb_index] * 1024; |
| 318 } | 320 } |
| 319 num_polls_from_last_dump = 0; | 321 num_polls_from_last_dump = 0; |
| 320 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i) | 322 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i) |
| 321 last_memory_totals_kb[i] = 0; | 323 last_memory_totals_kb[i] = 0; |
| 322 last_memory_totals_kb_index = 0; | 324 last_memory_totals_kb_index = 0; |
| 323 } | 325 } |
| 324 | 326 |
| 325 } // namespace trace_event | 327 } // namespace trace_event |
| 326 } // namespace base | 328 } // namespace base |
| OLD | NEW |