Use ExtensionRegistry::enabled_extensions instead of deprecated ExtensionService...
[chromium-blink-merge.git] / content / child / web_discardable_memory_impl.cc
blob684d440427ec988cc498b37e2e36242ad29c9e26
1 // Copyright 2014 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 "content/child/web_discardable_memory_impl.h"
7 namespace content {
9 WebDiscardableMemoryImpl::~WebDiscardableMemoryImpl() {}
11 // static
12 scoped_ptr<WebDiscardableMemoryImpl>
13 WebDiscardableMemoryImpl::CreateLockedMemory(size_t size) {
14 scoped_ptr<base::DiscardableMemory> memory(
15 base::DiscardableMemory::CreateLockedMemory(size));
16 if (!memory)
17 return scoped_ptr<WebDiscardableMemoryImpl>();
18 return make_scoped_ptr(new WebDiscardableMemoryImpl(memory.Pass()));
21 bool WebDiscardableMemoryImpl::lock() {
22 base::DiscardableMemoryLockStatus status = discardable_->Lock();
23 switch (status) {
24 case base::DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS:
25 return true;
26 case base::DISCARDABLE_MEMORY_LOCK_STATUS_PURGED:
27 discardable_->Unlock();
28 return false;
29 default:
30 discardable_.reset();
31 return false;
35 void WebDiscardableMemoryImpl::unlock() {
36 discardable_->Unlock();
39 void* WebDiscardableMemoryImpl::data() {
40 return discardable_->Memory();
43 WebDiscardableMemoryImpl::WebDiscardableMemoryImpl(
44 scoped_ptr<base::DiscardableMemory> memory)
45 : discardable_(memory.Pass()) {
48 } // namespace content