Infer appropriate GNU_STACK alignment for a shared library.
[chromium-blink-merge.git] / base / memory / discardable_memory_mac.cc
blob18cf80ac4aa80cf2fbae99d755b05fb7127e8ebf
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"
14 namespace base {
16 // static
17 void DiscardableMemory::ReleaseFreeMemory() {
18 internal::DiscardableMemoryShmem::ReleaseFreeMemory();
21 // static
22 bool DiscardableMemory::ReduceMemoryUsage() {
23 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
26 // static
27 void DiscardableMemory::GetSupportedTypes(
28 std::vector<DiscardableMemoryType>* types) {
29 const DiscardableMemoryType supported_types[] = {
30 DISCARDABLE_MEMORY_TYPE_MACH,
31 DISCARDABLE_MEMORY_TYPE_EMULATED,
32 DISCARDABLE_MEMORY_TYPE_SHMEM
34 types->assign(supported_types, supported_types + arraysize(supported_types));
37 // static
38 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
39 DiscardableMemoryType type, size_t size) {
40 switch (type) {
41 case DISCARDABLE_MEMORY_TYPE_MACH: {
42 scoped_ptr<internal::DiscardableMemoryMach> memory(
43 new internal::DiscardableMemoryMach(size));
44 if (!memory->Initialize())
45 return nullptr;
47 return memory.Pass();
49 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
50 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
51 new internal::DiscardableMemoryEmulated(size));
52 if (!memory->Initialize())
53 return nullptr;
55 return memory.Pass();
57 case DISCARDABLE_MEMORY_TYPE_SHMEM: {
58 scoped_ptr<internal::DiscardableMemoryShmem> memory(
59 new internal::DiscardableMemoryShmem(size));
60 if (!memory->Initialize())
61 return nullptr;
63 return memory.Pass();
65 case DISCARDABLE_MEMORY_TYPE_NONE:
66 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
67 NOTREACHED();
68 return nullptr;
71 NOTREACHED();
72 return nullptr;
75 // static
76 void DiscardableMemory::PurgeForTesting() {
77 internal::DiscardableMemoryMach::PurgeForTesting();
78 internal::DiscardableMemoryEmulated::PurgeForTesting();
79 internal::DiscardableMemoryShmem::PurgeForTesting();
82 } // namespace base