No longer register app window placement preference keys on
[chromium-blink-merge.git] / skia / ext / SkDiscardableMemory_chrome.cc
blob710310058f45e74ef60c57721cc70905acec3815
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();
11 switch (status) {
12 case base::DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS:
13 return true;
14 case base::DISCARDABLE_MEMORY_LOCK_STATUS_PURGED:
15 discardable_->Unlock();
16 return false;
17 default:
18 discardable_.reset();
19 return false;
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));
39 if (!discardable)
40 return NULL;
41 return new SkDiscardableMemoryChrome(discardable.Pass());