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 "base/memory/discardable_memory_shmem.h"
7 #include "base/lazy_instance.h"
8 #include "base/memory/discardable_memory_shmem_allocator.h"
13 DiscardableMemoryShmem::DiscardableMemoryShmem(size_t bytes
)
14 : chunk_(DiscardableMemoryShmemAllocator::GetInstance()
15 ->AllocateLockedDiscardableMemory(bytes
)),
20 DiscardableMemoryShmem::~DiscardableMemoryShmem() {
25 bool DiscardableMemoryShmem::Lock() {
29 if (!chunk_
->Lock()) {
38 void DiscardableMemoryShmem::Unlock() {
44 void* DiscardableMemoryShmem::Memory() const {
46 return chunk_
->Memory();
49 } // namespace internal