Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / base / test / test_discardable_memory_allocator.cc
blobeef1c982446633c79cdf94bee44ad578c55aed86
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/test/test_discardable_memory_allocator.h"
7 #include <stdint.h>
9 #include "base/memory/discardable_memory.h"
11 namespace base {
12 namespace {
14 class DiscardableMemoryImpl : public DiscardableMemory {
15 public:
16 explicit DiscardableMemoryImpl(size_t size) : data_(new uint8_t[size]) {}
18 // Overridden from DiscardableMemory:
19 bool Lock() override { return false; }
20 void Unlock() override {}
21 void* data() const override { return data_.get(); }
23 trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
24 const char* name,
25 trace_event::ProcessMemoryDump* pmd) const override {
26 return nullptr;
29 private:
30 scoped_ptr<uint8_t[]> data_;
33 } // namespace
35 TestDiscardableMemoryAllocator::TestDiscardableMemoryAllocator() {
38 TestDiscardableMemoryAllocator::~TestDiscardableMemoryAllocator() {
41 scoped_ptr<DiscardableMemory>
42 TestDiscardableMemoryAllocator::AllocateLockedDiscardableMemory(size_t size) {
43 return make_scoped_ptr(new DiscardableMemoryImpl(size));
46 } // namespace base