diff options
Diffstat (limited to 'chromium/components/discardable_memory/client')
2 files changed, 14 insertions, 18 deletions
diff --git a/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.cc b/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.cc index 337e1eb9e13..2cd5e0e5b1f 100644 --- a/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.cc +++ b/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.cc @@ -25,7 +25,6 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/trace_event.h" #include "components/crash/core/common/crash_key.h" -#include "mojo/public/cpp/system/platform_handle.h" namespace discardable_memory { namespace { @@ -168,7 +167,7 @@ ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( // Search free lists for suitable span. std::unique_ptr<DiscardableSharedMemoryHeap::Span> free_span = heap_->SearchFreeLists(pages, slack); - if (!free_span.get()) + if (!free_span) break; // Attempt to lock |free_span|. Delete span and search free lists again @@ -357,7 +356,7 @@ ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( "ClientDiscardableSharedMemoryManager::" "AllocateLockedDiscardableSharedMemory", "size", size, "id", id); - base::SharedMemoryHandle handle; + base::UnsafeSharedMemoryRegion region; base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); base::ScopedClosureRunner event_signal_runner( @@ -365,11 +364,12 @@ ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( io_task_runner_->PostTask( FROM_HERE, base::BindOnce(&ClientDiscardableSharedMemoryManager::AllocateOnIO, - base::Unretained(this), size, id, &handle, + base::Unretained(this), size, id, ®ion, std::move(event_signal_runner))); // Waiting until IPC has finished on the IO thread. event.Wait(); - auto memory = std::make_unique<base::DiscardableSharedMemory>(handle); + auto memory = + std::make_unique<base::DiscardableSharedMemory>(std::move(region)); if (!memory->Map(size)) base::TerminateBecauseOutOfMemory(size); return memory; @@ -378,25 +378,21 @@ ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( void ClientDiscardableSharedMemoryManager::AllocateOnIO( size_t size, int32_t id, - base::SharedMemoryHandle* handle, + base::UnsafeSharedMemoryRegion* region, base::ScopedClosureRunner closure_runner) { (*manager_mojo_) ->AllocateLockedDiscardableSharedMemory( static_cast<uint32_t>(size), id, base::BindOnce( &ClientDiscardableSharedMemoryManager::AllocateCompletedOnIO, - base::Unretained(this), handle, std::move(closure_runner))); + base::Unretained(this), region, std::move(closure_runner))); } void ClientDiscardableSharedMemoryManager::AllocateCompletedOnIO( - base::SharedMemoryHandle* handle, + base::UnsafeSharedMemoryRegion* region, base::ScopedClosureRunner closure_runner, - mojo::ScopedSharedBufferHandle mojo_handle) { - if (!mojo_handle.is_valid()) - return; - auto result = mojo::UnwrapSharedMemoryHandle(std::move(mojo_handle), handle, - nullptr, nullptr); - DCHECK_EQ(result, MOJO_RESULT_OK); + base::UnsafeSharedMemoryRegion ret_region) { + *region = std::move(ret_region); } void ClientDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory( diff --git a/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.h b/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.h index c6b375bdaa2..6e650e09cfe 100644 --- a/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.h +++ b/chromium/components/discardable_memory/client/client_discardable_shared_memory_manager.h @@ -11,7 +11,7 @@ #include "base/macros.h" #include "base/memory/discardable_memory_allocator.h" #include "base/memory/ref_counted.h" -#include "base/memory/shared_memory_handle.h" +#include "base/memory/unsafe_shared_memory_region.h" #include "base/synchronization/lock.h" #include "base/trace_event/memory_dump_provider.h" #include "components/discardable_memory/common/discardable_memory_export.h" @@ -67,11 +67,11 @@ class DISCARDABLE_MEMORY_EXPORT ClientDiscardableSharedMemoryManager AllocateLockedDiscardableSharedMemory(size_t size, int32_t id); void AllocateOnIO(size_t size, int32_t id, - base::SharedMemoryHandle* handle, + base::UnsafeSharedMemoryRegion* region, base::ScopedClosureRunner closure_runner); - void AllocateCompletedOnIO(base::SharedMemoryHandle* handle, + void AllocateCompletedOnIO(base::UnsafeSharedMemoryRegion* region, base::ScopedClosureRunner closure_runner, - mojo::ScopedSharedBufferHandle mojo_handle); + base::UnsafeSharedMemoryRegion ret_region); void DeletedDiscardableSharedMemory(int32_t id); void MemoryUsageChanged(size_t new_bytes_allocated, |