OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/discardable_memory.h" | 5 #include "base/memory/discardable_memory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
11 DiscardableMemory::DiscardableMemory() | 11 DiscardableMemory::DiscardableMemory() |
12 : memory_(NULL), | 12 : memory_(NULL), |
13 size_(0), | 13 size_(0), |
14 is_locked_(false) | 14 is_locked_(false) |
15 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
16 , fd_(-1) | 16 , fd_(-1) |
17 #endif // OS_ANDROID | 17 #endif // OS_ANDROID |
18 { | 18 { |
19 DCHECK(Supported()); | |
20 } | 19 } |
21 | 20 |
22 void* DiscardableMemory::Memory() const { | 21 void* DiscardableMemory::Memory() const { |
23 DCHECK(is_locked_); | 22 DCHECK(is_locked_); |
24 return memory_; | 23 return memory_; |
25 } | 24 } |
26 | 25 |
27 // Stub implementations for platforms that don't support discardable memory. | |
28 | |
29 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
30 | |
31 DiscardableMemory::~DiscardableMemory() { | |
32 NOTIMPLEMENTED(); | |
33 } | |
34 | |
35 // static | |
36 bool DiscardableMemory::Supported() { | |
37 return false; | |
38 } | |
39 | |
40 bool DiscardableMemory::InitializeAndLock(size_t size) { | |
41 NOTIMPLEMENTED(); | |
42 return false; | |
43 } | |
44 | |
45 LockDiscardableMemoryStatus DiscardableMemory::Lock() { | |
46 NOTIMPLEMENTED(); | |
47 return DISCARDABLE_MEMORY_FAILED; | |
48 } | |
49 | |
50 void DiscardableMemory::Unlock() { | |
51 NOTIMPLEMENTED(); | |
52 } | |
53 | |
54 // static | |
55 bool DiscardableMemory::PurgeForTestingSupported() { | |
56 return false; | |
57 } | |
58 | |
59 // static | |
60 void DiscardableMemory::PurgeForTesting() { | |
61 NOTIMPLEMENTED(); | |
62 } | |
63 | |
64 #endif // OS_* | |
65 | |
66 } // namespace base | 26 } // namespace base |
OLD | NEW |