Enterprise policy: Ignore the deprecated ForceSafeSearch if ForceGoogleSafeSearch...
[chromium-blink-merge.git] / base / trace_event / process_memory_dump.h
blobb59ae67bb4ff836af628e36d398e50d6765beab0
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 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
8 #include "base/base_export.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/containers/small_map.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/trace_event/memory_allocator_dump.h"
13 #include "base/trace_event/process_memory_maps.h"
14 #include "base/trace_event/process_memory_totals.h"
16 namespace base {
17 namespace trace_event {
19 class ConvertableToTraceFormat;
20 class MemoryDumpManager;
22 // ProcessMemoryDump is as a strongly typed container which enforces the data
23 // model for each memory dump and holds the dumps produced by the
24 // MemoryDumpProvider(s) for a specific process.
25 // At trace generation time (i.e. when AsValue() is called), ProcessMemoryDump
26 // will compose a key-value dictionary of the various dumps obtained at trace
27 // dump point time.
28 class BASE_EXPORT ProcessMemoryDump {
29 public:
30 using AllocatorDumpsMap =
31 SmallMap<hash_map<std::string, MemoryAllocatorDump*>>;
33 ProcessMemoryDump();
34 ~ProcessMemoryDump();
36 // Called at trace generation time to populate the TracedValue.
37 void AsValueInto(TracedValue* value) const;
39 ProcessMemoryTotals* process_totals() { return &process_totals_; }
40 bool has_process_totals() const { return has_process_totals_; }
41 void set_has_process_totals() { has_process_totals_ = true; }
43 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
44 bool has_process_mmaps() const { return has_process_mmaps_; }
45 void set_has_process_mmaps() { has_process_mmaps_ = true; }
47 // Creates a new MemoryAllocatorDump with the given name and returns the
48 // empty object back to the caller. The |name| must be unique in the dump.
49 // ProcessMemoryDump handles the memory ownership of the created object.
50 // |parent| can be used to specify a hierarchical relationship of the
51 // allocator dumps.
52 MemoryAllocatorDump* CreateAllocatorDump(const std::string& name);
53 MemoryAllocatorDump* CreateAllocatorDump(const std::string& name,
54 MemoryAllocatorDump* parent);
56 // Returns a MemoryAllocatorDump given its name or nullptr if not found.
57 MemoryAllocatorDump* GetAllocatorDump(const std::string& name) const;
59 // Returns the map of the MemoryAllocatorDumps added to this dump.
60 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; }
62 private:
63 ProcessMemoryTotals process_totals_;
64 bool has_process_totals_;
66 ProcessMemoryMaps process_mmaps_;
67 bool has_process_mmaps_;
69 // A maps of "allocator_name" -> MemoryAllocatorDump populated by
70 // allocator dump providers.
71 AllocatorDumpsMap allocator_dumps_;
73 // ProcessMemoryDump handles the memory ownership of all its belongings.
74 ScopedVector<MemoryAllocatorDump> allocator_dumps_storage_;
76 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
79 } // namespace trace_event
80 } // namespace base
82 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_