| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // - Linux: http://lwn.net/Articles/452035/ | 56 // - Linux: http://lwn.net/Articles/452035/ |
| 57 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp | 57 // - Mac: http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mac/Pur
geableBufferMac.cpp |
| 58 // the comment starting with "vm_object_purgable_control" at | 58 // the comment starting with "vm_object_purgable_control" at |
| 59 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c | 59 // http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/v
m_object.c |
| 60 // | 60 // |
| 61 // Thread-safety: DiscardableMemory instances are not thread-safe. | 61 // Thread-safety: DiscardableMemory instances are not thread-safe. |
| 62 class BASE_EXPORT DiscardableMemory { | 62 class BASE_EXPORT DiscardableMemory { |
| 63 public: | 63 public: |
| 64 virtual ~DiscardableMemory() {} | 64 virtual ~DiscardableMemory() {} |
| 65 | 65 |
| 66 // Call this on a thread with a MessageLoop current to allow discardable |
| 67 // memory implementations to respond to memory pressure signals. |
| 68 static void RegisterMemoryPressureListeners(); |
| 69 |
| 70 // Call this to prevent discardable memory implementations from responding |
| 71 // to memory pressure signals. |
| 72 static void UnregisterMemoryPressureListeners(); |
| 73 |
| 66 // Gets the discardable memory type with a given name. | 74 // Gets the discardable memory type with a given name. |
| 67 static DiscardableMemoryType GetNamedType(const std::string& name); | 75 static DiscardableMemoryType GetNamedType(const std::string& name); |
| 68 | 76 |
| 69 // Gets the name of a discardable memory type. | 77 // Gets the name of a discardable memory type. |
| 70 static const char* GetTypeName(DiscardableMemoryType type); | 78 static const char* GetTypeName(DiscardableMemoryType type); |
| 71 | 79 |
| 72 // Gets system supported discardable memory types. Default preferred type | 80 // Gets system supported discardable memory types. Default preferred type |
| 73 // at the front of vector. | 81 // at the front of vector. |
| 74 static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types); | 82 static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types); |
| 75 | 83 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 static bool PurgeForTestingSupported(); | 119 static bool PurgeForTestingSupported(); |
| 112 | 120 |
| 113 // Purge all discardable memory in the system. This call has global effects | 121 // Purge all discardable memory in the system. This call has global effects |
| 114 // across all running processes, so it should only be used for testing! | 122 // across all running processes, so it should only be used for testing! |
| 115 static void PurgeForTesting(); | 123 static void PurgeForTesting(); |
| 116 }; | 124 }; |
| 117 | 125 |
| 118 } // namespace base | 126 } // namespace base |
| 119 | 127 |
| 120 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 128 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| OLD | NEW |