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

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

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation issues on non-Android platforms 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ASHMEM_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_
7 7
8 #include "base/memory/discardable_memory.h" 8 #include "base/memory/discardable_memory.h"
9 9
10 #include "base/macros.h"
10 #include "base/memory/discardable_memory_manager.h" 11 #include "base/memory/discardable_memory_manager.h"
11 12
12 namespace base { 13 namespace base {
13 namespace internal { 14 namespace internal {
14 15
15 class DiscardableMemoryEmulated 16 class DiscardableAshmemChunk;
17 class DiscardableMemoryAshmemAllocator;
18 class DiscardableMemoryManager;
19
20 class DiscardableMemoryAshmem
16 : public DiscardableMemory, 21 : public DiscardableMemory,
17 public internal::DiscardableMemoryManagerAllocation { 22 public internal::DiscardableMemoryManagerAllocation {
18 public: 23 public:
19 explicit DiscardableMemoryEmulated(size_t size); 24 explicit DiscardableMemoryAshmem(size_t bytes,
20 virtual ~DiscardableMemoryEmulated(); 25 DiscardableMemoryAshmemAllocator* allocator,
26 DiscardableMemoryManager* manager);
21 27
22 static void RegisterMemoryPressureListeners(); 28 virtual ~DiscardableMemoryAshmem();
23 static void UnregisterMemoryPressureListeners();
24
25 static void PurgeForTesting();
26 29
27 bool Initialize(); 30 bool Initialize();
28 31
29 // Overridden from DiscardableMemory: 32 // Overridden from DiscardableMemory:
30 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; 33 virtual DiscardableMemoryLockStatus Lock() OVERRIDE;
31 virtual void Unlock() OVERRIDE; 34 virtual void Unlock() OVERRIDE;
32 virtual void* Memory() const OVERRIDE; 35 virtual void* Memory() const OVERRIDE;
33 36
34 // Overridden from internal::DiscardableMemoryManagerAllocation: 37 // Overridden from internal::DiscardableMemoryManagerAllocation:
35 virtual bool AllocateAndAcquireLock(size_t bytes) OVERRIDE; 38 virtual bool AllocateAndAcquireLock() OVERRIDE;
36 virtual void ReleaseLock() OVERRIDE {} 39 virtual void ReleaseLock() OVERRIDE;
37 virtual void Purge() OVERRIDE; 40 virtual void Purge() OVERRIDE;
38 41
39 private: 42 private:
40 scoped_ptr<uint8[]> memory_; 43 const size_t bytes_;
41 bool is_locked_; 44 DiscardableMemoryAshmemAllocator* const allocator_;
45 DiscardableMemoryManager* const manager_;
46 scoped_ptr<DiscardableAshmemChunk> ashmem_chunk_;
42 47
43 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); 48 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem);
44 }; 49 };
45 50
46 } // namespace internal 51 } // namespace internal
47 } // namespace base 52 } // namespace base
48 53
49 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ 54 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698