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" | |
8 | |
9 namespace base { | 7 namespace base { |
10 | 8 |
11 DiscardableMemory::DiscardableMemory() | 9 #if !defined(DISCARDABLE_MEMORY_SUPPORTED_NATIVELY) |
12 : memory_(NULL), | 10 static DiscardableMemoryProvider* s_factory = 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 | 11 |
22 void* DiscardableMemory::Memory() const { | 12 // static |
23 DCHECK(is_locked_); | 13 DiscardableMemoryProvider* DiscardableMemoryProvider::GetInstance() { |
24 return memory_; | 14 return s_factory; |
25 } | |
26 | |
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 } | 15 } |
34 | 16 |
35 // static | 17 // static |
36 bool DiscardableMemory::Supported() { | 18 void DiscardableMemoryProvider::SetInstance( |
37 return false; | 19 DiscardableMemoryProvider* factory) { |
| 20 s_factory = factory; |
| 21 } |
| 22 #endif |
| 23 |
| 24 DiscardableMemory::~DiscardableMemory() { |
38 } | 25 } |
39 | 26 |
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 | 27 } // namespace base |
OLD | NEW |