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

Side by Side Diff: content/child/web_process_memory_dump_impl.cc

Issue 1741673002: Revert of Refactoring: Move some classes from content/child to platform (patchset #17 id:320001 of … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 "platform/web_process_memory_dump_impl.h" 5 #include "content/child/web_process_memory_dump_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/discardable_memory.h" 9 #include "base/memory/discardable_memory.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/trace_event/heap_profiler_heap_dump_writer.h" 11 #include "base/trace_event/heap_profiler_heap_dump_writer.h"
12 #include "base/trace_event/process_memory_dump.h" 12 #include "base/trace_event/process_memory_dump.h"
13 #include "base/trace_event/trace_event_argument.h" 13 #include "base/trace_event/trace_event_argument.h"
14 #include "base/trace_event/trace_event_memory_overhead.h" 14 #include "base/trace_event/trace_event_memory_overhead.h"
15 #include "platform/web_memory_allocator_dump_impl.h" 15 #include "content/child/web_memory_allocator_dump_impl.h"
16 #include "skia/ext/skia_trace_memory_dump_impl.h" 16 #include "skia/ext/skia_trace_memory_dump_impl.h"
17 17
18 namespace blink { 18 namespace content {
19 19
20 WebProcessMemoryDumpImpl::WebProcessMemoryDumpImpl() 20 WebProcessMemoryDumpImpl::WebProcessMemoryDumpImpl()
21 : owned_process_memory_dump_( 21 : owned_process_memory_dump_(
22 new base::trace_event::ProcessMemoryDump(nullptr)), 22 new base::trace_event::ProcessMemoryDump(nullptr)),
23 process_memory_dump_(owned_process_memory_dump_.get()), 23 process_memory_dump_(owned_process_memory_dump_.get()),
24 level_of_detail_(base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {} 24 level_of_detail_(base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {}
25 25
26 WebProcessMemoryDumpImpl::WebProcessMemoryDumpImpl( 26 WebProcessMemoryDumpImpl::WebProcessMemoryDumpImpl(
27 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, 27 base::trace_event::MemoryDumpLevelOfDetail level_of_detail,
28 base::trace_event::ProcessMemoryDump* process_memory_dump) 28 base::trace_event::ProcessMemoryDump* process_memory_dump)
(...skipping 30 matching lines...) Expand all
59 base::trace_event::MemoryAllocatorDump* memory_allocator_dump) { 59 base::trace_event::MemoryAllocatorDump* memory_allocator_dump) {
60 if (!memory_allocator_dump) 60 if (!memory_allocator_dump)
61 return nullptr; 61 return nullptr;
62 62
63 // Wrap it and return to blink. 63 // Wrap it and return to blink.
64 WebMemoryAllocatorDumpImpl* web_memory_allocator_dump_impl = 64 WebMemoryAllocatorDumpImpl* web_memory_allocator_dump_impl =
65 new WebMemoryAllocatorDumpImpl(memory_allocator_dump); 65 new WebMemoryAllocatorDumpImpl(memory_allocator_dump);
66 66
67 // memory_allocator_dumps_ will take ownership of 67 // memory_allocator_dumps_ will take ownership of
68 // |web_memory_allocator_dumpd_impl|. 68 // |web_memory_allocator_dumpd_impl|.
69 memory_allocator_dumps_.set( 69 memory_allocator_dumps_.set(memory_allocator_dump,
70 memory_allocator_dump, adoptPtr(web_memory_allocator_dump_impl)); 70 make_scoped_ptr(web_memory_allocator_dump_impl));
71 return web_memory_allocator_dump_impl; 71 return web_memory_allocator_dump_impl;
72 } 72 }
73 73
74 blink::WebMemoryAllocatorDump* WebProcessMemoryDumpImpl::getMemoryAllocatorDump( 74 blink::WebMemoryAllocatorDump* WebProcessMemoryDumpImpl::getMemoryAllocatorDump(
75 const blink::WebString& absolute_name) const { 75 const blink::WebString& absolute_name) const {
76 // Retrieve the base MemoryAllocatorDump object and then reverse lookup 76 // Retrieve the base MemoryAllocatorDump object and then reverse lookup
77 // its wrapper. 77 // its wrapper.
78 base::trace_event::MemoryAllocatorDump* memory_allocator_dump = 78 base::trace_event::MemoryAllocatorDump* memory_allocator_dump =
79 process_memory_dump_->GetAllocatorDump(absolute_name.utf8()); 79 process_memory_dump_->GetAllocatorDump(absolute_name.utf8());
80 if (!memory_allocator_dump) 80 if (!memory_allocator_dump)
(...skipping 24 matching lines...) Expand all
105 // In order to expose the move and ownership transfer semantics of the 105 // In order to expose the move and ownership transfer semantics of the
106 // underlying ProcessMemoryDump, we need to: 106 // underlying ProcessMemoryDump, we need to:
107 107
108 // 1) Move and transfer the ownership of the wrapped 108 // 1) Move and transfer the ownership of the wrapped
109 // base::trace_event::MemoryAllocatorDump(s) instances. 109 // base::trace_event::MemoryAllocatorDump(s) instances.
110 process_memory_dump_->TakeAllDumpsFrom(other_impl->process_memory_dump_); 110 process_memory_dump_->TakeAllDumpsFrom(other_impl->process_memory_dump_);
111 111
112 // 2) Move and transfer the ownership of the WebMemoryAllocatorDump wrappers. 112 // 2) Move and transfer the ownership of the WebMemoryAllocatorDump wrappers.
113 const size_t expected_final_size = memory_allocator_dumps_.size() + 113 const size_t expected_final_size = memory_allocator_dumps_.size() +
114 other_impl->memory_allocator_dumps_.size(); 114 other_impl->memory_allocator_dumps_.size();
115 while (!other_impl->memory_allocator_dumps_.isEmpty()) { 115 while (!other_impl->memory_allocator_dumps_.empty()) {
116 auto first_entry = other_impl->memory_allocator_dumps_.begin(); 116 auto first_entry = other_impl->memory_allocator_dumps_.begin();
117 base::trace_event::MemoryAllocatorDump* memory_allocator_dump = 117 base::trace_event::MemoryAllocatorDump* memory_allocator_dump =
118 first_entry->key; 118 first_entry->first;
119 memory_allocator_dumps_.set(memory_allocator_dump, 119 memory_allocator_dumps_.set(
120 other_impl->memory_allocator_dumps_.take(memory_allocator_dump)); 120 memory_allocator_dump,
121 other_impl->memory_allocator_dumps_.take_and_erase(first_entry));
121 } 122 }
122 DCHECK_EQ(expected_final_size, memory_allocator_dumps_.size()); 123 DCHECK_EQ(expected_final_size, memory_allocator_dumps_.size());
123 DCHECK(other_impl->memory_allocator_dumps_.isEmpty()); 124 DCHECK(other_impl->memory_allocator_dumps_.empty());
124 } 125 }
125 126
126 void WebProcessMemoryDumpImpl::addOwnershipEdge( 127 void WebProcessMemoryDumpImpl::addOwnershipEdge(
127 blink::WebMemoryAllocatorDumpGuid source, 128 blink::WebMemoryAllocatorDumpGuid source,
128 blink::WebMemoryAllocatorDumpGuid target, 129 blink::WebMemoryAllocatorDumpGuid target,
129 int importance) { 130 int importance) {
130 process_memory_dump_->AddOwnershipEdge( 131 process_memory_dump_->AddOwnershipEdge(
131 base::trace_event::MemoryAllocatorDumpGuid(source), 132 base::trace_event::MemoryAllocatorDumpGuid(source),
132 base::trace_event::MemoryAllocatorDumpGuid(target), importance); 133 base::trace_event::MemoryAllocatorDumpGuid(target), importance);
133 } 134 }
134 135
135 void WebProcessMemoryDumpImpl::addOwnershipEdge( 136 void WebProcessMemoryDumpImpl::addOwnershipEdge(
136 blink::WebMemoryAllocatorDumpGuid source, 137 blink::WebMemoryAllocatorDumpGuid source,
137 blink::WebMemoryAllocatorDumpGuid target) { 138 blink::WebMemoryAllocatorDumpGuid target) {
138 process_memory_dump_->AddOwnershipEdge( 139 process_memory_dump_->AddOwnershipEdge(
139 base::trace_event::MemoryAllocatorDumpGuid(source), 140 base::trace_event::MemoryAllocatorDumpGuid(source),
140 base::trace_event::MemoryAllocatorDumpGuid(target)); 141 base::trace_event::MemoryAllocatorDumpGuid(target));
141 } 142 }
142 143
143 void WebProcessMemoryDumpImpl::addSuballocation( 144 void WebProcessMemoryDumpImpl::addSuballocation(
144 blink::WebMemoryAllocatorDumpGuid source, 145 blink::WebMemoryAllocatorDumpGuid source,
145 const blink::WebString& target_node_name) { 146 const blink::WebString& target_node_name) {
146 process_memory_dump_->AddSuballocation( 147 process_memory_dump_->AddSuballocation(
147 base::trace_event::MemoryAllocatorDumpGuid(source), 148 base::trace_event::MemoryAllocatorDumpGuid(source),
148 target_node_name.utf8()); 149 target_node_name.utf8());
149 } 150 }
150 151
151 SkTraceMemoryDump* WebProcessMemoryDumpImpl::createDumpAdapterForSkia( 152 SkTraceMemoryDump* WebProcessMemoryDumpImpl::createDumpAdapterForSkia(
152 const blink::WebString& dump_name_prefix) { 153 const blink::WebString& dump_name_prefix) {
153 sk_trace_dump_list_.push_back(make_scoped_ptr( 154 sk_trace_dump_list_.push_back(new skia::SkiaTraceMemoryDumpImpl(
154 new skia::SkiaTraceMemoryDumpImpl( 155 dump_name_prefix.utf8(), level_of_detail_, process_memory_dump_));
155 dump_name_prefix.utf8(), level_of_detail_, process_memory_dump_))); 156 return sk_trace_dump_list_.back();
156 return sk_trace_dump_list_.back().get();
157 } 157 }
158 158
159 blink::WebMemoryAllocatorDump* 159 blink::WebMemoryAllocatorDump*
160 WebProcessMemoryDumpImpl::CreateDiscardableMemoryAllocatorDump( 160 WebProcessMemoryDumpImpl::CreateDiscardableMemoryAllocatorDump(
161 const std::string& name, 161 const std::string& name,
162 base::DiscardableMemory* discardable) { 162 base::DiscardableMemory* discardable) {
163 base::trace_event::MemoryAllocatorDump* dump = 163 base::trace_event::MemoryAllocatorDump* dump =
164 discardable->CreateMemoryAllocatorDump(name.c_str(), 164 discardable->CreateMemoryAllocatorDump(name.c_str(),
165 process_memory_dump_); 165 process_memory_dump_);
166 return createWebMemoryAllocatorDump(dump); 166 return createWebMemoryAllocatorDump(dump);
(...skipping 10 matching lines...) Expand all
177 bytes_by_context, 177 bytes_by_context,
178 session_state->stack_frame_deduplicator(), 178 session_state->stack_frame_deduplicator(),
179 session_state->type_name_deduplicator()); 179 session_state->type_name_deduplicator());
180 process_memory_dump_->AddHeapDump(allocator_name, heap_dump); 180 process_memory_dump_->AddHeapDump(allocator_name, heap_dump);
181 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", 181 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s",
182 allocator_name); 182 allocator_name);
183 overhead.DumpInto(base_name.c_str(), process_memory_dump_); 183 overhead.DumpInto(base_name.c_str(), process_memory_dump_);
184 } 184 }
185 185
186 } // namespace content 186 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_process_memory_dump_impl.h ('k') | content/child/web_process_memory_dump_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698