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 Flag { | |
30 // A dump marked weak will be removed from tracing. It is used when dump | |
petrcermak
2016/01/18 11:23:46
nit: "... removed from tracing, unless it was/will
ssid
2016/01/18 16:28:35
Hm, I think as far as mad is concerned, it means t
petrcermak
2016/01/18 17:18:12
Good point. My concern is that this suggests that
| |
31 // provider is unsure of the existance of memory. | |
petrcermak
2016/01/18 11:23:46
s/existance/existence/
petrcermak
2016/01/18 11:23:46
nit: s/memory/a block of memory/ (memory always ex
ssid
2016/01/18 16:28:35
Done.
ssid
2016/01/18 16:28:35
Done.
| |
32 WEAK = 1 << 0, | |
33 }; | |
34 | |
29 // MemoryAllocatorDump is owned by ProcessMemoryDump. | 35 // MemoryAllocatorDump is owned by ProcessMemoryDump. |
30 MemoryAllocatorDump(const std::string& absolute_name, | 36 MemoryAllocatorDump(const std::string& absolute_name, |
31 ProcessMemoryDump* process_memory_dump, | 37 ProcessMemoryDump* process_memory_dump, |
38 const MemoryAllocatorDumpGuid& guid, | |
39 uint8_t flags); | |
petrcermak
2016/01/18 11:23:46
As explained in my comment in ProcessMemoryDump, a
ssid
2016/01/18 16:28:35
true.
| |
40 MemoryAllocatorDump(const std::string& absolute_name, | |
41 ProcessMemoryDump* process_memory_dump, | |
32 const MemoryAllocatorDumpGuid& guid); | 42 const MemoryAllocatorDumpGuid& guid); |
33 MemoryAllocatorDump(const std::string& absolute_name, | 43 MemoryAllocatorDump(const std::string& absolute_name, |
34 ProcessMemoryDump* process_memory_dump); | 44 ProcessMemoryDump* process_memory_dump); |
35 ~MemoryAllocatorDump(); | 45 ~MemoryAllocatorDump(); |
36 | 46 |
37 // Standard attribute |name|s for the AddScalar and AddString() methods. | 47 // Standard attribute |name|s for the AddScalar and AddString() methods. |
38 static const char kNameSize[]; // To represent allocated space. | 48 static const char kNameSize[]; // To represent allocated space. |
39 static const char kNameObjectCount[]; // To represent number of objects. | 49 static const char kNameObjectCount[]; // To represent number of objects. |
40 | 50 |
41 // Standard attribute |unit|s for the AddScalar and AddString() methods. | 51 // Standard attribute |unit|s for the AddScalar and AddString() methods. |
(...skipping 19 matching lines...) Expand all Loading... | |
61 const std::string& absolute_name() const { return absolute_name_; } | 71 const std::string& absolute_name() const { return absolute_name_; } |
62 | 72 |
63 // Called at trace generation time to populate the TracedValue. | 73 // Called at trace generation time to populate the TracedValue. |
64 void AsValueInto(TracedValue* value) const; | 74 void AsValueInto(TracedValue* value) const; |
65 | 75 |
66 // Get the ProcessMemoryDump instance that owns this. | 76 // Get the ProcessMemoryDump instance that owns this. |
67 ProcessMemoryDump* process_memory_dump() const { | 77 ProcessMemoryDump* process_memory_dump() const { |
68 return process_memory_dump_; | 78 return process_memory_dump_; |
69 } | 79 } |
70 | 80 |
81 // Use enum Flag to set values. | |
82 void set_flags(uint8_t flags) { flags_ |= flags; } | |
83 void unset_flags(uint8_t flags) { flags_ &= ~flags; } | |
84 uint8_t flags() { return flags_; } | |
85 | |
71 // |guid| is an optional global dump identifier, unique across all processes | 86 // |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 | 87 // 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 | 88 // graph APIs (see TODO_method_name) to express retention / suballocation or |
74 // cross process sharing. See crbug.com/492102 for design docs. | 89 // cross process sharing. See crbug.com/492102 for design docs. |
75 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are | 90 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are |
76 // expected to have the same guid. | 91 // expected to have the same guid. |
77 const MemoryAllocatorDumpGuid& guid() const { return guid_; } | 92 const MemoryAllocatorDumpGuid& guid() const { return guid_; } |
78 | 93 |
79 TracedValue* attributes_for_testing() const { return attributes_.get(); } | 94 TracedValue* attributes_for_testing() const { return attributes_.get(); } |
80 | 95 |
81 private: | 96 private: |
82 const std::string absolute_name_; | 97 const std::string absolute_name_; |
83 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). | 98 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). |
84 scoped_refptr<TracedValue> attributes_; | 99 scoped_refptr<TracedValue> attributes_; |
85 MemoryAllocatorDumpGuid guid_; | 100 MemoryAllocatorDumpGuid guid_; |
101 uint8_t flags_; // See enum Flag. | |
86 | 102 |
87 // A local buffer for Sprintf conversion on fastpath. Avoids allocating | 103 // A local buffer for Sprintf conversion on fastpath. Avoids allocating |
88 // temporary strings on each AddScalar() call. | 104 // temporary strings on each AddScalar() call. |
89 std::string string_conversion_buffer_; | 105 std::string string_conversion_buffer_; |
90 | 106 |
91 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); | 107 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); |
92 }; | 108 }; |
93 | 109 |
94 } // namespace trace_event | 110 } // namespace trace_event |
95 } // namespace base | 111 } // namespace base |
96 | 112 |
97 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ | 113 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ |
OLD | NEW |