| 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_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 5 #ifndef CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| 6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 ~ChildDiscardableSharedMemoryManager() override; | 29 ~ChildDiscardableSharedMemoryManager() override; |
| 30 | 30 |
| 31 // Overridden from base::DiscardableMemoryAllocator: | 31 // Overridden from base::DiscardableMemoryAllocator: |
| 32 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( | 32 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( |
| 33 size_t size) override; | 33 size_t size) override; |
| 34 | 34 |
| 35 // Overridden from base::trace_event::MemoryDumpProvider: | 35 // Overridden from base::trace_event::MemoryDumpProvider: |
| 36 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 36 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 37 base::trace_event::ProcessMemoryDump* pmd) override; | 37 base::trace_event::ProcessMemoryDump* pmd) override; |
| 38 | 38 |
| 39 size_t GetMemoryUsage() const; |
| 40 |
| 39 // Release memory and associated resources that have been purged. | 41 // Release memory and associated resources that have been purged. |
| 40 void ReleaseFreeMemory(); | 42 void ReleaseFreeMemory(); |
| 41 | 43 |
| 42 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); | 44 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 43 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); | 45 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 44 void ReleaseSpan(std::unique_ptr<DiscardableSharedMemoryHeap::Span> span); | 46 void ReleaseSpan(std::unique_ptr<DiscardableSharedMemoryHeap::Span> span); |
| 45 | 47 |
| 46 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump( | 48 base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump( |
| 47 DiscardableSharedMemoryHeap::Span* span, | 49 DiscardableSharedMemoryHeap::Span* span, |
| 48 const char* name, | 50 const char* name, |
| 49 base::trace_event::ProcessMemoryDump* pmd) const; | 51 base::trace_event::ProcessMemoryDump* pmd) const; |
| 50 | 52 |
| 51 private: | 53 private: |
| 52 std::unique_ptr<base::DiscardableSharedMemory> | 54 std::unique_ptr<base::DiscardableSharedMemory> |
| 53 AllocateLockedDiscardableSharedMemory(size_t size, | 55 AllocateLockedDiscardableSharedMemory(size_t size, |
| 54 DiscardableSharedMemoryId id); | 56 DiscardableSharedMemoryId id); |
| 55 void MemoryUsageChanged(size_t new_bytes_allocated, | 57 void MemoryUsageChanged(size_t new_bytes_allocated, |
| 56 size_t new_bytes_free) const; | 58 size_t new_bytes_free) const; |
| 57 | 59 |
| 58 mutable base::Lock lock_; | 60 mutable base::Lock lock_; |
| 59 DiscardableSharedMemoryHeap heap_; | 61 DiscardableSharedMemoryHeap heap_; |
| 60 scoped_refptr<ThreadSafeSender> sender_; | 62 scoped_refptr<ThreadSafeSender> sender_; |
| 61 | 63 |
| 62 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); | 64 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 } // namespace content | 67 } // namespace content |
| 66 | 68 |
| 67 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 69 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| OLD | NEW |