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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 AutoLock lock(lock_); | 709 AutoLock lock(lock_); |
710 | 710 |
711 DCHECK(delegate_); // At this point we must have a delegate. | 711 DCHECK(delegate_); // At this point we must have a delegate. |
712 session_state_ = session_state; | 712 session_state_ = session_state; |
713 | 713 |
714 DCHECK(!dump_thread_); | 714 DCHECK(!dump_thread_); |
715 dump_thread_ = std::move(dump_thread); | 715 dump_thread_ = std::move(dump_thread); |
716 | 716 |
717 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); | 717 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); |
718 | 718 |
719 // TODO(primiano): This is a temporary hack to disable periodic memory dumps | 719 if (!is_coordinator_) |
720 // when running memory benchmarks until telemetry uses TraceConfig to | |
721 // enable/disable periodic dumps. See crbug.com/529184 . | |
722 if (!is_coordinator_ || | |
723 CommandLine::ForCurrentProcess()->HasSwitch( | |
724 "enable-memory-benchmarking")) { | |
725 return; | 720 return; |
726 } | |
727 } | 721 } |
728 | 722 |
729 // Enable periodic dumps if necessary. | 723 // Enable periodic dumps if necessary. |
730 periodic_dump_timer_.Start(trace_config.memory_dump_config().triggers); | 724 periodic_dump_timer_.Start(trace_config.memory_dump_config().triggers); |
731 } | 725 } |
732 | 726 |
733 void MemoryDumpManager::OnTraceLogDisabled() { | 727 void MemoryDumpManager::OnTraceLogDisabled() { |
734 // There might be a memory dump in progress while this happens. Therefore, | 728 // There might be a memory dump in progress while this happens. Therefore, |
735 // ensure that the MDM state which depends on the tracing enabled / disabled | 729 // ensure that the MDM state which depends on the tracing enabled / disabled |
736 // state is always accessed by the dumping methods holding the |lock_|. | 730 // state is always accessed by the dumping methods holding the |lock_|. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) | 882 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) |
889 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; | 883 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; |
890 ++periodic_dumps_count_; | 884 ++periodic_dumps_count_; |
891 | 885 |
892 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 886 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
893 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); | 887 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); |
894 } | 888 } |
895 | 889 |
896 } // namespace trace_event | 890 } // namespace trace_event |
897 } // namespace base | 891 } // namespace base |
OLD | NEW |