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 SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
9 bool SkDiscardableMemoryChrome::lock() {
10 const base::DiscardableMemoryLockStatus status
= discardable_
->Lock();
12 case base::DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS
:
14 case base::DISCARDABLE_MEMORY_LOCK_STATUS_PURGED
:
15 discardable_
->Unlock();
23 void* SkDiscardableMemoryChrome::data() {
24 return discardable_
->Memory();
27 void SkDiscardableMemoryChrome::unlock() {
28 discardable_
->Unlock();
31 SkDiscardableMemoryChrome::SkDiscardableMemoryChrome(
32 scoped_ptr
<base::DiscardableMemory
> memory
)
33 : discardable_(memory
.Pass()) {
36 SkDiscardableMemory
* SkDiscardableMemory::Create(size_t bytes
) {
37 scoped_ptr
<base::DiscardableMemory
> discardable(
38 base::DiscardableMemory::CreateLockedMemory(bytes
));
41 return new SkDiscardableMemoryChrome(discardable
.Pass());