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

Side by Side Diff: base/trace_event/process_memory_dump.h

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/containers/small_map.h" 10 #include "base/containers/small_map.h"
11 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/trace_event/memory_allocator_dump.h" 13 #include "base/trace_event/memory_allocator_dump.h"
14 #include "base/trace_event/memory_dump_session_state.h"
13 #include "base/trace_event/process_memory_maps.h" 15 #include "base/trace_event/process_memory_maps.h"
14 #include "base/trace_event/process_memory_totals.h" 16 #include "base/trace_event/process_memory_totals.h"
15 17
16 namespace base { 18 namespace base {
17 namespace trace_event { 19 namespace trace_event {
18 20
19 class ConvertableToTraceFormat; 21 class ConvertableToTraceFormat;
20 class MemoryDumpManager; 22 class MemoryDumpManager;
23 class MemoryDumpSessionState;
21 24
22 // ProcessMemoryDump is as a strongly typed container which enforces the data 25 // ProcessMemoryDump is as a strongly typed container which enforces the data
23 // model for each memory dump point and holds the dumps produced by the 26 // model for each memory dump and holds the dumps produced by the
24 // MemoryDumpProvider(s) for a specific process. 27 // MemoryDumpProvider(s) for a specific process.
25 // At trace generation time (i.e. when AsValue() is called), ProcessMemoryDump 28 // 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 29 // will compose a key-value dictionary of the various dumps obtained at trace
27 // dump point time. 30 // dump point time.
28 class BASE_EXPORT ProcessMemoryDump { 31 class BASE_EXPORT ProcessMemoryDump {
29 public: 32 public:
33 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to
34 // MemoryAllocatorDump instances.
30 using AllocatorDumpsMap = 35 using AllocatorDumpsMap =
31 SmallMap<hash_map<std::string, MemoryAllocatorDump*>>; 36 SmallMap<hash_map<std::string, MemoryAllocatorDump*>>;
32 37
33 ProcessMemoryDump(); 38 ProcessMemoryDump(const scoped_refptr<MemoryDumpSessionState>& session_state);
34 ~ProcessMemoryDump(); 39 ~ProcessMemoryDump();
35 40
36 // Called at trace generation time to populate the TracedValue. 41 // Called at trace generation time to populate the TracedValue.
37 void AsValueInto(TracedValue* value) const; 42 void AsValueInto(TracedValue* value) const;
38 43
39 ProcessMemoryTotals* process_totals() { return &process_totals_; } 44 ProcessMemoryTotals* process_totals() { return &process_totals_; }
40 bool has_process_totals() const { return has_process_totals_; } 45 bool has_process_totals() const { return has_process_totals_; }
41 void set_has_process_totals() { has_process_totals_ = true; } 46 void set_has_process_totals() { has_process_totals_ = true; }
42 47
43 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } 48 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
44 bool has_process_mmaps() const { return has_process_mmaps_; } 49 bool has_process_mmaps() const { return has_process_mmaps_; }
45 void set_has_process_mmaps() { has_process_mmaps_ = true; } 50 void set_has_process_mmaps() { has_process_mmaps_ = true; }
46 51
47 // Creates a new MemoryAllocatorDump with the given name and returns the 52 // 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. 53 // empty object back to the caller.
49 // ProcessMemoryDump handles the memory ownership of the created object. 54 // Arguments:
50 // |parent| can be used to specify a hierarchical relationship of the 55 // allocator_name: a name that univocally identifies allocator dumps
51 // allocator dumps. 56 // produced by this provider. It acts as a type w.r.t. the allocator
52 MemoryAllocatorDump* CreateAllocatorDump(const std::string& name); 57 // attributes, in the sense that all the MAD with the same allocator_name
53 MemoryAllocatorDump* CreateAllocatorDump(const std::string& name, 58 // are expected to have the same attributes.
54 MemoryAllocatorDump* parent); 59 // heap_name, either:
60 // - kRootHeap: if the allocator has only one default heap.
61 // - a string identifing a heap name (e.g., isolate1, isolate2 ...). It is
62 // possible to specify nesting by using a path-like string (e.g.,
63 // isolate1/heap_spaceX, isolate1/heap_spaceY, isolate2/heap_spaceX).
64 // The tuple (|allocator_name|, |heap_name|) is unique inside a PMD.
65 // ProcessMemoryDump handles the memory ownership of its MemoryAllocatorDumps.
66 MemoryAllocatorDump* CreateAllocatorDump(const std::string& allocator_name,
67 const std::string& heap_name);
55 68
56 // Returns a MemoryAllocatorDump given its name or nullptr if not found. 69 // Looks up a MemoryAllocatorDump given its allocator and heap names, or
57 MemoryAllocatorDump* GetAllocatorDump(const std::string& name) const; 70 // nullptr if not found.
71 MemoryAllocatorDump* GetAllocatorDump(const std::string& allocator_name,
72 const std::string& heap_name) const;
58 73
59 // Returns the map of the MemoryAllocatorDumps added to this dump. 74 // Returns the map of the MemoryAllocatorDumps added to this dump.
60 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } 75 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; }
61 76
77 const scoped_refptr<MemoryDumpSessionState>& session_state() const {
78 return session_state_;
79 }
80
62 private: 81 private:
63 ProcessMemoryTotals process_totals_; 82 ProcessMemoryTotals process_totals_;
64 bool has_process_totals_; 83 bool has_process_totals_;
65 84
66 ProcessMemoryMaps process_mmaps_; 85 ProcessMemoryMaps process_mmaps_;
67 bool has_process_mmaps_; 86 bool has_process_mmaps_;
68 87
69 // A maps of "allocator_name" -> MemoryAllocatorDump populated by
70 // allocator dump providers.
71 AllocatorDumpsMap allocator_dumps_; 88 AllocatorDumpsMap allocator_dumps_;
72 89
73 // ProcessMemoryDump handles the memory ownership of all its belongings. 90 // ProcessMemoryDump handles the memory ownership of all its belongings.
74 ScopedVector<MemoryAllocatorDump> allocator_dumps_storage_; 91 ScopedVector<MemoryAllocatorDump> allocator_dumps_storage_;
75 92
93 // State shared among all PMDs instances created in a given trace session.
94 scoped_refptr<MemoryDumpSessionState> session_state_;
95
76 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 96 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
77 }; 97 };
78 98
79 } // namespace trace_event 99 } // namespace trace_event
80 } // namespace base 100 } // namespace base
81 101
82 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 102 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698