NACL_WIN64 takes precedence over USE_OPENSSL.
[chromium-blink-merge.git] / base / memory / discardable_memory_emulated.h
blob150c1ab5669b07de010fa68cb4bc966bbec1d998
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
3 // found in the LICENSE file.
5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_
8 #include "base/memory/discardable_memory.h"
10 #include "base/memory/discardable_memory_manager.h"
12 namespace base {
13 namespace internal {
15 class DiscardableMemoryEmulated
16 : public DiscardableMemory,
17 public internal::DiscardableMemoryManagerAllocation {
18 public:
19 explicit DiscardableMemoryEmulated(size_t bytes);
20 ~DiscardableMemoryEmulated() override;
22 static bool ReduceMemoryUsage();
24 // TODO(reveman): Remove this as it is breaking the discardable memory design
25 // principle that implementations should not rely on information this is
26 // unavailable in kernel space. crbug.com/400423
27 BASE_EXPORT static void ReduceMemoryUsageUntilWithinLimit(size_t bytes);
29 static void PurgeForTesting();
31 bool Initialize();
33 // Overridden from DiscardableMemory:
34 DiscardableMemoryLockStatus Lock() override;
35 void Unlock() override;
36 void* Memory() const override;
38 // Overridden from internal::DiscardableMemoryManagerAllocation:
39 bool AllocateAndAcquireLock() override;
40 void ReleaseLock() override {}
41 void Purge() override;
42 bool IsMemoryResident() const override;
44 private:
45 const size_t bytes_;
46 scoped_ptr<uint8[]> memory_;
47 bool is_locked_;
49 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated);
52 } // namespace internal
53 } // namespace base
55 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_