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

Side by Side Diff: content/common/discardable_shared_memory_heap.h

Issue 1306243003: Add support to create memory allocator dump in base::DiscardableMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix html_viewer. Created 5 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ 5 #ifndef CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_
6 #define CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ 6 #define CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/containers/linked_list.h" 10 #include "base/containers/linked_list.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 // Dumps memory statistics for chrome://tracing. 88 // Dumps memory statistics for chrome://tracing.
89 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd); 89 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd);
90 90
91 // Returns a unique identifier for a given tuple of (process id, segment id) 91 // Returns a unique identifier for a given tuple of (process id, segment id)
92 // that can be used to match memory dumps across different processes. 92 // that can be used to match memory dumps across different processes.
93 static base::trace_event::MemoryAllocatorDumpGuid GetSegmentGUIDForTracing( 93 static base::trace_event::MemoryAllocatorDumpGuid GetSegmentGUIDForTracing(
94 uint64 tracing_process_id, 94 uint64 tracing_process_id,
95 int32 segment_id); 95 int32 segment_id);
96 96
97 // Returns a MemoryAllocatorDump for a given span on |pmd| with the size of
98 // the span.
99 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
100 Span* span,
101 const char* name,
102 base::trace_event::ProcessMemoryDump* pmd) const;
103
97 private: 104 private:
98 class ScopedMemorySegment { 105 class ScopedMemorySegment {
99 public: 106 public:
100 ScopedMemorySegment(DiscardableSharedMemoryHeap* heap, 107 ScopedMemorySegment(DiscardableSharedMemoryHeap* heap,
101 scoped_ptr<base::DiscardableSharedMemory> shared_memory, 108 scoped_ptr<base::DiscardableSharedMemory> shared_memory,
102 size_t size, 109 size_t size,
103 int32_t id, 110 int32_t id,
104 const base::Closure& deleted_callback); 111 const base::Closure& deleted_callback);
105 ~ScopedMemorySegment(); 112 ~ScopedMemorySegment();
106 113
107 bool IsUsed() const; 114 bool IsUsed() const;
108 bool IsResident() const; 115 bool IsResident() const;
109 116
117 bool ContainsSpan(Span* span) const;
118
119 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
120 Span* span,
121 const char* name,
122 base::trace_event::ProcessMemoryDump* pmd) const;
123
110 // Used for dumping memory statistics from the segment to chrome://tracing. 124 // Used for dumping memory statistics from the segment to chrome://tracing.
111 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) const; 125 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) const;
112 126
113 private: 127 private:
114 DiscardableSharedMemoryHeap* const heap_; 128 DiscardableSharedMemoryHeap* const heap_;
115 scoped_ptr<base::DiscardableSharedMemory> shared_memory_; 129 scoped_ptr<base::DiscardableSharedMemory> shared_memory_;
116 const size_t size_; 130 const size_t size_;
117 const int32_t id_; 131 const int32_t id_;
118 const base::Closure deleted_callback_; 132 const base::Closure deleted_callback_;
119 133
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // is a free list of runs that consist of k blocks. The 256th entry is a 167 // is a free list of runs that consist of k blocks. The 256th entry is a
154 // free list of runs that have length >= 256 blocks. 168 // free list of runs that have length >= 256 blocks.
155 base::LinkedList<Span> free_spans_[256]; 169 base::LinkedList<Span> free_spans_[256];
156 170
157 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap); 171 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap);
158 }; 172 };
159 173
160 } // namespace content 174 } // namespace content
161 175
162 #endif // CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ 176 #endif // CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_
OLDNEW
« no previous file with comments | « content/child/child_discardable_shared_memory_manager.cc ('k') | content/common/discardable_shared_memory_heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698