| 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. |
| 50 class BASE_EXPORT DiscardableMemory { | 52 class BASE_EXPORT DiscardableMemory { |
| 51 public: | 53 public: |
| 52 virtual ~DiscardableMemory() {} | 54 virtual ~DiscardableMemory() {} |
| 53 | 55 |
| 54 // Check whether the system supports discardable memory natively. Returns | 56 // Check whether the system supports discardable memory natively. Returns |
| 55 // false if the support is emulated. | 57 // false if the support is emulated. |
| 56 static bool SupportedNatively(); | 58 static bool SupportedNatively(); |
| 57 | 59 |
| 58 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); | 60 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); |
| 59 | 61 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 static bool PurgeForTestingSupported(); | 82 static bool PurgeForTestingSupported(); |
| 81 | 83 |
| 82 // Purge all discardable memory in the system. This call has global effects | 84 // Purge all discardable memory in the system. This call has global effects |
| 83 // across all running processes, so it should only be used for testing! | 85 // across all running processes, so it should only be used for testing! |
| 84 static void PurgeForTesting(); | 86 static void PurgeForTesting(); |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 } // namespace base | 89 } // namespace base |
| 88 | 90 |
| 89 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 91 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| OLD | NEW |