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

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

Issue 336273003: base: Add soft memory limit to DiscardableMemoryManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac build Created 6 years, 5 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_android.cc ('k') | base/memory/discardable_memory_emulated.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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
7 7
8 #include "base/memory/discardable_memory.h" 8 #include "base/memory/discardable_memory.h"
9 9
10 #include "base/memory/discardable_memory_manager.h" 10 #include "base/memory/discardable_memory_manager.h"
11 11
12 namespace base { 12 namespace base {
13 namespace internal { 13 namespace internal {
14 14
15 class DiscardableMemoryEmulated 15 class DiscardableMemoryEmulated
16 : public DiscardableMemory, 16 : public DiscardableMemory,
17 public internal::DiscardableMemoryManagerAllocation { 17 public internal::DiscardableMemoryManagerAllocation {
18 public: 18 public:
19 explicit DiscardableMemoryEmulated(size_t bytes); 19 explicit DiscardableMemoryEmulated(size_t bytes);
20 virtual ~DiscardableMemoryEmulated(); 20 virtual ~DiscardableMemoryEmulated();
21 21
22 static void RegisterMemoryPressureListeners(); 22 static void RegisterMemoryPressureListeners();
23 static void UnregisterMemoryPressureListeners(); 23 static void UnregisterMemoryPressureListeners();
24 static bool ReduceMemoryUsage();
24 25
25 static void PurgeForTesting(); 26 static void PurgeForTesting();
26 27
27 bool Initialize(); 28 bool Initialize();
28 29
29 // Overridden from DiscardableMemory: 30 // Overridden from DiscardableMemory:
30 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; 31 virtual DiscardableMemoryLockStatus Lock() OVERRIDE;
31 virtual void Unlock() OVERRIDE; 32 virtual void Unlock() OVERRIDE;
32 virtual void* Memory() const OVERRIDE; 33 virtual void* Memory() const OVERRIDE;
33 34
34 // Overridden from internal::DiscardableMemoryManagerAllocation: 35 // Overridden from internal::DiscardableMemoryManagerAllocation:
35 virtual bool AllocateAndAcquireLock() OVERRIDE; 36 virtual bool AllocateAndAcquireLock() OVERRIDE;
36 virtual void ReleaseLock() OVERRIDE {} 37 virtual void ReleaseLock() OVERRIDE {}
37 virtual void Purge() OVERRIDE; 38 virtual void Purge() OVERRIDE;
38 39
39 private: 40 private:
40 const size_t bytes_; 41 const size_t bytes_;
41 scoped_ptr<uint8[]> memory_; 42 scoped_ptr<uint8[]> memory_;
42 bool is_locked_; 43 bool is_locked_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); 45 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated);
45 }; 46 };
46 47
47 } // namespace internal 48 } // namespace internal
48 } // namespace base 49 } // namespace base
49 50
50 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 51 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_android.cc ('k') | base/memory/discardable_memory_emulated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698