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

Unified Diff: components/discardable_memory/service/discardable_shared_memory_manager.h

Issue 2485623002: discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/service/discardable_shared_memory_manager.h
diff --git a/components/discardable_memory/service/discardable_shared_memory_manager.h b/components/discardable_memory/service/discardable_shared_memory_manager.h
index 7ccadf18a44b3b1c68a540e9f4647b0d3778bd44..a581c309c9f2512c35c1f7c3541d74e3200ce178 100644
--- a/components/discardable_memory/service/discardable_shared_memory_manager.h
+++ b/components/discardable_memory/service/discardable_shared_memory_manager.h
@@ -27,7 +27,7 @@
#include "base/threading/thread_task_runner_handle.h"
#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_id.h"
+#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
namespace discardable_memory {
@@ -47,6 +47,9 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager
// Returns a singleton instance.
static DiscardableSharedMemoryManager* current();
+ // Bind the current manager to a mojo interface request.
+ static void Bind(mojom::DiscardableSharedMemoryManagerRequest request);
+
// Overridden from base::DiscardableMemoryAllocator:
std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory(
size_t size) override;
@@ -55,20 +58,17 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
- // TODO(penghuang): Get ride of the |process_handle| when we switch to mojo.
// This allocates a discardable memory segment for |process_handle|.
// A valid shared memory handle is returned on success.
void AllocateLockedDiscardableSharedMemoryForClient(
- base::ProcessHandle process_handle,
int client_id,
size_t size,
- DiscardableSharedMemoryId id,
+ int32_t id,
base::SharedMemoryHandle* shared_memory_handle);
// Call this to notify the manager that client process associated with
// |client_id| has deleted discardable memory segment with |id|.
- void ClientDeletedDiscardableSharedMemory(DiscardableSharedMemoryId id,
- int client_id);
+ void ClientDeletedDiscardableSharedMemory(int32_t id, int client_id);
// Call this to notify the manager that client associated with |client_id|
// has been removed. The manager will use this to release memory segments
@@ -111,15 +111,12 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager
// base::MemoryCoordinatorClient implementation:
void OnMemoryStateChange(base::MemoryState state) override;
- // TODO(penghuang): Get ride of the |process_handle| when we switch to mojo.
void AllocateLockedDiscardableSharedMemory(
- base::ProcessHandle process_handle,
int client_id,
size_t size,
- DiscardableSharedMemoryId id,
+ int32_t id,
base::SharedMemoryHandle* shared_memory_handle);
- void DeletedDiscardableSharedMemory(DiscardableSharedMemoryId id,
- int client_id);
+ void DeletedDiscardableSharedMemory(int32_t id, int client_id);
void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
void ReduceMemoryUsageUntilWithinMemoryLimit();
@@ -131,9 +128,10 @@ class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryManager
virtual base::Time Now() const;
virtual void ScheduleEnforceMemoryPolicy();
+ int32_t last_client_id_;
+
base::Lock lock_;
- typedef base::hash_map<DiscardableSharedMemoryId,
- scoped_refptr<MemorySegment>>
+ typedef base::hash_map<int32_t, scoped_refptr<MemorySegment>>
MemorySegmentMap;
typedef base::hash_map<int, MemorySegmentMap> ClientMap;
ClientMap clients_;

Powered by Google App Engine
This is Rietveld 408576698