Chromium Code Reviews

Side by Side Diff: base/memory/discardable_memory_shmem.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.
Jump to:
View unified diff |
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_SHMEM_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_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/memory/discardable_memory_manager.h"
11
12 namespace base { 10 namespace base {
13 class DiscardableMemoryShmemChunk; 11 class DiscardableMemoryShmemChunk;
14 12
15 namespace internal { 13 namespace internal {
16 14
17 class DiscardableMemoryShmem 15 class DiscardableMemoryShmem : public DiscardableMemory {
18 : public DiscardableMemory,
19 public internal::DiscardableMemoryManagerAllocation {
20 public: 16 public:
21 explicit DiscardableMemoryShmem(size_t bytes); 17 explicit DiscardableMemoryShmem(size_t bytes);
22 ~DiscardableMemoryShmem() override; 18 ~DiscardableMemoryShmem() override;
23 19
24 static void ReleaseFreeMemory();
25
26 static void PurgeForTesting();
27
28 bool Initialize(); 20 bool Initialize();
29 21
30 // Overridden from DiscardableMemory: 22 // Overridden from DiscardableMemory:
31 DiscardableMemoryLockStatus Lock() override; 23 DiscardableMemoryLockStatus Lock() override;
32 void Unlock() override; 24 void Unlock() override;
33 void* Memory() const override; 25 void* Memory() const override;
34 26
35 // Overridden from internal::DiscardableMemoryManagerAllocation:
36 bool AllocateAndAcquireLock() override;
37 void ReleaseLock() override;
38 void Purge() override;
39 bool IsMemoryResident() const override;
40
41 private: 27 private:
42 const size_t bytes_; 28 const size_t bytes_;
43 scoped_ptr<DiscardableMemoryShmemChunk> chunk_; 29 scoped_ptr<DiscardableMemoryShmemChunk> chunk_;
44 bool is_locked_; 30 bool is_locked_;
45 31
46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmem); 32 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmem);
47 }; 33 };
48 34
49 } // namespace internal 35 } // namespace internal
50 } // namespace base 36 } // namespace base
51 37
52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ 38 #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