| Index: base/memory/discardable_memory.cc
|
| diff --git a/base/memory/discardable_memory.cc b/base/memory/discardable_memory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6d74d650e7ff1ab3ece3b85cacb1e168817a0602
|
| --- /dev/null
|
| +++ b/base/memory/discardable_memory.cc
|
| @@ -0,0 +1,36 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/memory/discardable_memory.h"
|
| +
|
| +#include "base/lazy_instance.h"
|
| +
|
| +namespace base {
|
| +namespace {
|
| +
|
| +struct TypeInitializedWithPreferredValue {
|
| + TypeInitializedWithPreferredValue() : value(DISCARDABLE_MEMORY_TYPE_NONE) {
|
| + std::vector<DiscardableMemoryType> supported_types;
|
| + DiscardableMemory::GetSupportedTypes(&supported_types);
|
| + DCHECK(!supported_types.empty());
|
| + value = supported_types.front();
|
| + }
|
| + DiscardableMemoryType value;
|
| +};
|
| +LazyInstance<TypeInitializedWithPreferredValue>::Leaky
|
| + g_discardable_memory_type = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +void DiscardableMemory::SetType(DiscardableMemoryType type) {
|
| + g_discardable_memory_type.Get().value = type;
|
| +}
|
| +
|
| +// static
|
| +DiscardableMemoryType DiscardableMemory::GetType() {
|
| + return g_discardable_memory_type.Get().value;
|
| +}
|
| +
|
| +} // namespace base
|
|
|