| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/discardable_memory.h" | 5 #include "base/memory/discardable_memory.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 const struct TypeNamePair { | 13 const struct TypeNamePair { |
| 14 DiscardableMemoryType type; | 14 DiscardableMemoryType type; |
| 15 const char* name; | 15 const char* name; |
| 16 } kTypeNamePairs[] = { | 16 } kTypeNamePairs[] = { |
| 17 { DISCARDABLE_MEMORY_TYPE_ASHMEM, "ashmem" }, | |
| 18 { DISCARDABLE_MEMORY_TYPE_MACH, "mach" }, | |
| 19 { DISCARDABLE_MEMORY_TYPE_EMULATED, "emulated" }, | |
| 20 { DISCARDABLE_MEMORY_TYPE_SHMEM, "shmem" } | 17 { DISCARDABLE_MEMORY_TYPE_SHMEM, "shmem" } |
| 21 }; | 18 }; |
| 22 | 19 |
| 23 DiscardableMemoryType g_preferred_type = DISCARDABLE_MEMORY_TYPE_NONE; | 20 DiscardableMemoryType g_preferred_type = DISCARDABLE_MEMORY_TYPE_NONE; |
| 24 | 21 |
| 25 struct DefaultPreferredType { | 22 struct DefaultPreferredType { |
| 26 DefaultPreferredType() : value(DISCARDABLE_MEMORY_TYPE_NONE) { | 23 DefaultPreferredType() : value(DISCARDABLE_MEMORY_TYPE_NONE) { |
| 27 std::vector<DiscardableMemoryType> supported_types; | 24 std::vector<DiscardableMemoryType> supported_types; |
| 28 DiscardableMemory::GetSupportedTypes(&supported_types); | 25 DiscardableMemory::GetSupportedTypes(&supported_types); |
| 29 DCHECK(!supported_types.empty()); | 26 DCHECK(!supported_types.empty()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return g_preferred_type; | 74 return g_preferred_type; |
| 78 } | 75 } |
| 79 | 76 |
| 80 // static | 77 // static |
| 81 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( | 78 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( |
| 82 size_t size) { | 79 size_t size) { |
| 83 return CreateLockedMemoryWithType(GetPreferredType(), size); | 80 return CreateLockedMemoryWithType(GetPreferredType(), size); |
| 84 } | 81 } |
| 85 | 82 |
| 86 } // namespace base | 83 } // namespace base |
| OLD | NEW |