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

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

Issue 285493004: [Mac] A couple of improvements for DiscardableMemory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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_ashmem.cc ('k') | base/memory/discardable_memory_mac.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void DiscardableMemoryEmulated::UnregisterMemoryPressureListeners() { 49 void DiscardableMemoryEmulated::UnregisterMemoryPressureListeners() {
50 g_shared_state.Pointer()->manager.UnregisterMemoryPressureListener(); 50 g_shared_state.Pointer()->manager.UnregisterMemoryPressureListener();
51 } 51 }
52 52
53 // static 53 // static
54 void DiscardableMemoryEmulated::PurgeForTesting() { 54 void DiscardableMemoryEmulated::PurgeForTesting() {
55 g_shared_state.Pointer()->manager.PurgeAll(); 55 g_shared_state.Pointer()->manager.PurgeAll();
56 } 56 }
57 57
58 bool DiscardableMemoryEmulated::Initialize() { 58 bool DiscardableMemoryEmulated::Initialize() {
59 return Lock() == DISCARDABLE_MEMORY_LOCK_STATUS_PURGED; 59 return Lock() != DISCARDABLE_MEMORY_LOCK_STATUS_FAILED;
60 } 60 }
61 61
62 DiscardableMemoryLockStatus DiscardableMemoryEmulated::Lock() { 62 DiscardableMemoryLockStatus DiscardableMemoryEmulated::Lock() {
63 DCHECK(!is_locked_); 63 DCHECK(!is_locked_);
64 64
65 bool purged = false; 65 bool purged = false;
66 if (!g_shared_state.Pointer()->manager.AcquireLock(this, &purged)) 66 if (!g_shared_state.Pointer()->manager.AcquireLock(this, &purged))
67 return DISCARDABLE_MEMORY_LOCK_STATUS_FAILED; 67 return DISCARDABLE_MEMORY_LOCK_STATUS_FAILED;
68 68
69 is_locked_ = true; 69 is_locked_ = true;
(...skipping 20 matching lines...) Expand all
90 memory_.reset(new uint8[bytes_]); 90 memory_.reset(new uint8[bytes_]);
91 return false; 91 return false;
92 } 92 }
93 93
94 void DiscardableMemoryEmulated::Purge() { 94 void DiscardableMemoryEmulated::Purge() {
95 memory_.reset(); 95 memory_.reset();
96 } 96 }
97 97
98 } // namespace internal 98 } // namespace internal
99 } // namespace base 99 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_ashmem.cc ('k') | base/memory/discardable_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698