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_shmem_allocator.h" | 8 #include "base/memory/discardable_memory_shmem_allocator.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/synchronization/lock.h" |
10 #include "content/child/thread_safe_sender.h" | 11 #include "content/child/thread_safe_sender.h" |
| 12 #include "content/common/discardable_shared_memory_heap.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 // Implementation of DiscardableMemoryShmemAllocator that allocates | 16 // Implementation of DiscardableMemoryShmemAllocator that allocates |
15 // discardable memory segments through the browser process. | 17 // discardable memory segments through the browser process. |
16 class ChildDiscardableSharedMemoryManager | 18 class ChildDiscardableSharedMemoryManager |
17 : public base::DiscardableMemoryShmemAllocator { | 19 : public base::DiscardableMemoryShmemAllocator { |
18 public: | 20 public: |
19 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); | 21 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); |
20 ~ChildDiscardableSharedMemoryManager() override; | 22 ~ChildDiscardableSharedMemoryManager() override; |
21 | 23 |
22 // Overridden from base::DiscardableMemoryShmemAllocator: | 24 // Overridden from base::DiscardableMemoryShmemAllocator: |
23 scoped_ptr<base::DiscardableSharedMemory> | 25 scoped_ptr<base::DiscardableMemoryShmemChunk> AllocateLockedDiscardableMemory( |
24 AllocateLockedDiscardableSharedMemory(size_t size) override; | 26 size_t size) override; |
| 27 |
| 28 bool LockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 29 void UnlockSpan(DiscardableSharedMemoryHeap::Span* span); |
| 30 bool IsSpanResident(DiscardableSharedMemoryHeap::Span* span) const; |
| 31 void ReleaseSpan(scoped_ptr<DiscardableSharedMemoryHeap::Span> span); |
25 | 32 |
26 private: | 33 private: |
| 34 scoped_ptr<base::DiscardableSharedMemory> |
| 35 AllocateLockedDiscardableSharedMemory(size_t size); |
| 36 |
| 37 mutable base::Lock lock_; |
| 38 DiscardableSharedMemoryHeap heap_; |
27 scoped_refptr<ThreadSafeSender> sender_; | 39 scoped_refptr<ThreadSafeSender> sender_; |
28 | 40 |
29 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); | 41 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); |
30 }; | 42 }; |
31 | 43 |
32 } // namespace content | 44 } // namespace content |
33 | 45 |
34 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 46 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
OLD | NEW |