Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: trunk/src/base/memory/discardable_memory_android.cc

Issue 257383004: Revert 267170 "Use DiscardableMemoryManager on Android." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/base/memory/discardable_memory_android.cc
===================================================================
--- trunk/src/base/memory/discardable_memory_android.cc (revision 267174)
+++ trunk/src/base/memory/discardable_memory_android.cc (working copy)
@@ -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

Powered by Google App Engine
This is Rietveld 408576698