| 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 29 matching lines...) Expand all Loading... |
| 40 // small allocations. | 40 // small allocations. |
| 41 // - A discardable memory instance is not thread safe. It is the | 41 // - A discardable memory instance is not thread safe. It is the |
| 42 // responsibility of users of discardable memory to ensure there are no | 42 // responsibility of users of discardable memory to ensure there are no |
| 43 // races. | 43 // races. |
| 44 // | 44 // |
| 45 // References: | 45 // References: |
| 46 // - Linux: http://lwn.net/Articles/452035/ | 46 // - Linux: http://lwn.net/Articles/452035/ |
| 47 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp | 47 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp |
| 48 // the comment starting with "vm_object_purgable_control" at | 48 // the comment starting with "vm_object_purgable_control" at |
| 49 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c | 49 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c |
| 50 // | |
| 51 // Thread-safety: DiscardableMemory instances are not thread-safe. | |
| 52 class BASE_EXPORT DiscardableMemory { | 50 class BASE_EXPORT DiscardableMemory { |
| 53 public: | 51 public: |
| 54 virtual ~DiscardableMemory() {} | 52 virtual ~DiscardableMemory() {} |
| 55 | 53 |
| 56 // Check whether the system supports discardable memory natively. Returns | 54 // Check whether the system supports discardable memory natively. Returns |
| 57 // false if the support is emulated. | 55 // false if the support is emulated. |
| 58 static bool SupportedNatively(); | 56 static bool SupportedNatively(); |
| 59 | 57 |
| 60 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); | 58 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); |
| 61 | 59 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 82 static bool PurgeForTestingSupported(); | 80 static bool PurgeForTestingSupported(); |
| 83 | 81 |
| 84 // Purge all discardable memory in the system. This call has global effects | 82 // Purge all discardable memory in the system. This call has global effects |
| 85 // across all running processes, so it should only be used for testing! | 83 // across all running processes, so it should only be used for testing! |
| 86 static void PurgeForTesting(); | 84 static void PurgeForTesting(); |
| 87 }; | 85 }; |
| 88 | 86 |
| 89 } // namespace base | 87 } // namespace base |
| 90 | 88 |
| 91 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 89 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| OLD | NEW |