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 "base/memory/discardable_memory_allocator.h" | 8 #include "base/memory/discardable_memory_allocator.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 public base::trace_event::MemoryDumpProvider { | 23 public base::trace_event::MemoryDumpProvider { |
24 public: | 24 public: |
25 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); | 25 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); |
26 ~ChildDiscardableSharedMemoryManager() override; | 26 ~ChildDiscardableSharedMemoryManager() override; |
27 | 27 |
28 // Overridden from base::DiscardableMemoryAllocator: | 28 // Overridden from base::DiscardableMemoryAllocator: |
29 scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( | 29 scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( |
30 size_t size) override; | 30 size_t size) override; |
31 | 31 |
32 // Overridden from base::trace_event::MemoryDumpProvider: | 32 // Overridden from base::trace_event::MemoryDumpProvider: |
33 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; | 33 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 34 base::trace_event::ProcessMemoryDump* pmd) override; |
34 | 35 |
35 // Release memory and associated resources that have been purged. | 36 // Release memory and associated resources that have been purged. |
36 void ReleaseFreeMemory(); | 37 void ReleaseFreeMemory(); |
37 | 38 |
38 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); | 39 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); |
39 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); | 40 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); |
40 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); | 41 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); |
41 | 42 |
42 private: | 43 private: |
43 scoped_ptr<base::DiscardableSharedMemory> | 44 scoped_ptr<base::DiscardableSharedMemory> |
44 AllocateLockedDiscardableSharedMemory(size_t size, | 45 AllocateLockedDiscardableSharedMemory(size_t size, |
45 DiscardableSharedMemoryId id); | 46 DiscardableSharedMemoryId id); |
46 void MemoryUsageChanged(size_t new_bytes_allocated, | 47 void MemoryUsageChanged(size_t new_bytes_allocated, |
47 size_t new_bytes_free) const; | 48 size_t new_bytes_free) const; |
48 | 49 |
49 mutable base::Lock lock_; | 50 mutable base::Lock lock_; |
50 DiscardableSharedMemoryHeap heap_; | 51 DiscardableSharedMemoryHeap heap_; |
51 scoped_refptr<ThreadSafeSender> sender_; | 52 scoped_refptr<ThreadSafeSender> sender_; |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); | 54 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace content | 57 } // namespace content |
57 | 58 |
58 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 59 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
OLD | NEW |