ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / base / memory / discardable_memory_mac.cc
blob2881f5e120a4fd19614c5aedc95f56bdf4661ab5
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 bool DiscardableMemory::ReduceMemoryUsage() {
18 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
21 // static
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));
32 // static
33 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
34 DiscardableMemoryType type, size_t size) {
35 switch (type) {
36 case DISCARDABLE_MEMORY_TYPE_MACH: {
37 scoped_ptr<internal::DiscardableMemoryMach> memory(
38 new internal::DiscardableMemoryMach(size));
39 if (!memory->Initialize())
40 return nullptr;
42 return memory.Pass();
44 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
45 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
46 new internal::DiscardableMemoryEmulated(size));
47 if (!memory->Initialize())
48 return nullptr;
50 return memory.Pass();
52 case DISCARDABLE_MEMORY_TYPE_SHMEM: {
53 scoped_ptr<internal::DiscardableMemoryShmem> memory(
54 new internal::DiscardableMemoryShmem(size));
55 if (!memory->Initialize())
56 return nullptr;
58 return memory.Pass();
60 case DISCARDABLE_MEMORY_TYPE_NONE:
61 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
62 NOTREACHED();
63 return nullptr;
66 NOTREACHED();
67 return nullptr;
70 } // namespace base