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

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

Issue 1583483002: [tracing] Add method to create "weak" global dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 4 years, 11 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
« no previous file with comments | « no previous file | base/trace_event/memory_allocator_dump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 {
30 DEFAULT = 0,
31
32 // A dump marked weak will be discarded by TraceViewer.
33 WEAK = 1 << 0,
34 };
35
29 // MemoryAllocatorDump is owned by ProcessMemoryDump. 36 // MemoryAllocatorDump is owned by ProcessMemoryDump.
30 MemoryAllocatorDump(const std::string& absolute_name, 37 MemoryAllocatorDump(const std::string& absolute_name,
31 ProcessMemoryDump* process_memory_dump, 38 ProcessMemoryDump* process_memory_dump,
32 const MemoryAllocatorDumpGuid& guid); 39 const MemoryAllocatorDumpGuid& guid);
33 MemoryAllocatorDump(const std::string& absolute_name, 40 MemoryAllocatorDump(const std::string& absolute_name,
34 ProcessMemoryDump* process_memory_dump); 41 ProcessMemoryDump* process_memory_dump);
35 ~MemoryAllocatorDump(); 42 ~MemoryAllocatorDump();
36 43
37 // Standard attribute |name|s for the AddScalar and AddString() methods. 44 // Standard attribute |name|s for the AddScalar and AddString() methods.
38 static const char kNameSize[]; // To represent allocated space. 45 static const char kNameSize[]; // To represent allocated space.
(...skipping 22 matching lines...) Expand all
61 const std::string& absolute_name() const { return absolute_name_; } 68 const std::string& absolute_name() const { return absolute_name_; }
62 69
63 // Called at trace generation time to populate the TracedValue. 70 // Called at trace generation time to populate the TracedValue.
64 void AsValueInto(TracedValue* value) const; 71 void AsValueInto(TracedValue* value) const;
65 72
66 // Get the ProcessMemoryDump instance that owns this. 73 // Get the ProcessMemoryDump instance that owns this.
67 ProcessMemoryDump* process_memory_dump() const { 74 ProcessMemoryDump* process_memory_dump() const {
68 return process_memory_dump_; 75 return process_memory_dump_;
69 } 76 }
70 77
78 // Use enum Flags to set values.
79 void set_flags(int flags) { flags_ |= flags; }
80 void clear_flags(int flags) { flags_ &= ~flags; }
81 int flags() { return flags_; }
82
71 // |guid| is an optional global dump identifier, unique across all processes 83 // |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 84 // 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 85 // graph APIs (see TODO_method_name) to express retention / suballocation or
74 // cross process sharing. See crbug.com/492102 for design docs. 86 // cross process sharing. See crbug.com/492102 for design docs.
75 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are 87 // Subsequent MemoryAllocatorDump(s) with the same |absolute_name| are
76 // expected to have the same guid. 88 // expected to have the same guid.
77 const MemoryAllocatorDumpGuid& guid() const { return guid_; } 89 const MemoryAllocatorDumpGuid& guid() const { return guid_; }
78 90
79 TracedValue* attributes_for_testing() const { return attributes_.get(); } 91 TracedValue* attributes_for_testing() const { return attributes_.get(); }
80 92
81 private: 93 private:
82 const std::string absolute_name_; 94 const std::string absolute_name_;
83 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). 95 ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this).
84 scoped_refptr<TracedValue> attributes_; 96 scoped_refptr<TracedValue> attributes_;
85 MemoryAllocatorDumpGuid guid_; 97 MemoryAllocatorDumpGuid guid_;
98 int flags_; // See enum Flags.
86 99
87 // A local buffer for Sprintf conversion on fastpath. Avoids allocating 100 // A local buffer for Sprintf conversion on fastpath. Avoids allocating
88 // temporary strings on each AddScalar() call. 101 // temporary strings on each AddScalar() call.
89 std::string string_conversion_buffer_; 102 std::string string_conversion_buffer_;
90 103
91 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); 104 DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump);
92 }; 105 };
93 106
94 } // namespace trace_event 107 } // namespace trace_event
95 } // namespace base 108 } // namespace base
96 109
97 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_ 110 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_allocator_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698