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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/memory/discardable_memory_emulated.h ('k') | base/memory/discardable_memory_linux.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_emulated.h" 5 #include "base/memory/discardable_memory_emulated.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/discardable_memory_manager.h" 8 #include "base/memory/discardable_memory_manager.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 bool DiscardableMemoryEmulated::ReduceMemoryUsage() { 61 bool DiscardableMemoryEmulated::ReduceMemoryUsage() {
62 return g_manager.Pointer()->ReduceMemoryUsage(); 62 return g_manager.Pointer()->ReduceMemoryUsage();
63 } 63 }
64 64
65 // static 65 // static
66 void DiscardableMemoryEmulated::ReduceMemoryUsageUntilWithinLimit( 66 void DiscardableMemoryEmulated::ReduceMemoryUsageUntilWithinLimit(
67 size_t bytes) { 67 size_t bytes) {
68 g_manager.Pointer()->ReduceMemoryUsageUntilWithinLimit(bytes); 68 g_manager.Pointer()->ReduceMemoryUsageUntilWithinLimit(bytes);
69 } 69 }
70 70
71 // static
72 void DiscardableMemoryEmulated::PurgeForTesting() {
73 g_manager.Pointer()->PurgeAll();
74 }
75
76 bool DiscardableMemoryEmulated::Initialize() { 71 bool DiscardableMemoryEmulated::Initialize() {
77 return Lock() != DISCARDABLE_MEMORY_LOCK_STATUS_FAILED; 72 return Lock() != DISCARDABLE_MEMORY_LOCK_STATUS_FAILED;
78 } 73 }
79 74
80 DiscardableMemoryLockStatus DiscardableMemoryEmulated::Lock() { 75 DiscardableMemoryLockStatus DiscardableMemoryEmulated::Lock() {
81 DCHECK(!is_locked_); 76 DCHECK(!is_locked_);
82 77
83 bool purged = false; 78 bool purged = false;
84 if (!g_manager.Pointer()->AcquireLock(this, &purged)) 79 if (!g_manager.Pointer()->AcquireLock(this, &purged))
85 return DISCARDABLE_MEMORY_LOCK_STATUS_FAILED; 80 return DISCARDABLE_MEMORY_LOCK_STATUS_FAILED;
(...skipping 20 matching lines...) Expand all
106 return true; 101 return true;
107 102
108 memory_.reset(new uint8[bytes_]); 103 memory_.reset(new uint8[bytes_]);
109 return false; 104 return false;
110 } 105 }
111 106
112 void DiscardableMemoryEmulated::Purge() { 107 void DiscardableMemoryEmulated::Purge() {
113 memory_.reset(); 108 memory_.reset();
114 } 109 }
115 110
116 bool DiscardableMemoryEmulated::IsMemoryResident() const {
117 return true;
118 }
119
120 } // namespace internal 111 } // namespace internal
121 } // namespace base 112 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_emulated.h ('k') | base/memory/discardable_memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698