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