| 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 COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ | 5 #ifndef COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ |
| 6 #define COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ | 6 #define COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
| 23 #include "base/memory/shared_memory.h" | 23 #include "base/memory/shared_memory.h" |
| 24 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
| 25 #include "base/process/process_handle.h" | 25 #include "base/process/process_handle.h" |
| 26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/trace_event/memory_dump_provider.h" | 28 #include "base/trace_event/memory_dump_provider.h" |
| 29 #include "components/discardable_memory/common/discardable_memory_export.h" | 29 #include "components/discardable_memory/common/discardable_memory_export.h" |
| 30 #include "components/discardable_memory/public/interfaces/discardable_shared_mem
ory_manager.mojom.h" | 30 #include "components/discardable_memory/public/interfaces/discardable_shared_mem
ory_manager.mojom.h" |
| 31 | 31 |
| 32 namespace service_manager { |
| 33 struct BindSourceInfo; |
| 34 } |
| 35 |
| 32 namespace discardable_memory { | 36 namespace discardable_memory { |
| 33 | 37 |
| 34 // Implementation of DiscardableMemoryAllocator that allocates and manages | 38 // Implementation of DiscardableMemoryAllocator that allocates and manages |
| 35 // discardable memory segments for the process which hosts this class, and | 39 // discardable memory segments for the process which hosts this class, and |
| 36 // for remote processes which request discardable memory from this class via | 40 // for remote processes which request discardable memory from this class via |
| 37 // IPC. | 41 // IPC. |
| 38 // This class is thread-safe and instances can safely be used on any thread. | 42 // This class is thread-safe and instances can safely be used on any thread. |
| 39 class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager | 43 class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager |
| 40 : public base::DiscardableMemoryAllocator, | 44 : public base::DiscardableMemoryAllocator, |
| 41 public base::trace_event::MemoryDumpProvider, | 45 public base::trace_event::MemoryDumpProvider, |
| 42 public base::MemoryCoordinatorClient { | 46 public base::MemoryCoordinatorClient { |
| 43 public: | 47 public: |
| 44 DiscardableSharedMemoryManager(); | 48 DiscardableSharedMemoryManager(); |
| 45 ~DiscardableSharedMemoryManager() override; | 49 ~DiscardableSharedMemoryManager() override; |
| 46 | 50 |
| 47 // Bind the manager to a mojo interface request. | 51 // Bind the manager to a mojo interface request. |
| 48 void Bind(mojom::DiscardableSharedMemoryManagerRequest request); | 52 void Bind(const service_manager::BindSourceInfo& source_info, |
| 53 mojom::DiscardableSharedMemoryManagerRequest request); |
| 49 | 54 |
| 50 // Overridden from base::DiscardableMemoryAllocator: | 55 // Overridden from base::DiscardableMemoryAllocator: |
| 51 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( | 56 std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( |
| 52 size_t size) override; | 57 size_t size) override; |
| 53 | 58 |
| 54 // Overridden from base::trace_event::MemoryDumpProvider: | 59 // Overridden from base::trace_event::MemoryDumpProvider: |
| 55 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 60 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 56 base::trace_event::ProcessMemoryDump* pmd) override; | 61 base::trace_event::ProcessMemoryDump* pmd) override; |
| 57 | 62 |
| 58 // This allocates a discardable memory segment for |process_handle|. | 63 // This allocates a discardable memory segment for |process_handle|. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::Closure enforce_memory_policy_callback_; | 151 base::Closure enforce_memory_policy_callback_; |
| 147 bool enforce_memory_policy_pending_; | 152 bool enforce_memory_policy_pending_; |
| 148 base::WeakPtrFactory<DiscardableSharedMemoryManager> weak_ptr_factory_; | 153 base::WeakPtrFactory<DiscardableSharedMemoryManager> weak_ptr_factory_; |
| 149 | 154 |
| 150 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryManager); | 155 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryManager); |
| 151 }; | 156 }; |
| 152 | 157 |
| 153 } // namespace discardable_memory | 158 } // namespace discardable_memory |
| 154 | 159 |
| 155 #endif // COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAG
ER_H_ | 160 #endif // COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAG
ER_H_ |
| OLD | NEW |