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/compiler_specific.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 | 9 |
9 namespace base { | 10 namespace base { |
10 | 11 |
11 DiscardableMemory::DiscardableMemory() | |
12 : memory_(NULL), | |
13 size_(0), | |
14 is_locked_(false) | |
15 #if defined(OS_ANDROID) | |
16 , fd_(-1) | |
17 #endif // OS_ANDROID | |
18 { | |
19 DCHECK(Supported()); | |
20 } | |
21 | |
22 void* DiscardableMemory::Memory() const { | |
23 DCHECK(is_locked_); | |
24 return memory_; | |
25 } | |
26 | |
27 // Stub implementations for platforms that don't support discardable memory. | 12 // Stub implementations for platforms that don't support discardable memory. |
28 | 13 |
29 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | 14 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) |
30 | 15 |
31 DiscardableMemory::~DiscardableMemory() { | |
32 NOTIMPLEMENTED(); | |
33 } | |
34 | |
35 // static | 16 // static |
36 bool DiscardableMemory::Supported() { | 17 bool DiscardableMemory::Supported() { |
37 return false; | 18 return false; |
38 } | 19 } |
39 | 20 |
40 bool DiscardableMemory::InitializeAndLock(size_t size) { | 21 // static |
41 NOTIMPLEMENTED(); | 22 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemory( |
42 return false; | 23 size_t size) { |
43 } | 24 return scoped_ptr<DiscardableMemory>(); |
44 | |
45 LockDiscardableMemoryStatus DiscardableMemory::Lock() { | |
46 NOTIMPLEMENTED(); | |
47 return DISCARDABLE_MEMORY_FAILED; | |
48 } | |
49 | |
50 void DiscardableMemory::Unlock() { | |
51 NOTIMPLEMENTED(); | |
52 } | 25 } |
53 | 26 |
54 // static | 27 // static |
55 bool DiscardableMemory::PurgeForTestingSupported() { | 28 bool DiscardableMemory::PurgeForTestingSupported() { |
56 return false; | 29 return false; |
57 } | 30 } |
58 | 31 |
59 // static | 32 // static |
60 void DiscardableMemory::PurgeForTesting() { | 33 void DiscardableMemory::PurgeForTesting() { |
61 NOTIMPLEMENTED(); | 34 NOTIMPLEMENTED(); |
62 } | 35 } |
63 | 36 |
64 #endif // OS_* | 37 #endif // OS_* |
65 | 38 |
66 } // namespace base | 39 } // namespace base |
OLD | NEW |