Chromium Code Reviews| Index: components/discardable_memory/client/client_discardable_shared_memory_manager.h |
| diff --git a/components/discardable_memory/client/client_discardable_shared_memory_manager.h b/components/discardable_memory/client/client_discardable_shared_memory_manager.h |
| index 76215bc099f65ccd6cd36299f09ea531b29b1a4a..c3b1b4f0b07fbcdd3c2689e3aa7bef6a8170ea4d 100644 |
| --- a/components/discardable_memory/client/client_discardable_shared_memory_manager.h |
| +++ b/components/discardable_memory/client/client_discardable_shared_memory_manager.h |
| @@ -15,7 +15,11 @@ |
| #include "base/trace_event/memory_dump_provider.h" |
| #include "components/discardable_memory/common/discardable_memory_export.h" |
| #include "components/discardable_memory/common/discardable_shared_memory_heap.h" |
| -#include "components/discardable_memory/common/discardable_shared_memory_id.h" |
| +#include "components/discardable_memory/public/interfaces/discardable_memory.mojom.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| namespace discardable_memory { |
| @@ -25,20 +29,9 @@ class DISCARDABLE_MEMORY_EXPORT ClientDiscardableSharedMemoryManager |
| : public base::DiscardableMemoryAllocator, |
| public base::trace_event::MemoryDumpProvider { |
| public: |
| - class Delegate { |
| - public: |
| - virtual void AllocateLockedDiscardableSharedMemory( |
| - size_t size, |
| - DiscardableSharedMemoryId id, |
| - base::SharedMemoryHandle* handle) = 0; |
| - virtual void DeletedDiscardableSharedMemory( |
| - DiscardableSharedMemoryId id) = 0; |
| - |
| - protected: |
| - virtual ~Delegate() {} |
| - }; |
| - |
| - explicit ClientDiscardableSharedMemoryManager(Delegate* delegate); |
| + ClientDiscardableSharedMemoryManager( |
| + mojom::DiscardableSharedMemoryManagerPtrInfo info, |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); |
|
reveman
2016/11/11 20:17:26
s/scoped_refptr<base::SingleThreadTaskRunner>/base
Peng
2016/11/11 22:50:35
Done.
|
| ~ClientDiscardableSharedMemoryManager() override; |
| // Overridden from base::DiscardableMemoryAllocator: |
| @@ -69,15 +62,18 @@ class DISCARDABLE_MEMORY_EXPORT ClientDiscardableSharedMemoryManager |
| Statistics GetStatistics() const; |
| private: |
| + class ThreadSafeManagerProxy; |
| + |
| std::unique_ptr<base::DiscardableSharedMemory> |
| - AllocateLockedDiscardableSharedMemory(size_t size, |
| - DiscardableSharedMemoryId id); |
| + AllocateLockedDiscardableSharedMemory(size_t size, int32_t id); |
| + void DeletedDiscardableSharedMemory(int32_t id); |
| + |
| void MemoryUsageChanged(size_t new_bytes_allocated, |
| size_t new_bytes_free) const; |
| mutable base::Lock lock_; |
| + scoped_refptr<ThreadSafeManagerProxy> manager_; |
|
reveman
2016/11/11 20:17:26
why do we need a separate instance for this? Can t
Peng
2016/11/11 22:50:35
It is because I want to make manager_ a thread saf
|
| DiscardableSharedMemoryHeap heap_; |
| - Delegate* const delegate_; |
| DISALLOW_COPY_AND_ASSIGN(ClientDiscardableSharedMemoryManager); |
| }; |