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

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: 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 unified diff | Download patch
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_allocator_android.h" 11 #include "base/memory/discardable_memory_allocator_android.h"
13 #include "base/memory/discardable_memory_emulated.h" 12 #include "base/memory/discardable_memory_emulated.h"
14 #include "base/memory/discardable_memory_malloc.h" 13 #include "base/memory/discardable_memory_malloc.h"
14 #include "base/sys_utils.h"
15 15
16 namespace base { 16 namespace base {
17 namespace { 17 namespace {
18 18
19 const char kAshmemAllocatorName[] = "DiscardableMemoryAllocator"; 19 const char kAshmemAllocatorName[] = "DiscardableMemoryAllocator";
20 20
21 struct DiscardableMemoryAllocatorWrapper { 21 struct DiscardableMemoryAllocatorWrapper {
22 DiscardableMemoryAllocatorWrapper() 22 DiscardableMemoryAllocatorWrapper()
23 : allocator(kAshmemAllocatorName, 23 : allocator(kAshmemAllocatorName,
24 GetOptimalAshmemRegionSizeForAllocator()) { 24 GetOptimalAshmemRegionSizeForAllocator()) {
25 } 25 }
26 26
27 internal::DiscardableMemoryAllocator allocator; 27 internal::DiscardableMemoryAllocator allocator;
28 28
29 private: 29 private:
30 // Returns 64 MBytes for a 512 MBytes device, 128 MBytes for 1024 MBytes... 30 // Returns 64 MBytes for a 512 MBytes device, 128 MBytes for 1024 MBytes...
31 static size_t GetOptimalAshmemRegionSizeForAllocator() { 31 static size_t GetOptimalAshmemRegionSizeForAllocator() {
32 // Note that this may do some I/O (without hitting the disk though) so it 32 // Note that this may do some I/O (without hitting the disk though) so it
33 // should not be called on the critical path. 33 // should not be called on the critical path.
34 return base::android::SysUtils::AmountOfPhysicalMemoryKB() * 1024 / 8; 34 return base::SysUtils::AmountOfPhysicalMemoryKB() * 1024 / 8;
35 } 35 }
36 }; 36 };
37 37
38 LazyInstance<DiscardableMemoryAllocatorWrapper>::Leaky g_context = 38 LazyInstance<DiscardableMemoryAllocatorWrapper>::Leaky g_context =
39 LAZY_INSTANCE_INITIALIZER; 39 LAZY_INSTANCE_INITIALIZER;
40 40
41 } // namespace 41 } // namespace
42 42
43 // static 43 // static
44 void DiscardableMemory::RegisterMemoryPressureListeners() { 44 void DiscardableMemory::RegisterMemoryPressureListeners() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool DiscardableMemory::PurgeForTestingSupported() { 97 bool DiscardableMemory::PurgeForTestingSupported() {
98 return false; 98 return false;
99 } 99 }
100 100
101 // static 101 // static
102 void DiscardableMemory::PurgeForTesting() { 102 void DiscardableMemory::PurgeForTesting() {
103 NOTIMPLEMENTED(); 103 NOTIMPLEMENTED();
104 } 104 }
105 105
106 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/base_switches.cc ('k') | base/sys_utils.h » ('j') | base/sys_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698