| OLD | NEW |
| 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_MALLOC_H_ |
| 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MALLOC_H_ |
| 7 | 7 |
| 8 #include "base/memory/discardable_memory.h" | 8 #include "base/memory/discardable_memory.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 class DiscardableMemoryEmulated : public DiscardableMemory { | 13 class DiscardableMemoryMalloc : public DiscardableMemory { |
| 14 public: | 14 public: |
| 15 explicit DiscardableMemoryEmulated(size_t size); | 15 explicit DiscardableMemoryMalloc(size_t size); |
| 16 virtual ~DiscardableMemoryEmulated(); | 16 virtual ~DiscardableMemoryMalloc(); |
| 17 | |
| 18 static void RegisterMemoryPressureListeners(); | |
| 19 static void UnregisterMemoryPressureListeners(); | |
| 20 | |
| 21 static void PurgeForTesting(); | |
| 22 | 17 |
| 23 bool Initialize(); | 18 bool Initialize(); |
| 24 | 19 |
| 25 // Overridden from DiscardableMemory: | 20 // Overridden from DiscardableMemory: |
| 26 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; | 21 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; |
| 27 virtual void Unlock() OVERRIDE; | 22 virtual void Unlock() OVERRIDE; |
| 28 virtual void* Memory() const OVERRIDE; | 23 virtual void* Memory() const OVERRIDE; |
| 29 | 24 |
| 30 private: | 25 private: |
| 31 scoped_ptr<uint8, FreeDeleter> memory_; | 26 scoped_ptr<uint8, FreeDeleter> memory_; |
| 32 bool is_locked_; | 27 const size_t size_; |
| 33 | 28 |
| 34 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); | 29 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMalloc); |
| 35 }; | 30 }; |
| 36 | 31 |
| 37 } // namespace internal | 32 } // namespace internal |
| 38 } // namespace base | 33 } // namespace base |
| 39 | 34 |
| 40 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ | 35 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MALLOC_H_ |
| OLD | NEW |