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.
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_mach.h"
10 #include "base/memory/discardable_memory_manager.h"
11 #include "base/memory/discardable_memory_shmem.h"
12 #include "base/memory/scoped_ptr.h"
17 bool DiscardableMemory::ReduceMemoryUsage() {
18 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
22 void DiscardableMemory::GetSupportedTypes(
23 std::vector
<DiscardableMemoryType
>* types
) {
24 const DiscardableMemoryType supported_types
[] = {
25 DISCARDABLE_MEMORY_TYPE_SHMEM
,
26 DISCARDABLE_MEMORY_TYPE_MACH
,
27 DISCARDABLE_MEMORY_TYPE_EMULATED
29 types
->assign(supported_types
, supported_types
+ arraysize(supported_types
));
33 scoped_ptr
<DiscardableMemory
> DiscardableMemory::CreateLockedMemoryWithType(
34 DiscardableMemoryType type
, size_t size
) {
36 case DISCARDABLE_MEMORY_TYPE_MACH
: {
37 scoped_ptr
<internal::DiscardableMemoryMach
> memory(
38 new internal::DiscardableMemoryMach(size
));
39 if (!memory
->Initialize())
44 case DISCARDABLE_MEMORY_TYPE_EMULATED
: {
45 scoped_ptr
<internal::DiscardableMemoryEmulated
> memory(
46 new internal::DiscardableMemoryEmulated(size
));
47 if (!memory
->Initialize())
52 case DISCARDABLE_MEMORY_TYPE_SHMEM
: {
53 scoped_ptr
<internal::DiscardableMemoryShmem
> memory(
54 new internal::DiscardableMemoryShmem(size
));
55 if (!memory
->Initialize())
60 case DISCARDABLE_MEMORY_TYPE_NONE
:
61 case DISCARDABLE_MEMORY_TYPE_ASHMEM
: