Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2806553005: Revert of memory-infra: Fill the memory dump callback result (2/2) (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 TRACE_EVENT_NESTABLE_ASYNC_END1( 85 TRACE_EVENT_NESTABLE_ASYNC_END1(
86 MemoryDumpManager::kTraceCategory, "GlobalMemoryDump", 86 MemoryDumpManager::kTraceCategory, "GlobalMemoryDump",
87 TRACE_ID_MANGLE(dump_guid), "success", success); 87 TRACE_ID_MANGLE(dump_guid), "success", success);
88 88
89 if (!wrapped_callback.is_null()) { 89 if (!wrapped_callback.is_null()) {
90 wrapped_callback.Run(dump_guid, success); 90 wrapped_callback.Run(dump_guid, success);
91 wrapped_callback.Reset(); 91 wrapped_callback.Reset();
92 } 92 }
93 } 93 }
94 94
95 void FillOsDumpFromProcessMemoryDump(
96 const ProcessMemoryDump* pmd,
97 MemoryDumpCallbackResult::OSMemDump* osDump) {
98 if (pmd->has_process_totals()) {
99 const ProcessMemoryTotals* totals = pmd->process_totals();
100 osDump->resident_set_kb = totals->resident_set_bytes() / 1024;
101 }
102 }
103
104 // Proxy class which wraps a ConvertableToTraceFormat owned by the 95 // Proxy class which wraps a ConvertableToTraceFormat owned by the
105 // |session_state| into a proxy object that can be added to the trace event log. 96 // |session_state| into a proxy object that can be added to the trace event log.
106 // This is to solve the problem that the MemoryDumpSessionState is refcounted 97 // This is to solve the problem that the MemoryDumpSessionState is refcounted
107 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>. 98 // but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>.
108 template <typename T> 99 template <typename T>
109 struct SessionStateConvertableProxy : public ConvertableToTraceFormat { 100 struct SessionStateConvertableProxy : public ConvertableToTraceFormat {
110 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const; 101 using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const;
111 102
112 SessionStateConvertableProxy( 103 SessionStateConvertableProxy(
113 scoped_refptr<MemoryDumpSessionState> session_state, 104 scoped_refptr<MemoryDumpSessionState> session_state,
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 GetDumpsSumKb("v8/*", process_memory_dump); 791 GetDumpsSumKb("v8/*", process_memory_dump);
801 792
802 // partition_alloc reports sizes for both allocated_objects and 793 // partition_alloc reports sizes for both allocated_objects and
803 // partitions. The memory allocated_objects uses is a subset of 794 // partitions. The memory allocated_objects uses is a subset of
804 // the partitions memory so to avoid double counting we only 795 // the partitions memory so to avoid double counting we only
805 // count partitions memory. 796 // count partitions memory.
806 result.chrome_dump.partition_alloc_total_kb = 797 result.chrome_dump.partition_alloc_total_kb =
807 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); 798 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump);
808 result.chrome_dump.blink_gc_total_kb = 799 result.chrome_dump.blink_gc_total_kb =
809 GetDumpsSumKb("blink_gc", process_memory_dump); 800 GetDumpsSumKb("blink_gc", process_memory_dump);
810 FillOsDumpFromProcessMemoryDump(process_memory_dump, &result.os_dump);
811 } else {
812 auto& os_dump = result.extra_processes_dump[pid];
813 FillOsDumpFromProcessMemoryDump(process_memory_dump, &os_dump);
814 } 801 }
815 } 802 }
816 803
817 bool tracing_still_enabled; 804 bool tracing_still_enabled;
818 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); 805 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled);
819 if (!tracing_still_enabled) { 806 if (!tracing_still_enabled) {
820 pmd_async_state->dump_successful = false; 807 pmd_async_state->dump_successful = false;
821 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" 808 VLOG(1) << kLogPrefix << " failed because tracing was disabled before"
822 << " the dump was completed"; 809 << " the dump was completed";
823 } 810 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 if (iter == process_dumps.end()) { 1003 if (iter == process_dumps.end()) {
1017 std::unique_ptr<ProcessMemoryDump> new_pmd( 1004 std::unique_ptr<ProcessMemoryDump> new_pmd(
1018 new ProcessMemoryDump(session_state, dump_args)); 1005 new ProcessMemoryDump(session_state, dump_args));
1019 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 1006 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
1020 } 1007 }
1021 return iter->second.get(); 1008 return iter->second.get();
1022 } 1009 }
1023 1010
1024 } // namespace trace_event 1011 } // namespace trace_event
1025 } // namespace base 1012 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698