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 SkDiscardableMemory
* SkDiscardableMemory::Create(size_t bytes
) {
30 return new SkDiscardableMemoryChrome(
31 base::DiscardableMemoryAllocator::GetInstance()
32 ->AllocateLockedDiscardableMemory(bytes
));