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

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

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_ashmem.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 ~DiscardableMemoryEmulated() override; 20 ~DiscardableMemoryEmulated() override;
21 21
22 static bool ReduceMemoryUsage(); 22 static bool ReduceMemoryUsage();
23 23
24 // TODO(reveman): Remove this as it is breaking the discardable memory design 24 // TODO(reveman): Remove this as it is breaking the discardable memory design
25 // principle that implementations should not rely on information this is 25 // principle that implementations should not rely on information this is
26 // unavailable in kernel space. crbug.com/400423 26 // unavailable in kernel space. crbug.com/400423
27 BASE_EXPORT static void ReduceMemoryUsageUntilWithinLimit(size_t bytes); 27 BASE_EXPORT static void ReduceMemoryUsageUntilWithinLimit(size_t bytes);
28 28
29 static void PurgeForTesting();
30
31 bool Initialize(); 29 bool Initialize();
32 30
33 // Overridden from DiscardableMemory: 31 // Overridden from DiscardableMemory:
34 DiscardableMemoryLockStatus Lock() override; 32 DiscardableMemoryLockStatus Lock() override;
35 void Unlock() override; 33 void Unlock() override;
36 void* Memory() const override; 34 void* Memory() const override;
37 35
38 // Overridden from internal::DiscardableMemoryManagerAllocation: 36 // Overridden from internal::DiscardableMemoryManagerAllocation:
39 bool AllocateAndAcquireLock() override; 37 bool AllocateAndAcquireLock() override;
40 void ReleaseLock() override {} 38 void ReleaseLock() override {}
41 void Purge() override; 39 void Purge() override;
42 bool IsMemoryResident() const override;
43 40
44 private: 41 private:
45 const size_t bytes_; 42 const size_t bytes_;
46 scoped_ptr<uint8[]> memory_; 43 scoped_ptr<uint8[]> memory_;
47 bool is_locked_; 44 bool is_locked_;
48 45
49 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); 46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated);
50 }; 47 };
51 48
52 } // namespace internal 49 } // namespace internal
53 } // namespace base 50 } // namespace base
54 51
55 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_ashmem.cc ('k') | base/memory/discardable_memory_emulated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698