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

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

Issue 458343003: Revert of base: Introduce an explicit call for reducing emulated discardable memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/memory/discardable_memory.h ('k') | base/memory/discardable_memory_emulated.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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
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::SysInfo::AmountOfPhysicalMemory() / 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, TimeDelta::Max()), 35 : manager(kAshmemMemoryLimit,
36 kAshmemMemoryLimit,
37 kAshmemMemoryLimit,
38 TimeDelta::Max()),
36 allocator(kAshmemAllocatorName, 39 allocator(kAshmemAllocatorName,
37 GetOptimalAshmemRegionSizeForAllocator()) {} 40 GetOptimalAshmemRegionSizeForAllocator()) {}
38 41
39 internal::DiscardableMemoryManager manager; 42 internal::DiscardableMemoryManager manager;
40 internal::DiscardableMemoryAshmemAllocator allocator; 43 internal::DiscardableMemoryAshmemAllocator allocator;
41 }; 44 };
42 LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER; 45 LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER;
43 46
44 } // namespace 47 } // namespace
45 48
46 // static 49 // static
50 void DiscardableMemory::RegisterMemoryPressureListeners() {
51 internal::DiscardableMemoryEmulated::RegisterMemoryPressureListeners();
52 }
53
54 // static
55 void DiscardableMemory::UnregisterMemoryPressureListeners() {
56 internal::DiscardableMemoryEmulated::UnregisterMemoryPressureListeners();
57 }
58
59 // static
47 bool DiscardableMemory::ReduceMemoryUsage() { 60 bool DiscardableMemory::ReduceMemoryUsage() {
48 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage(); 61 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
49 } 62 }
50 63
51 // static 64 // static
52 void DiscardableMemory::GetSupportedTypes( 65 void DiscardableMemory::GetSupportedTypes(
53 std::vector<DiscardableMemoryType>* types) { 66 std::vector<DiscardableMemoryType>* types) {
54 const DiscardableMemoryType supported_types[] = { 67 const DiscardableMemoryType supported_types[] = {
55 DISCARDABLE_MEMORY_TYPE_ASHMEM, 68 DISCARDABLE_MEMORY_TYPE_ASHMEM,
56 DISCARDABLE_MEMORY_TYPE_EMULATED, 69 DISCARDABLE_MEMORY_TYPE_EMULATED,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return scoped_ptr<DiscardableMemory>(); 111 return scoped_ptr<DiscardableMemory>();
99 } 112 }
100 113
101 // static 114 // static
102 void DiscardableMemory::PurgeForTesting() { 115 void DiscardableMemory::PurgeForTesting() {
103 g_shared_state.Pointer()->manager.PurgeAll(); 116 g_shared_state.Pointer()->manager.PurgeAll();
104 internal::DiscardableMemoryEmulated::PurgeForTesting(); 117 internal::DiscardableMemoryEmulated::PurgeForTesting();
105 } 118 }
106 119
107 } // namespace base 120 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory.h ('k') | base/memory/discardable_memory_emulated.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698