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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // memory, use it as quickly as possible, and then unlock it. | 37 // memory, use it as quickly as possible, and then unlock it. |
38 // - Because of memory alignment, the amount of memory allocated can be | 38 // - Because of memory alignment, the amount of memory allocated can be |
39 // larger than the requested memory size. It is not very efficient for | 39 // larger than the requested memory size. It is not very efficient for |
40 // small allocations. | 40 // small allocations. |
41 // | 41 // |
42 // References: | 42 // References: |
43 // - Linux: http://lwn.net/Articles/452035/ | 43 // - Linux: http://lwn.net/Articles/452035/ |
44 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp | 44 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp |
45 // the comment starting with "vm_object_purgable_control" at | 45 // the comment starting with "vm_object_purgable_control" at |
46 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c | 46 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c |
| 47 // |
| 48 // Thread-safety: DiscardableMemory instances are not thread-safe. |
47 class BASE_EXPORT DiscardableMemory { | 49 class BASE_EXPORT DiscardableMemory { |
48 public: | 50 public: |
49 virtual ~DiscardableMemory() {} | 51 virtual ~DiscardableMemory() {} |
50 | 52 |
51 // Returns whether the system supports discardable memory. | 53 // Returns whether the system supports discardable memory. |
52 static bool Supported(); | 54 static bool Supported(); |
53 | 55 |
54 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); | 56 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); |
55 | 57 |
56 // Locks the memory so that it will not be purged by the system. Returns | 58 // Locks the memory so that it will not be purged by the system. Returns |
(...skipping 19 matching lines...) Expand all Loading... |
76 static bool PurgeForTestingSupported(); | 78 static bool PurgeForTestingSupported(); |
77 | 79 |
78 // Purge all discardable memory in the system. This call has global effects | 80 // Purge all discardable memory in the system. This call has global effects |
79 // across all running processes, so it should only be used for testing! | 81 // across all running processes, so it should only be used for testing! |
80 static void PurgeForTesting(); | 82 static void PurgeForTesting(); |
81 }; | 83 }; |
82 | 84 |
83 } // namespace base | 85 } // namespace base |
84 | 86 |
85 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 87 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
OLD | NEW |