| 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/memory/weak_ptr.h" | |
| 11 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 12 #include "content/child/thread_safe_sender.h" | 11 #include "content/child/thread_safe_sender.h" |
| 13 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 14 #include "content/common/discardable_shared_memory_heap.h" | 13 #include "content/common/discardable_shared_memory_heap.h" |
| 15 #include "content/common/host_discardable_shared_memory_manager.h" | 14 #include "content/common/host_discardable_shared_memory_manager.h" |
| 16 | 15 |
| 17 namespace content { | 16 namespace content { |
| 18 | 17 |
| 19 // Implementation of DiscardableMemoryAllocator that allocates | 18 // Implementation of DiscardableMemoryAllocator that allocates |
| 20 // discardable memory segments through the browser process. | 19 // discardable memory segments through the browser process. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 void ReleaseFreeMemory(); | 31 void ReleaseFreeMemory(); |
| 33 | 32 |
| 34 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); | 33 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 35 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); | 34 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 36 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); | 35 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 scoped_ptr<base::DiscardableSharedMemory> | 38 scoped_ptr<base::DiscardableSharedMemory> |
| 40 AllocateLockedDiscardableSharedMemory(size_t size, | 39 AllocateLockedDiscardableSharedMemory(size_t size, |
| 41 DiscardableSharedMemoryId id); | 40 DiscardableSharedMemoryId id); |
| 42 void DeletedDiscardableSharedMemory(DiscardableSharedMemoryId id); | |
| 43 void MemoryUsageChanged(size_t new_bytes_allocated, | 41 void MemoryUsageChanged(size_t new_bytes_allocated, |
| 44 size_t new_bytes_free) const; | 42 size_t new_bytes_free) const; |
| 45 | 43 |
| 46 mutable base::Lock lock_; | 44 mutable base::Lock lock_; |
| 47 DiscardableSharedMemoryHeap heap_; | 45 DiscardableSharedMemoryHeap heap_; |
| 48 scoped_refptr<ThreadSafeSender> sender_; | 46 scoped_refptr<ThreadSafeSender> sender_; |
| 49 base::WeakPtrFactory<ChildDiscardableSharedMemoryManager> weak_ptr_factory_; | |
| 50 | 47 |
| 51 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); | 48 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 } // namespace content | 51 } // namespace content |
| 55 | 52 |
| 56 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 53 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| OLD | NEW |