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 <memory> | 10 #include <memory> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 // - "size" column (all dumps are expected to have at least this one): | 56 // - "size" column (all dumps are expected to have at least this one): |
57 // AddScalar(kNameSize, kUnitsBytes, 1234); | 57 // AddScalar(kNameSize, kUnitsBytes, 1234); |
58 // - Some extra-column reporting internal details of the subsystem: | 58 // - Some extra-column reporting internal details of the subsystem: |
59 // AddScalar("number_of_freelist_entires", kUnitsObjects, 42) | 59 // AddScalar("number_of_freelist_entires", kUnitsObjects, 42) |
60 // - Other informational column (will not be auto-added in the UI) | 60 // - Other informational column (will not be auto-added in the UI) |
61 // AddScalarF("kittens_ratio", "ratio", 42.0f) | 61 // AddScalarF("kittens_ratio", "ratio", 42.0f) |
62 void AddScalar(const char* name, const char* units, uint64_t value); | 62 void AddScalar(const char* name, const char* units, uint64_t value); |
63 void AddScalarF(const char* name, const char* units, double value); | 63 void AddScalarF(const char* name, const char* units, double value); |
64 void AddString(const char* name, const char* units, const std::string& value); | 64 void AddString(const char* name, const char* units, const std::string& value); |
65 | 65 |
66 // Get the size for this dump. | |
67 // The size is the value set with AddScalar(kNameSize, kUnitsBytes, size); | |
68 uint64_t GetSize(); | |
Primiano Tucci (use gerrit)
2017/03/22 17:19:52
can you plz:
- make this private (or protected, if
hjd
2017/03/22 19:24:20
Done.
| |
69 | |
66 // Absolute name, unique within the scope of an entire ProcessMemoryDump. | 70 // Absolute name, unique within the scope of an entire ProcessMemoryDump. |
67 const std::string& absolute_name() const { return absolute_name_; } | 71 const std::string& absolute_name() const { return absolute_name_; } |
68 | 72 |
69 // Called at trace generation time to populate the TracedValue. | 73 // Called at trace generation time to populate the TracedValue. |
70 void AsValueInto(TracedValue* value) const; | 74 void AsValueInto(TracedValue* value) const; |
71 | 75 |
72 // Use enum Flags to set values. | 76 // Use enum Flags to set values. |
73 void set_flags(int flags) { flags_ |= flags; } | 77 void set_flags(int flags) { flags_ |= flags; } |
74 void clear_flags(int flags) { flags_ &= ~flags; } | 78 void clear_flags(int flags) { flags_ &= ~flags; } |
75 int flags() { return flags_; } | 79 int flags() { return flags_; } |
76 | 80 |
77 // |guid| is an optional global dump identifier, unique across all processes | 81 // |guid| is an optional global dump identifier, unique across all processes |
78 // within the scope of a global dump. It is only required when using the | 82 // within the scope of a global dump. It is only required when using the |
79 // graph APIs (see TODO_method_name) to express retention / suballocation or | 83 // graph APIs (see TODO_method_name) to express retention / suballocation or |
80 // cross process sharing. See crbug.com/492102 for design docs. | 84 // cross process sharing. See crbug.com/492102 for design docs. |
81 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are | 85 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are |
82 // expected to have the same guid. | 86 // expected to have the same guid. |
83 const MemoryAllocatorDumpGuid& guid() const { return guid_; } | 87 const MemoryAllocatorDumpGuid& guid() const { return guid_; } |
84 | 88 |
85 TracedValue* attributes_for_testing() const { return attributes_.get(); } | 89 TracedValue* attributes_for_testing() const { return attributes_.get(); } |
86 | 90 |
87 private: | 91 private: |
88 const std::string absolute_name_; | 92 const std::string absolute_name_; |
89 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). | 93 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). |
90 std::unique_ptr<TracedValue> attributes_; | 94 std::unique_ptr<TracedValue> attributes_; |
91 MemoryAllocatorDumpGuid guid_; | 95 MemoryAllocatorDumpGuid guid_; |
92 int flags_; // See enum Flags. | 96 int flags_; // See enum Flags. |
97 uint64_t size_; | |
93 | 98 |
94 // A local buffer for Sprintf conversion on fastpath. Avoids allocating | 99 // A local buffer for Sprintf conversion on fastpath. Avoids allocating |
95 // temporary strings on each AddScalar() call. | 100 // temporary strings on each AddScalar() call. |
96 std::string string_conversion_buffer_; | 101 std::string string_conversion_buffer_; |
97 | 102 |
98 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); | 103 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); |
99 }; | 104 }; |
100 | 105 |
101 } // namespace trace_event | 106 } // namespace trace_event |
102 } // namespace base | 107 } // namespace base |
103 | 108 |
104 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ | 109 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ |
OLD | NEW |