Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / base / memory / discardable_memory_allocator.cc
blob002a3ba5e4763c360dc0a96861d0c53758bdb3bc
1 // Copyright 2015 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_allocator.h"
7 #include "base/logging.h"
9 namespace base {
10 namespace {
12 DiscardableMemoryAllocator* g_allocator = nullptr;
14 } // namespace
16 // static
17 void DiscardableMemoryAllocator::SetInstance(
18 DiscardableMemoryAllocator* allocator) {
19 DCHECK(allocator);
21 // Make sure this function is only called once before the first call
22 // to GetInstance().
23 DCHECK(!g_allocator);
25 g_allocator = allocator;
28 // static
29 DiscardableMemoryAllocator* DiscardableMemoryAllocator::GetInstance() {
30 DCHECK(g_allocator);
31 return g_allocator;
34 } // namespace base