Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1463)

Unified Diff: components/discardable_memory/client/client_discardable_shared_memory_manager.h

Issue 2485623002: discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Fix bot issues Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..45c795bf1cd8a3ad9c6e1834f52701194f3317ec 100644
--- a/components/discardable_memory/client/client_discardable_shared_memory_manager.h
+++ b/components/discardable_memory/client/client_discardable_shared_memory_manager.h
@@ -7,6 +7,7 @@
#include <stddef.h>
+#include "base/callback_helpers.h"
#include "base/macros.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/memory/ref_counted.h"
@@ -15,7 +16,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_shared_memory_manager.mojom.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
namespace discardable_memory {
@@ -25,20 +30,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::DiscardableSharedMemoryManagerPtr manager,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
~ClientDiscardableSharedMemoryManager() override;
// Overridden from base::DiscardableMemoryAllocator:
@@ -70,14 +64,27 @@ class DISCARDABLE_MEMORY_EXPORT ClientDiscardableSharedMemoryManager
private:
std::unique_ptr<base::DiscardableSharedMemory>
- AllocateLockedDiscardableSharedMemory(size_t size,
- DiscardableSharedMemoryId id);
+ AllocateLockedDiscardableSharedMemory(size_t size, int32_t id);
+ void AllocateOnIO(size_t size,
+ int32_t id,
+ std::unique_ptr<base::DiscardableSharedMemory>* memory,
+ base::ScopedClosureRunner closure_runner);
+ void AllocateCompletedOnIO(
+ std::unique_ptr<base::DiscardableSharedMemory>* memory,
+ base::ScopedClosureRunner closure_runner,
+ mojo::ScopedSharedBufferHandle mojo_handle);
+
+ void DeletedDiscardableSharedMemory(int32_t id);
void MemoryUsageChanged(size_t new_bytes_allocated,
size_t new_bytes_free) const;
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+ // TODO(penghuang): Switch to ThreadSafeInterfacePtr when it starts supporting
+ // sync method call.
+ std::unique_ptr<mojom::DiscardableSharedMemoryManagerPtr> manager_mojo_;
+
mutable base::Lock lock_;
- DiscardableSharedMemoryHeap heap_;
- Delegate* const delegate_;
+ std::unique_ptr<DiscardableSharedMemoryHeap> heap_;
DISALLOW_COPY_AND_ASSIGN(ClientDiscardableSharedMemoryManager);
};

Powered by Google App Engine
This is Rietveld 408576698