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

Side by Side Diff: base/memory/discardable_memory_android.cc

Issue 258663002: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « base/base_switches.cc ('k') | base/sys_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/android/sys_utils.h"
8 #include "base/basictypes.h" 7 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/memory/discardable_memory_ashmem.h" 11 #include "base/memory/discardable_memory_ashmem.h"
13 #include "base/memory/discardable_memory_ashmem_allocator.h" 12 #include "base/memory/discardable_memory_ashmem_allocator.h"
14 #include "base/memory/discardable_memory_emulated.h" 13 #include "base/memory/discardable_memory_emulated.h"
15 #include "base/memory/discardable_memory_malloc.h" 14 #include "base/memory/discardable_memory_malloc.h"
15 #include "base/sys_info.h"
16 16
17 namespace base { 17 namespace base {
18 namespace { 18 namespace {
19 19
20 const char kAshmemAllocatorName[] = "DiscardableMemoryAshmemAllocator"; 20 const char kAshmemAllocatorName[] = "DiscardableMemoryAshmemAllocator";
21 21
22 // For Ashmem, have the DiscardableMemoryManager trigger userspace eviction 22 // For Ashmem, have the DiscardableMemoryManager trigger userspace eviction
23 // when address space usage gets too high (e.g. 512 MBytes). 23 // when address space usage gets too high (e.g. 512 MBytes).
24 const size_t kAshmemMemoryLimit = 512 * 1024 * 1024; 24 const size_t kAshmemMemoryLimit = 512 * 1024 * 1024;
25 25
26 size_t GetOptimalAshmemRegionSizeForAllocator() { 26 size_t GetOptimalAshmemRegionSizeForAllocator() {
27 // Note that this may do some I/O (without hitting the disk though) so it 27 // Note that this may do some I/O (without hitting the disk though) so it
28 // should not be called on the critical path. 28 // should not be called on the critical path.
29 return base::android::SysUtils::AmountOfPhysicalMemoryKB() * 1024 / 8; 29 return base::SysInfo::AmountOfPhysicalMemory() / 8;
30 } 30 }
31 31
32 // Holds the shared state used for allocations. 32 // Holds the shared state used for allocations.
33 struct SharedState { 33 struct SharedState {
34 SharedState() 34 SharedState()
35 : manager(kAshmemMemoryLimit, kAshmemMemoryLimit), 35 : manager(kAshmemMemoryLimit, kAshmemMemoryLimit),
36 allocator(kAshmemAllocatorName, 36 allocator(kAshmemAllocatorName,
37 GetOptimalAshmemRegionSizeForAllocator()) {} 37 GetOptimalAshmemRegionSizeForAllocator()) {}
38 38
39 internal::DiscardableMemoryManager manager; 39 internal::DiscardableMemoryManager manager;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return scoped_ptr<DiscardableMemory>(); 103 return scoped_ptr<DiscardableMemory>();
104 } 104 }
105 105
106 // static 106 // static
107 void DiscardableMemory::PurgeForTesting() { 107 void DiscardableMemory::PurgeForTesting() {
108 g_shared_state.Pointer()->manager.PurgeAll(); 108 g_shared_state.Pointer()->manager.PurgeAll();
109 internal::DiscardableMemoryEmulated::PurgeForTesting(); 109 internal::DiscardableMemoryEmulated::PurgeForTesting();
110 } 110 }
111 111
112 } // namespace base 112 } // namespace base
OLDNEW
« no previous file with comments | « base/base_switches.cc ('k') | base/sys_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698