Enterprise policy: Ignore the deprecated ForceSafeSearch if ForceGoogleSafeSearch...
[chromium-blink-merge.git] / base / trace_event / process_memory_dump.cc
blobbbca36c36528ae8b75397058c01b8269e2bc322c
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
3 // found in the LICENSE file.
5 #include "base/trace_event/process_memory_dump.h"
7 #include "base/trace_event/process_memory_totals.h"
8 #include "base/trace_event/trace_event_argument.h"
10 namespace base {
11 namespace trace_event {
13 ProcessMemoryDump::ProcessMemoryDump()
14 : has_process_totals_(false), has_process_mmaps_(false) {
17 ProcessMemoryDump::~ProcessMemoryDump() {
20 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
21 const std::string& name) {
22 return CreateAllocatorDump(name, nullptr);
25 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
26 const std::string& name,
27 MemoryAllocatorDump* parent) {
28 DCHECK_EQ(0ul, allocator_dumps_.count(name));
29 MemoryAllocatorDump* mad = new MemoryAllocatorDump(name, parent);
30 allocator_dumps_storage_.push_back(mad);
31 allocator_dumps_[name] = mad;
32 return mad;
35 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
36 const std::string& name) const {
37 auto it = allocator_dumps_.find(name);
38 return it == allocator_dumps_.end() ? nullptr : it->second;
41 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
42 // Build up the [dumper name] -> [value] dictionary.
43 if (has_process_totals_) {
44 value->BeginDictionary("process_totals");
45 process_totals_.AsValueInto(value);
46 value->EndDictionary();
48 if (has_process_mmaps_) {
49 value->BeginDictionary("process_mmaps");
50 process_mmaps_.AsValueInto(value);
51 value->EndDictionary();
53 if (allocator_dumps_storage_.size() > 0) {
54 value->BeginDictionary("allocators");
55 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
56 allocator_dump->AsValueInto(value);
57 value->EndDictionary();
61 } // namespace trace_event
62 } // namespace base