summaryrefslogtreecommitdiff
path: root/chromium/base/memory/discardable_memory.cc
blob: 33f9e19cdeee523f7b99a53a8452ef23f0f569f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 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/logging.h"

namespace base {

DiscardableMemory::DiscardableMemory()
    : memory_(NULL),
      size_(0),
      is_locked_(false)
#if defined(OS_ANDROID)
      , fd_(-1)
#endif  // OS_ANDROID
      {
  DCHECK(Supported());
}

void* DiscardableMemory::Memory() const {
  DCHECK(is_locked_);
  return memory_;
}

// Stub implementations for platforms that don't support discardable memory.

#if !defined(OS_ANDROID) && !defined(OS_MACOSX)

DiscardableMemory::~DiscardableMemory() {
  NOTIMPLEMENTED();
}

// static
bool DiscardableMemory::Supported() {
  return false;
}

bool DiscardableMemory::InitializeAndLock(size_t size) {
  NOTIMPLEMENTED();
  return false;
}

LockDiscardableMemoryStatus DiscardableMemory::Lock() {
  NOTIMPLEMENTED();
  return DISCARDABLE_MEMORY_FAILED;
}

void DiscardableMemory::Unlock() {
  NOTIMPLEMENTED();
}

// static
bool DiscardableMemory::PurgeForTestingSupported() {
  return false;
}

// static
void DiscardableMemory::PurgeForTesting() {
  NOTIMPLEMENTED();
}

#endif  // OS_*

}  // namespace base