This source file includes following definitions.
- lock
- data
- unlock
- Create
#include "SkDiscardableMemory_chrome.h"
SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
bool SkDiscardableMemoryChrome::lock() {
const base::DiscardableMemoryLockStatus status = discardable_->Lock();
switch (status) {
case base::DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS:
return true;
case base::DISCARDABLE_MEMORY_LOCK_STATUS_PURGED:
discardable_->Unlock();
return false;
default:
discardable_.reset();
return false;
}
}
void* SkDiscardableMemoryChrome::data() {
return discardable_->Memory();
}
void SkDiscardableMemoryChrome::unlock() {
discardable_->Unlock();
}
SkDiscardableMemoryChrome::SkDiscardableMemoryChrome(
scoped_ptr<base::DiscardableMemory> memory)
: discardable_(memory.Pass()) {
}
SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
scoped_ptr<base::DiscardableMemory> discardable(
base::DiscardableMemory::CreateLockedMemory(bytes));
if (!discardable)
return NULL;
return new SkDiscardableMemoryChrome(discardable.Pass());
}