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

Unified Diff: base/memory/discardable_memory_android.cc

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 0c9f3fc61d9f9a9f2f0d5200d5fd58906ae3c362..de7112457dea7a17ce0d6483af7dc931168f1261 100644
--- a/base/memory/discardable_memory_android.cc
+++ b/base/memory/discardable_memory_android.cc
@@ -11,6 +11,7 @@
#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 {
@@ -43,6 +44,11 @@ LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER;
} // namespace
// static
+void DiscardableMemory::ReleaseFreeMemory() {
+ internal::DiscardableMemoryShmem::ReleaseFreeMemory();
+}
+
+// static
bool DiscardableMemory::ReduceMemoryUsage() {
return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
}
@@ -52,7 +58,8 @@ void DiscardableMemory::GetSupportedTypes(
std::vector<DiscardableMemoryType>* types) {
const DiscardableMemoryType supported_types[] = {
DISCARDABLE_MEMORY_TYPE_ASHMEM,
- DISCARDABLE_MEMORY_TYPE_EMULATED
+ DISCARDABLE_MEMORY_TYPE_EMULATED,
+ DISCARDABLE_MEMORY_TYPE_SHMEM
};
types->assign(supported_types, supported_types + arraysize(supported_types));
}
@@ -79,6 +86,14 @@ scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
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_NONE:
case DISCARDABLE_MEMORY_TYPE_MACH:
NOTREACHED();
@@ -93,6 +108,7 @@ scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
void DiscardableMemory::PurgeForTesting() {
g_shared_state.Pointer()->manager.PurgeAll();
internal::DiscardableMemoryEmulated::PurgeForTesting();
+ internal::DiscardableMemoryShmem::PurgeForTesting();
}
} // namespace base
« 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