blob: d4c3ee280a86a68439761e10e6ae428a2dfd84d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/web_discardable_memory_impl.h"
namespace webkit_glue {
WebDiscardableMemoryImpl::WebDiscardableMemoryImpl()
: discardable_(new base::DiscardableMemory()) {
}
WebDiscardableMemoryImpl::~WebDiscardableMemoryImpl() {}
bool WebDiscardableMemoryImpl::InitializeAndLock(size_t size) {
return discardable_->InitializeAndLock(size);
}
bool WebDiscardableMemoryImpl::lock() {
base::LockDiscardableMemoryStatus status = discardable_->Lock();
switch (status) {
case base::DISCARDABLE_MEMORY_SUCCESS:
return true;
case base::DISCARDABLE_MEMORY_PURGED:
discardable_->Unlock();
return false;
default:
discardable_.reset();
return false;
}
}
void* WebDiscardableMemoryImpl::data() {
return discardable_->Memory();
}
void WebDiscardableMemoryImpl::unlock() {
discardable_->Unlock();
}
} // namespace webkit_glue
|