Added unit test for DevTools' ephemeral port support.
[chromium-blink-merge.git] / base / memory / discardable_memory_emulated.h
blob3242245c10b8958e9ff64a3bc6e81189ceb16396
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 virtual ~DiscardableMemoryEmulated();
22 static void RegisterMemoryPressureListeners();
23 static void UnregisterMemoryPressureListeners();
25 static void PurgeForTesting();
27 bool Initialize();
29 // Overridden from DiscardableMemory:
30 virtual DiscardableMemoryLockStatus Lock() OVERRIDE;
31 virtual void Unlock() OVERRIDE;
32 virtual void* Memory() const OVERRIDE;
34 // Overridden from internal::DiscardableMemoryManagerAllocation:
35 virtual bool AllocateAndAcquireLock() OVERRIDE;
36 virtual void ReleaseLock() OVERRIDE {}
37 virtual void Purge() OVERRIDE;
39 private:
40 const size_t bytes_;
41 scoped_ptr<uint8[]> memory_;
42 bool is_locked_;
44 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated);
47 } // namespace internal
48 } // namespace base
50 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_