| 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_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 5 #ifndef CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| 6 #define CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 6 #define CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" |
| 10 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 11 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 12 #include "base/memory/discardable_memory_allocator.h" | 13 #include "base/memory/discardable_memory_allocator.h" |
| 13 #include "base/memory/discardable_shared_memory.h" | 14 #include "base/memory/discardable_shared_memory.h" |
| 14 #include "base/memory/memory_pressure_listener.h" | 15 #include "base/memory/memory_pressure_listener.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
| 17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 18 #include "base/process/process_handle.h" | 19 #include "base/process/process_handle.h" |
| 19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 21 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/trace_event/memory_dump_provider.h" | 22 #include "base/trace_event/memory_dump_provider.h" |
| 21 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
| 22 | 24 |
| 23 namespace content { | 25 namespace content { |
| 24 typedef int32_t DiscardableSharedMemoryId; | 26 typedef int32_t DiscardableSharedMemoryId; |
| 25 | 27 |
| 26 // Implementation of DiscardableMemoryAllocator that allocates and manages | 28 // Implementation of DiscardableMemoryAllocator that allocates and manages |
| 27 // discardable memory segments for the browser process and child processes. | 29 // discardable memory segments for the browser process and child processes. |
| 28 // This class is thread-safe and instances can safely be used on any thread. | 30 // This class is thread-safe and instances can safely be used on any thread. |
| 29 class CONTENT_EXPORT HostDiscardableSharedMemoryManager | 31 class CONTENT_EXPORT HostDiscardableSharedMemoryManager |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 scoped_refptr<MemorySegment>> MemorySegmentMap; | 122 scoped_refptr<MemorySegment>> MemorySegmentMap; |
| 121 typedef base::hash_map<int, MemorySegmentMap> ProcessMap; | 123 typedef base::hash_map<int, MemorySegmentMap> ProcessMap; |
| 122 ProcessMap processes_; | 124 ProcessMap processes_; |
| 123 // Note: The elements in |segments_| are arranged in such a way that they form | 125 // Note: The elements in |segments_| are arranged in such a way that they form |
| 124 // a heap. The LRU memory segment always first. | 126 // a heap. The LRU memory segment always first. |
| 125 typedef std::vector<scoped_refptr<MemorySegment>> MemorySegmentVector; | 127 typedef std::vector<scoped_refptr<MemorySegment>> MemorySegmentVector; |
| 126 MemorySegmentVector segments_; | 128 MemorySegmentVector segments_; |
| 127 size_t memory_limit_; | 129 size_t memory_limit_; |
| 128 size_t bytes_allocated_; | 130 size_t bytes_allocated_; |
| 129 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 131 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
| 132 scoped_refptr<base::SingleThreadTaskRunner> |
| 133 enforce_memory_policy_task_runner_; |
| 134 base::Closure enforce_memory_policy_callback_; |
| 130 bool enforce_memory_policy_pending_; | 135 bool enforce_memory_policy_pending_; |
| 131 base::WeakPtrFactory<HostDiscardableSharedMemoryManager> weak_ptr_factory_; | 136 base::WeakPtrFactory<HostDiscardableSharedMemoryManager> weak_ptr_factory_; |
| 132 | 137 |
| 133 DISALLOW_COPY_AND_ASSIGN(HostDiscardableSharedMemoryManager); | 138 DISALLOW_COPY_AND_ASSIGN(HostDiscardableSharedMemoryManager); |
| 134 }; | 139 }; |
| 135 | 140 |
| 136 } // namespace content | 141 } // namespace content |
| 137 | 142 |
| 138 #endif // CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ | 143 #endif // CONTENT_COMMON_HOST_DISCARDABLE_SHARED_MEMORY_MANAGER_H_ |
| OLD | NEW |