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

Unified Diff: base/memory/discardable_memory_android.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « base/memory/discardable_memory.cc ('k') | base/memory/discardable_memory_ashmem.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_android.cc
diff --git a/base/memory/discardable_memory_android.cc b/base/memory/discardable_memory_android.cc
index 2b3558736c44d9371e021d171cfa913402cd1fcc..a36f54e7d5ddeccd2d2a9b65204c7a5b4b1dc579 100644
--- a/base/memory/discardable_memory_android.cc
+++ b/base/memory/discardable_memory_android.cc
@@ -4,57 +4,16 @@
#include "base/memory/discardable_memory.h"
-#include "base/basictypes.h"
-#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_emulated.h"
#include "base/memory/discardable_memory_shmem.h"
-#include "base/sys_info.h"
namespace base {
-namespace {
-
-const char kAshmemAllocatorName[] = "DiscardableMemoryAshmemAllocator";
-
-// For Ashmem, have the DiscardableMemoryManager trigger userspace eviction
-// when address space usage gets too high (e.g. 512 MBytes).
-const size_t kAshmemMemoryLimit = 512 * 1024 * 1024;
-
-size_t GetOptimalAshmemRegionSizeForAllocator() {
- // Note that this may do some I/O (without hitting the disk though) so it
- // should not be called on the critical path.
- return base::SysInfo::AmountOfPhysicalMemory() / 8;
-}
-
-// Holds the shared state used for allocations.
-struct SharedState {
- SharedState()
- : manager(kAshmemMemoryLimit, kAshmemMemoryLimit, TimeDelta::Max()),
- allocator(kAshmemAllocatorName,
- GetOptimalAshmemRegionSizeForAllocator()) {}
-
- internal::DiscardableMemoryManager manager;
- internal::DiscardableMemoryAshmemAllocator allocator;
-};
-LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER;
-
-} // namespace
-
-// static
-bool DiscardableMemory::ReduceMemoryUsage() {
- return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
-}
// static
void DiscardableMemory::GetSupportedTypes(
std::vector<DiscardableMemoryType>* types) {
const DiscardableMemoryType supported_types[] = {
- DISCARDABLE_MEMORY_TYPE_SHMEM,
- DISCARDABLE_MEMORY_TYPE_ASHMEM,
- DISCARDABLE_MEMORY_TYPE_EMULATED
+ DISCARDABLE_MEMORY_TYPE_SHMEM
};
types->assign(supported_types, supported_types + arraysize(supported_types));
}
@@ -63,34 +22,9 @@ void DiscardableMemory::GetSupportedTypes(
scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
DiscardableMemoryType type, size_t size) {
switch (type) {
- case DISCARDABLE_MEMORY_TYPE_ASHMEM: {
- SharedState* const shared_state = g_shared_state.Pointer();
- scoped_ptr<internal::DiscardableMemoryAshmem> memory(
- new internal::DiscardableMemoryAshmem(
- size, &shared_state->allocator, &shared_state->manager));
- if (!memory->Initialize())
- return nullptr;
-
- return memory.Pass();
- }
- case DISCARDABLE_MEMORY_TYPE_EMULATED: {
- scoped_ptr<internal::DiscardableMemoryEmulated> memory(
- new internal::DiscardableMemoryEmulated(size));
- if (!memory->Initialize())
- return nullptr;
-
- return memory.Pass();
- }
- case DISCARDABLE_MEMORY_TYPE_SHMEM: {
- scoped_ptr<internal::DiscardableMemoryShmem> memory(
- new internal::DiscardableMemoryShmem(size));
- if (!memory->Initialize())
- return nullptr;
-
- return memory.Pass();
- }
+ case DISCARDABLE_MEMORY_TYPE_SHMEM:
+ return make_scoped_ptr(new internal::DiscardableMemoryShmem(size));
case DISCARDABLE_MEMORY_TYPE_NONE:
- case DISCARDABLE_MEMORY_TYPE_MACH:
NOTREACHED();
return nullptr;
}
« no previous file with comments | « base/memory/discardable_memory.cc ('k') | base/memory/discardable_memory_ashmem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698