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

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

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 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_ASHMEM_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_
7 7
8 #include "base/memory/discardable_memory.h" 8 #include "base/memory/discardable_memory.h"
9 9
10 #include "base/macros.h"
11 #include "base/memory/discardable_memory_manager.h" 10 #include "base/memory/discardable_memory_manager.h"
12 11
13 namespace base { 12 namespace base {
13 class DiscardableSharedMemory;
14
14 namespace internal { 15 namespace internal {
15 16
16 class DiscardableAshmemChunk; 17 class DiscardableMemoryShmem
17 class DiscardableMemoryAshmemAllocator;
18 class DiscardableMemoryManager;
19
20 class DiscardableMemoryAshmem
21 : public DiscardableMemory, 18 : public DiscardableMemory,
22 public internal::DiscardableMemoryManagerAllocation { 19 public internal::DiscardableMemoryManagerAllocation {
23 public: 20 public:
24 explicit DiscardableMemoryAshmem(size_t bytes, 21 explicit DiscardableMemoryShmem(size_t bytes);
25 DiscardableMemoryAshmemAllocator* allocator, 22 virtual ~DiscardableMemoryShmem();
26 DiscardableMemoryManager* manager);
27 23
28 virtual ~DiscardableMemoryAshmem(); 24 static void ReleaseFreeMemory();
25
26 static void PurgeForTesting();
29 27
30 bool Initialize(); 28 bool Initialize();
31 29
32 // Overridden from DiscardableMemory: 30 // Overridden from DiscardableMemory:
33 virtual DiscardableMemoryLockStatus Lock() override; 31 virtual DiscardableMemoryLockStatus Lock() override;
34 virtual void Unlock() override; 32 virtual void Unlock() override;
35 virtual void* Memory() const override; 33 virtual void* Memory() const override;
36 34
37 // Overridden from internal::DiscardableMemoryManagerAllocation: 35 // Overridden from internal::DiscardableMemoryManagerAllocation:
38 virtual bool AllocateAndAcquireLock() override; 36 virtual bool AllocateAndAcquireLock() override;
39 virtual void ReleaseLock() override; 37 virtual void ReleaseLock() override;
40 virtual void Purge() override; 38 virtual void Purge() override;
39 virtual bool IsMemoryResident() const override;
41 40
42 private: 41 private:
43 const size_t bytes_; 42 const size_t bytes_;
44 DiscardableMemoryAshmemAllocator* const allocator_; 43 scoped_ptr<DiscardableSharedMemory> shared_memory_;
45 DiscardableMemoryManager* const manager_;
46 bool is_locked_; 44 bool is_locked_;
47 scoped_ptr<DiscardableAshmemChunk> ashmem_chunk_;
48 45
49 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem); 46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmem);
50 }; 47 };
51 48
52 } // namespace internal 49 } // namespace internal
53 } // namespace base 50 } // namespace base
54 51
55 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_ 52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_manager_unittest.cc ('k') | base/memory/discardable_memory_shmem.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698