OLD | NEW |
---|---|
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_MEMORY_ALLOCATOR_DUMP_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ |
6 #define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/trace_event/memory_allocator_dump_guid.h" | 16 #include "base/trace_event/memory_allocator_dump_guid.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 namespace trace_event { | 20 namespace trace_event { |
21 | 21 |
22 class MemoryDumpManager; | 22 class MemoryDumpManager; |
23 class ProcessMemoryDump; | 23 class ProcessMemoryDump; |
24 class TracedValue; | 24 class TracedValue; |
25 | 25 |
26 // Data model for user-land memory allocator dumps. | 26 // Data model for user-land memory allocator dumps. |
27 class BASE_EXPORT MemoryAllocatorDump { | 27 class BASE_EXPORT MemoryAllocatorDump { |
28 public: | 28 public: |
29 enum Flags { | |
petrcermak
2016/01/13 17:46:14
I think that this should be called "Flag" (singula
ssid
2016/01/15 17:14:56
Done.
| |
30 // A weak dump is made invalid unless it is marked strong later, either by | |
petrcermak
2016/01/13 17:46:14
It could also be 'marked' strong "earlier".
petrcermak
2016/01/13 17:46:14
Please don't use the word "invalid" because we don
ssid
2016/01/15 17:14:56
Done.
ssid
2016/01/15 17:14:56
Done.
| |
31 // the same process or at least one process in case of global dumps. | |
32 // All dumps that own an invalid dump and all its children will be marked | |
petrcermak
2016/01/13 17:46:14
nit: I'd say "All owners and children of a removed
ssid
2016/01/15 17:14:56
Done.
| |
33 // invalid transitively. Default value is 0. | |
petrcermak
2016/01/13 17:46:14
Rather than "Default value is 0", say "A dump is s
ssid
2016/01/15 17:14:56
Done.
| |
34 WEAK = 1 << 0 | |
35 }; | |
36 | |
29 // MemoryAllocatorDump is owned by ProcessMemoryDump. | 37 // MemoryAllocatorDump is owned by ProcessMemoryDump. |
30 MemoryAllocatorDump(const std::string& absolute_name, | 38 MemoryAllocatorDump(const std::string& absolute_name, |
31 ProcessMemoryDump* process_memory_dump, | 39 ProcessMemoryDump* process_memory_dump, |
32 const MemoryAllocatorDumpGuid& guid); | 40 const MemoryAllocatorDumpGuid& guid); |
33 MemoryAllocatorDump(const std::string& absolute_name, | 41 MemoryAllocatorDump(const std::string& absolute_name, |
34 ProcessMemoryDump* process_memory_dump); | 42 ProcessMemoryDump* process_memory_dump); |
35 ~MemoryAllocatorDump(); | 43 ~MemoryAllocatorDump(); |
36 | 44 |
37 // Standard attribute |name|s for the AddScalar and AddString() methods. | 45 // Standard attribute |name|s for the AddScalar and AddString() methods. |
38 static const char kNameSize[]; // To represent allocated space. | 46 static const char kNameSize[]; // To represent allocated space. |
(...skipping 14 matching lines...) Expand all Loading... | |
53 // AddScalar("number_of_freelist_entires", kUnitsObjects, 42) | 61 // AddScalar("number_of_freelist_entires", kUnitsObjects, 42) |
54 // - Other informational column (will not be auto-added in the UI) | 62 // - Other informational column (will not be auto-added in the UI) |
55 // AddScalarF("kittens_ratio", "ratio", 42.0f) | 63 // AddScalarF("kittens_ratio", "ratio", 42.0f) |
56 void AddScalar(const char* name, const char* units, uint64_t value); | 64 void AddScalar(const char* name, const char* units, uint64_t value); |
57 void AddScalarF(const char* name, const char* units, double value); | 65 void AddScalarF(const char* name, const char* units, double value); |
58 void AddString(const char* name, const char* units, const std::string& value); | 66 void AddString(const char* name, const char* units, const std::string& value); |
59 | 67 |
60 // Absolute name, unique within the scope of an entire ProcessMemoryDump. | 68 // Absolute name, unique within the scope of an entire ProcessMemoryDump. |
61 const std::string& absolute_name() const { return absolute_name_; } | 69 const std::string& absolute_name() const { return absolute_name_; } |
62 | 70 |
71 // Use Flags to set values. | |
72 void set_flags(int flags) { flags_ |= flags; } | |
73 void reset_flags(int flags) { flags_ &= !flags; } | |
petrcermak
2016/01/13 17:46:14
it this a naming convention? If not, "unset" might
ssid
2016/01/15 17:14:56
Done.
| |
74 bool flags() const { return flags_; } | |
petrcermak
2016/01/13 17:46:14
this shouldn't be a bool...
| |
75 | |
63 // Called at trace generation time to populate the TracedValue. | 76 // Called at trace generation time to populate the TracedValue. |
64 void AsValueInto(TracedValue* value) const; | 77 void AsValueInto(TracedValue* value) const; |
65 | 78 |
66 // Get the ProcessMemoryDump instance that owns this. | 79 // Get the ProcessMemoryDump instance that owns this. |
67 ProcessMemoryDump* process_memory_dump() const { | 80 ProcessMemoryDump* process_memory_dump() const { |
68 return process_memory_dump_; | 81 return process_memory_dump_; |
69 } | 82 } |
70 | 83 |
71 // |guid| is an optional global dump identifier, unique across all processes | 84 // |guid| is an optional global dump identifier, unique across all processes |
72 // within the scope of a global dump. It is only required when using the | 85 // within the scope of a global dump. It is only required when using the |
73 // graph APIs (see TODO_method_name) to express retention / suballocation or | 86 // graph APIs (see TODO_method_name) to express retention / suballocation or |
74 // cross process sharing. See crbug.com/492102 for design docs. | 87 // cross process sharing. See crbug.com/492102 for design docs. |
75 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are | 88 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are |
76 // expected to have the same guid. | 89 // expected to have the same guid. |
77 const MemoryAllocatorDumpGuid& guid() const { return guid_; } | 90 const MemoryAllocatorDumpGuid& guid() const { return guid_; } |
78 | 91 |
79 TracedValue* attributes_for_testing() const { return attributes_.get(); } | 92 TracedValue* attributes_for_testing() const { return attributes_.get(); } |
80 | 93 |
81 private: | 94 private: |
82 const std::string absolute_name_; | 95 const std::string absolute_name_; |
83 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). | 96 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). |
84 scoped_refptr<TracedValue> attributes_; | 97 scoped_refptr<TracedValue> attributes_; |
85 MemoryAllocatorDumpGuid guid_; | 98 MemoryAllocatorDumpGuid guid_; |
99 int flags_; // See Flags. | |
petrcermak
2016/01/13 17:46:14
I think that this should be unsigned or Flag (even
ssid
2016/01/15 17:14:56
Hm I made this integer because the traceValue acce
| |
86 | 100 |
87 // A local buffer for Sprintf conversion on fastpath. Avoids allocating | 101 // A local buffer for Sprintf conversion on fastpath. Avoids allocating |
88 // temporary strings on each AddScalar() call. | 102 // temporary strings on each AddScalar() call. |
89 std::string string_conversion_buffer_; | 103 std::string string_conversion_buffer_; |
90 | 104 |
91 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); | 105 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); |
92 }; | 106 }; |
93 | 107 |
94 } // namespace trace_event | 108 } // namespace trace_event |
95 } // namespace base | 109 } // namespace base |
96 | 110 |
97 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ | 111 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ |
OLD | NEW |