Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: skia/ext/SkDiscardableMemory_chrome.cc

Issue 23206002: skia: Added chrome implementation of SkDiscardableMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Capitalized name of static factory method. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "SkDiscardableMemory_chrome.h"
6
7 SkDiscardableMemoryChrome::SkDiscardableMemoryChrome()
8 : discardable_(new base::DiscardableMemory()) {
9 }
10
11 bool SkDiscardableMemoryChrome::lock() {
12 base::LockDiscardableMemoryStatus status = discardable_->Lock();
13 switch (status) {
14 case base::DISCARDABLE_MEMORY_SUCCESS:
15 return true;
16 case base::DISCARDABLE_MEMORY_PURGED:
17 discardable_->Unlock();
18 return false;
Ian Vollick 2013/08/16 11:36:31 Do you really want to do this in response to being
19 default:
20 discardable_.reset();
21 return false;
22 }
23 }
24
25 void* SkDiscardableMemoryChrome::data() {
26 return discardable_->Memory();
27 }
28
29 void SkDiscardableMemoryChrome::unlock() {
30 discardable_->Unlock();
31 }
32
33 bool SkDiscardableMemoryChrome::InitializeAndLock(size_t bytes) {
34 return discardable_->InitializeAndLock(bytes);
35 }
36
37 SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
38 if (!base::DiscardableMemory::Supported()) {
39 return NULL;
40 }
41 scoped_ptr<SkDiscardableMemoryChrome> discardable(
42 new SkDiscardableMemoryChrome());
43 if (discardable->InitializeAndLock(bytes))
44 return discardable.release();
45 return NULL;
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698