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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/shared_memory_allocator_impl.h"
6
7 #include "content/public/browser/browser_thread.h"
8 #include "mojo/public/cpp/bindings/strong_binding.h"
9 #include "mojo/public/cpp/system/platform_handle.h"
10
11 namespace content {
12
13 void SharedMemoryAllocatorImpl::Create(
14 mojom::SharedMemoryAllocatorRequest request) {
15 mojo::MakeStrongBinding(
16 base::WrapUnique(new SharedMemoryAllocatorImpl()),
17 std::move(request));
18 }
19
20 SharedMemoryAllocatorImpl::SharedMemoryAllocatorImpl()
21 : bitmap_manager_client_(HostSharedBitmapManager::current()) {
22 DCHECK_CURRENTLY_ON(BrowserThread::IO);
23 }
24
25 SharedMemoryAllocatorImpl::~SharedMemoryAllocatorImpl() {
26 DCHECK(thread_checker_.CalledOnValidThread());
27 }
28
29 void SharedMemoryAllocatorImpl::AllocatedSharedBitmap(
30 mojo::ScopedSharedBufferHandle buffer,
31 const gpu::Mailbox& id) {
32 base::SharedMemoryHandle memory_handle;
33 size_t size;
34 MojoResult result = mojo::UnwrapSharedMemoryHandle(
35 std::move(buffer), &memory_handle, &size, NULL);
36 DCHECK_EQ(result, MOJO_RESULT_OK);
37 bitmap_manager_client_.ChildAllocatedSharedBitmap(size, memory_handle, id);
38 }
39
40 void SharedMemoryAllocatorImpl::DeletedSharedBitmap(const gpu::Mailbox& id) {
41 bitmap_manager_client_.ChildDeletedSharedBitmap(id);
42 }
43
44 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698