1 // Copyright 2013 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 "SkDiscardableMemory_chrome.h"
7 #include "base/memory/discardable_memory.h"
8 #include "base/memory/discardable_memory_allocator.h"
10 SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
12 bool SkDiscardableMemoryChrome::lock() {
13 return discardable_
->Lock();
16 void* SkDiscardableMemoryChrome::data() {
17 return discardable_
->data();
20 void SkDiscardableMemoryChrome::unlock() {
21 discardable_
->Unlock();
24 SkDiscardableMemoryChrome::SkDiscardableMemoryChrome(
25 scoped_ptr
<base::DiscardableMemory
> memory
)
26 : discardable_(memory
.Pass()) {
29 base::trace_event::MemoryAllocatorDump
*
30 SkDiscardableMemoryChrome::CreateMemoryAllocatorDump(
32 base::trace_event::ProcessMemoryDump
* pmd
) const {
33 return discardable_
->CreateMemoryAllocatorDump(name
, pmd
);
36 SkDiscardableMemory
* SkDiscardableMemory::Create(size_t bytes
) {
37 return new SkDiscardableMemoryChrome(
38 base::DiscardableMemoryAllocator::GetInstance()
39 ->AllocateLockedDiscardableMemory(bytes
));