| OLD | NEW |
| 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 Loading... |
| 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 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump( |
| 118 Span* span, |
| 119 const char* name, |
| 120 base::trace_event::ProcessMemoryDump* pmd) const; |
| 121 |
| 110 // Used for dumping memory statistics from the segment to chrome://tracing. | 122 // Used for dumping memory statistics from the segment to chrome://tracing. |
| 111 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) const; | 123 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) const; |
| 112 | 124 |
| 113 private: | 125 private: |
| 114 DiscardableSharedMemoryHeap* const heap_; | 126 DiscardableSharedMemoryHeap* const heap_; |
| 115 scoped_ptr<base::DiscardableSharedMemory> shared_memory_; | 127 scoped_ptr<base::DiscardableSharedMemory> shared_memory_; |
| 116 const size_t size_; | 128 const size_t size_; |
| 117 const int32_t id_; | 129 const int32_t id_; |
| 118 const base::Closure deleted_callback_; | 130 const base::Closure deleted_callback_; |
| 119 | 131 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // is a free list of runs that consist of k blocks. The 256th entry is a | 165 // 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. | 166 // free list of runs that have length >= 256 blocks. |
| 155 base::LinkedList<Span> free_spans_[256]; | 167 base::LinkedList<Span> free_spans_[256]; |
| 156 | 168 |
| 157 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap); | 169 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap); |
| 158 }; | 170 }; |
| 159 | 171 |
| 160 } // namespace content | 172 } // namespace content |
| 161 | 173 |
| 162 #endif // CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ | 174 #endif // CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ |
| OLD | NEW |