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 COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CHILD_DISCARDABLE_SHARED_MEMORY_MAN AGER_H_ |
6 #define CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 6 #define COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CHILD_DISCARDABLE_SHARED_MEMORY_MAN AGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/discardable_memory_allocator.h" | 11 #include "base/memory/discardable_memory_allocator.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/trace_event/memory_dump_provider.h" | 14 #include "base/trace_event/memory_dump_provider.h" |
15 #include "content/child/thread_safe_sender.h" | 15 #include "components/discardable_memory/common/discardable_memory_export.h" |
16 #include "content/common/content_export.h" | 16 #include "components/discardable_memory/common/discardable_shared_memory_heap.h" |
17 #include "content/common/discardable_shared_memory_heap.h" | 17 #include "components/discardable_memory/common/discardable_shared_memory_manager .h" |
18 #include "content/common/host_discardable_shared_memory_manager.h" | |
19 | 18 |
20 namespace content { | 19 namespace discardable_memory { |
21 | 20 |
22 // Implementation of DiscardableMemoryAllocator that allocates | 21 // Implementation of DiscardableMemoryAllocator that allocates |
23 // discardable memory segments through the browser process. | 22 // discardable memory segments through the browser process. |
24 class CONTENT_EXPORT ChildDiscardableSharedMemoryManager | 23 class DISCARDABLE_MEMORY_EXPORT ChildDiscardableSharedMemoryManager |
25 : public base::DiscardableMemoryAllocator, | 24 : public base::DiscardableMemoryAllocator, |
26 public base::trace_event::MemoryDumpProvider { | 25 public base::trace_event::MemoryDumpProvider { |
27 public: | 26 public: |
28 explicit ChildDiscardableSharedMemoryManager(ThreadSafeSender* sender); | 27 class Delegate { |
28 public: | |
29 virtual ~Delegate() {} | |
reveman
2016/10/31 22:46:02
nit: can this be protected?
Peng
2016/11/01 14:26:18
Done.
| |
30 virtual void AllocateLockedDiscardableSharedMemory( | |
31 size_t size, | |
32 DiscardableSharedMemoryId id, | |
33 base::SharedMemoryHandle* handle) = 0; | |
34 virtual void DeletedDiscardableSharedMemory( | |
35 DiscardableSharedMemoryId id) = 0; | |
36 }; | |
37 | |
38 explicit ChildDiscardableSharedMemoryManager(Delegate* delegate); | |
29 ~ChildDiscardableSharedMemoryManager() override; | 39 ~ChildDiscardableSharedMemoryManager() override; |
30 | 40 |
31 // Overridden from base::DiscardableMemoryAllocator: | 41 // Overridden from base::DiscardableMemoryAllocator: |
32 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( | 42 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( |
33 size_t size) override; | 43 size_t size) override; |
34 | 44 |
35 // Overridden from base::trace_event::MemoryDumpProvider: | 45 // Overridden from base::trace_event::MemoryDumpProvider: |
36 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 46 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
37 base::trace_event::ProcessMemoryDump* pmd) override; | 47 base::trace_event::ProcessMemoryDump* pmd) override; |
38 | 48 |
(...skipping 18 matching lines...) Expand all Loading... | |
57 | 67 |
58 private: | 68 private: |
59 std::unique_ptr<base::DiscardableSharedMemory> | 69 std::unique_ptr<base::DiscardableSharedMemory> |
60 AllocateLockedDiscardableSharedMemory(size_t size, | 70 AllocateLockedDiscardableSharedMemory(size_t size, |
61 DiscardableSharedMemoryId id); | 71 DiscardableSharedMemoryId id); |
62 void MemoryUsageChanged(size_t new_bytes_allocated, | 72 void MemoryUsageChanged(size_t new_bytes_allocated, |
63 size_t new_bytes_free) const; | 73 size_t new_bytes_free) const; |
64 | 74 |
65 mutable base::Lock lock_; | 75 mutable base::Lock lock_; |
66 DiscardableSharedMemoryHeap heap_; | 76 DiscardableSharedMemoryHeap heap_; |
67 scoped_refptr<ThreadSafeSender> sender_; | 77 Delegate* delegate_; |
reveman
2016/10/31 22:46:02
nit: Delegate* const delegate_
Peng
2016/11/01 14:26:18
Done.
| |
68 | 78 |
69 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); | 79 DISALLOW_COPY_AND_ASSIGN(ChildDiscardableSharedMemoryManager); |
70 }; | 80 }; |
71 | 81 |
72 } // namespace content | 82 } // namespace discardable_memory |
73 | 83 |
74 #endif // CONTENT_CHILD_CHILD_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 84 #endif // COMPONENTS_DISCARDABLE_MEMORY_CLIENT_CHILD_DISCARDABLE_SHARED_MEMORY_ MANAGER_H_ |
OLD | NEW |