Add UMA to identify where a hotword trigger comes from.
[chromium-blink-merge.git] / base / memory / discardable_memory_win.cc
blob9b4e9401ce4ff7c006756a9a5ed6a245431662c9
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 #include "base/memory/discardable_memory.h"
7 #include "base/logging.h"
8 #include "base/memory/discardable_memory_emulated.h"
9 #include "base/memory/discardable_memory_shmem.h"
11 namespace base {
13 // static
14 void DiscardableMemory::ReleaseFreeMemory() {
15 internal::DiscardableMemoryShmem::ReleaseFreeMemory();
18 // static
19 bool DiscardableMemory::ReduceMemoryUsage() {
20 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage();
23 // static
24 void DiscardableMemory::GetSupportedTypes(
25 std::vector<DiscardableMemoryType>* types) {
26 const DiscardableMemoryType supported_types[] = {
27 DISCARDABLE_MEMORY_TYPE_EMULATED,
28 DISCARDABLE_MEMORY_TYPE_SHMEM
30 types->assign(supported_types, supported_types + arraysize(supported_types));
33 // static
34 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
35 DiscardableMemoryType type, size_t size) {
36 switch (type) {
37 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
38 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
39 new internal::DiscardableMemoryEmulated(size));
40 if (!memory->Initialize())
41 return nullptr;
43 return memory.Pass();
45 case DISCARDABLE_MEMORY_TYPE_SHMEM: {
46 scoped_ptr<internal::DiscardableMemoryShmem> memory(
47 new internal::DiscardableMemoryShmem(size));
48 if (!memory->Initialize())
49 return nullptr;
51 return memory.Pass();
53 case DISCARDABLE_MEMORY_TYPE_NONE:
54 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
55 case DISCARDABLE_MEMORY_TYPE_MACH:
56 NOTREACHED();
57 return nullptr;
60 NOTREACHED();
61 return nullptr;
64 // static
65 void DiscardableMemory::PurgeForTesting() {
66 internal::DiscardableMemoryEmulated::PurgeForTesting();
67 internal::DiscardableMemoryShmem::PurgeForTesting();
70 } // namespace base