Add UMA to identify where a hotword trigger comes from.
[chromium-blink-merge.git] / base / memory / discardable_memory_mach.h
blobaf2191f338c4e86549ebd2631d84a8d0ee022e57
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
3 // found in the LICENSE file.
5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_MACH_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MACH_H_
8 #include "base/memory/discardable_memory.h"
10 #include "base/mac/scoped_mach_vm.h"
11 #include "base/memory/discardable_memory_manager.h"
13 namespace base {
14 namespace internal {
16 class DiscardableMemoryMach
17 : public DiscardableMemory,
18 public internal::DiscardableMemoryManagerAllocation {
19 public:
20 explicit DiscardableMemoryMach(size_t bytes);
21 ~DiscardableMemoryMach() override;
23 static void PurgeForTesting();
25 bool Initialize();
27 // Overridden from DiscardableMemory:
28 DiscardableMemoryLockStatus Lock() override;
29 void Unlock() override;
30 void* Memory() const override;
32 // Overridden from internal::DiscardableMemoryManagerAllocation:
33 bool AllocateAndAcquireLock() override;
34 void ReleaseLock() override;
35 void Purge() override;
36 bool IsMemoryResident() const override;
38 private:
39 mac::ScopedMachVM memory_;
40 const size_t bytes_;
41 bool is_locked_;
43 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMach);
46 } // namespace internal
47 } // namespace base
49 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MACH_H_