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

Unified Diff: content/browser/renderer_host/shared_memory_allocator_impl.cc

Issue 2488913003: Replacing allocate bitmap IPC messages with a new Mojo interface. (Closed)
Patch Set: Clean-up 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: content/browser/renderer_host/shared_memory_allocator_impl.cc
diff --git a/content/browser/renderer_host/shared_memory_allocator_impl.cc b/content/browser/renderer_host/shared_memory_allocator_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3636bc2dce80b40a46d3e1518c902c0ce24af68d
--- /dev/null
+++ b/content/browser/renderer_host/shared_memory_allocator_impl.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/shared_memory_allocator_impl.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "mojo/public/cpp/system/platform_handle.h"
+
+namespace content {
+
+void SharedMemoryAllocatorImpl::Create(
+ mojom::SharedMemoryAllocatorRequest request) {
+ mojo::MakeStrongBinding(
+ base::WrapUnique(new SharedMemoryAllocatorImpl()),
+ std::move(request));
+}
+
+SharedMemoryAllocatorImpl::SharedMemoryAllocatorImpl()
+ : bitmap_manager_client_(HostSharedBitmapManager::current()) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+SharedMemoryAllocatorImpl::~SharedMemoryAllocatorImpl() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+void SharedMemoryAllocatorImpl::AllocatedSharedBitmap(
+ mojo::ScopedSharedBufferHandle buffer,
+ const gpu::Mailbox& id) {
+ base::SharedMemoryHandle memory_handle;
+ size_t size;
+ MojoResult result = mojo::UnwrapSharedMemoryHandle(
+ std::move(buffer), &memory_handle, &size, NULL);
+ DCHECK_EQ(result, MOJO_RESULT_OK);
+ bitmap_manager_client_.ChildAllocatedSharedBitmap(size, memory_handle, id);
+}
+
+void SharedMemoryAllocatorImpl::DeletedSharedBitmap(const gpu::Mailbox& id) {
+ bitmap_manager_client_.ChildDeletedSharedBitmap(id);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698