cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / child / child_discardable_shared_memory_manager.cc
blob606ca6ceb06074b02e02c421ee613bcb26a3d2b6
1 // Copyright 2014 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.
5 #include "content/child/child_discardable_shared_memory_manager.h"
7 #include "base/memory/discardable_shared_memory.h"
8 #include "content/child/child_thread.h"
9 #include "content/common/child_process_messages.h"
11 namespace content {
13 ChildDiscardableSharedMemoryManager::ChildDiscardableSharedMemoryManager(
14 ThreadSafeSender* sender)
15 : sender_(sender) {
18 ChildDiscardableSharedMemoryManager::~ChildDiscardableSharedMemoryManager() {
21 scoped_ptr<base::DiscardableSharedMemory>
22 ChildDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory(
23 size_t size) {
24 TRACE_EVENT1("renderer",
25 "ChildDiscardableSharedMemoryManager::"
26 "AllocateLockedDiscardableSharedMemory",
27 "size",
28 size);
30 base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle();
31 sender_->Send(
32 new ChildProcessHostMsg_SyncAllocateLockedDiscardableSharedMemory(
33 size, &handle));
34 scoped_ptr<base::DiscardableSharedMemory> memory(
35 new base::DiscardableSharedMemory(handle));
36 CHECK(memory->Map(size));
37 return memory.Pass();
40 } // namespace content