| Index: base/memory/discardable_memory_android.cc
|
| diff --git a/base/memory/discardable_memory_android.cc b/base/memory/discardable_memory_android.cc
|
| index 904390662062e405fc8eae710e0cb4441c175a69..fa89c189db7be5170ecf30ea3a2a882c24fc87db 100644
|
| --- a/base/memory/discardable_memory_android.cc
|
| +++ b/base/memory/discardable_memory_android.cc
|
| @@ -9,30 +9,22 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| -#include "base/memory/discardable_memory_ashmem.h"
|
| -#include "base/memory/discardable_memory_ashmem_allocator.h"
|
| +#include "base/memory/discardable_memory_allocator_android.h"
|
| #include "base/memory/discardable_memory_emulated.h"
|
| #include "base/memory/discardable_memory_malloc.h"
|
|
|
| namespace base {
|
| namespace {
|
|
|
| -const char kAshmemAllocatorName[] = "DiscardableMemoryAshmemAllocator";
|
| +const char kAshmemAllocatorName[] = "DiscardableMemoryAllocator";
|
|
|
| -// When ashmem is used, have the DiscardableMemoryManager trigger userspace
|
| -// eviction when address space usage gets too high (e.g. 512 MBytes).
|
| -const size_t kAshmemMaxAddressSpaceUsage = 512 * 1024 * 1024;
|
| -
|
| -// Holds the state used for ashmem allocations.
|
| -struct AshmemGlobalContext {
|
| - AshmemGlobalContext()
|
| +struct DiscardableMemoryAllocatorWrapper {
|
| + DiscardableMemoryAllocatorWrapper()
|
| : allocator(kAshmemAllocatorName,
|
| GetOptimalAshmemRegionSizeForAllocator()) {
|
| - manager.SetMemoryLimit(kAshmemMaxAddressSpaceUsage);
|
| }
|
|
|
| - internal::DiscardableMemoryAshmemAllocator allocator;
|
| - internal::DiscardableMemoryManager manager;
|
| + internal::DiscardableMemoryAllocator allocator;
|
|
|
| private:
|
| // Returns 64 MBytes for a 512 MBytes device, 128 MBytes for 1024 MBytes...
|
| @@ -43,7 +35,8 @@
|
| }
|
| };
|
|
|
| -LazyInstance<AshmemGlobalContext>::Leaky g_context = LAZY_INSTANCE_INITIALIZER;
|
| +LazyInstance<DiscardableMemoryAllocatorWrapper>::Leaky g_context =
|
| + LAZY_INSTANCE_INITIALIZER;
|
|
|
| } // namespace
|
|
|
| @@ -61,7 +54,7 @@
|
| void DiscardableMemory::GetSupportedTypes(
|
| std::vector<DiscardableMemoryType>* types) {
|
| const DiscardableMemoryType supported_types[] = {
|
| - DISCARDABLE_MEMORY_TYPE_ASHMEM,
|
| + DISCARDABLE_MEMORY_TYPE_ANDROID,
|
| DISCARDABLE_MEMORY_TYPE_EMULATED,
|
| DISCARDABLE_MEMORY_TYPE_MALLOC
|
| };
|
| @@ -75,15 +68,8 @@
|
| case DISCARDABLE_MEMORY_TYPE_NONE:
|
| case DISCARDABLE_MEMORY_TYPE_MAC:
|
| return scoped_ptr<DiscardableMemory>();
|
| - case DISCARDABLE_MEMORY_TYPE_ASHMEM: {
|
| - AshmemGlobalContext* const global_context = g_context.Pointer();
|
| - scoped_ptr<internal::DiscardableMemoryAshmem> memory(
|
| - new internal::DiscardableMemoryAshmem(
|
| - size, &global_context->allocator, &global_context->manager));
|
| - if (!memory->Initialize())
|
| - return scoped_ptr<DiscardableMemory>();
|
| -
|
| - return memory.PassAs<DiscardableMemory>();
|
| + case DISCARDABLE_MEMORY_TYPE_ANDROID: {
|
| + return g_context.Pointer()->allocator.Allocate(size);
|
| }
|
| case DISCARDABLE_MEMORY_TYPE_EMULATED: {
|
| scoped_ptr<internal::DiscardableMemoryEmulated> memory(
|
| @@ -108,9 +94,13 @@
|
| }
|
|
|
| // static
|
| +bool DiscardableMemory::PurgeForTestingSupported() {
|
| + return false;
|
| +}
|
| +
|
| +// static
|
| void DiscardableMemory::PurgeForTesting() {
|
| - g_context.Pointer()->manager.PurgeAll();
|
| - internal::DiscardableMemoryEmulated::PurgeForTesting();
|
| + NOTIMPLEMENTED();
|
| }
|
|
|
| } // namespace base
|
|
|