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 void DiscardableMemory::ReleaseFreeMemory() {
15 internal::DiscardableMemoryShmem::ReleaseFreeMemory();
19 bool DiscardableMemory::ReduceMemoryUsage() {
20 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
24 void DiscardableMemory::GetSupportedTypes(
25 std::vector
<DiscardableMemoryType
>* types
) {
26 const DiscardableMemoryType supported_types
[] = {
27 DISCARDABLE_MEMORY_TYPE_EMULATED
,
28 DISCARDABLE_MEMORY_TYPE_SHMEM
30 types
->assign(supported_types
, supported_types
+ arraysize(supported_types
));
34 scoped_ptr
<DiscardableMemory
> DiscardableMemory::CreateLockedMemoryWithType(
35 DiscardableMemoryType type
, size_t size
) {
37 case DISCARDABLE_MEMORY_TYPE_EMULATED
: {
38 scoped_ptr
<internal::DiscardableMemoryEmulated
> memory(
39 new internal::DiscardableMemoryEmulated(size
));
40 if (!memory
->Initialize())
45 case DISCARDABLE_MEMORY_TYPE_SHMEM
: {
46 scoped_ptr
<internal::DiscardableMemoryShmem
> memory(
47 new internal::DiscardableMemoryShmem(size
));
48 if (!memory
->Initialize())
53 case DISCARDABLE_MEMORY_TYPE_NONE
:
54 case DISCARDABLE_MEMORY_TYPE_ASHMEM
:
55 case DISCARDABLE_MEMORY_TYPE_MACH
:
65 void DiscardableMemory::PurgeForTesting() {
66 internal::DiscardableMemoryEmulated::PurgeForTesting();
67 internal::DiscardableMemoryShmem::PurgeForTesting();