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 "base/memory/discardable_memory.h"
7 #include "base/logging.h"
8 #include "base/memory/discardable_memory_emulated.h"
9 #include "base/memory/discardable_memory_shmem.h"
14 bool DiscardableMemory::ReduceMemoryUsage() {
15 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
19 void DiscardableMemory::GetSupportedTypes(
20 std::vector
<DiscardableMemoryType
>* types
) {
21 const DiscardableMemoryType supported_types
[] = {
22 DISCARDABLE_MEMORY_TYPE_EMULATED
,
23 DISCARDABLE_MEMORY_TYPE_SHMEM
25 types
->assign(supported_types
, supported_types
+ arraysize(supported_types
));
29 scoped_ptr
<DiscardableMemory
> DiscardableMemory::CreateLockedMemoryWithType(
30 DiscardableMemoryType type
, size_t size
) {
32 case DISCARDABLE_MEMORY_TYPE_EMULATED
: {
33 scoped_ptr
<internal::DiscardableMemoryEmulated
> memory(
34 new internal::DiscardableMemoryEmulated(size
));
35 if (!memory
->Initialize())
40 case DISCARDABLE_MEMORY_TYPE_SHMEM
: {
41 scoped_ptr
<internal::DiscardableMemoryShmem
> memory(
42 new internal::DiscardableMemoryShmem(size
));
43 if (!memory
->Initialize())
48 case DISCARDABLE_MEMORY_TYPE_NONE
:
49 case DISCARDABLE_MEMORY_TYPE_ASHMEM
:
50 case DISCARDABLE_MEMORY_TYPE_MACH
: