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 | |
74 // Gets the discardable memory type with a given name. | 66 // Gets the discardable memory type with a given name. |
75 static DiscardableMemoryType GetNamedType(const std::string& name); | 67 static DiscardableMemoryType GetNamedType(const std::string& name); |
76 | 68 |
77 // Gets the name of a discardable memory type. | 69 // Gets the name of a discardable memory type. |
78 static const char* GetTypeName(DiscardableMemoryType type); | 70 static const char* GetTypeName(DiscardableMemoryType type); |
79 | 71 |
80 // Gets system supported discardable memory types. Default preferred type | 72 // Gets system supported discardable memory types. Default preferred type |
81 // at the front of vector. | 73 // at the front of vector. |
82 static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types); | 74 static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types); |
83 | 75 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static bool PurgeForTestingSupported(); | 111 static bool PurgeForTestingSupported(); |
120 | 112 |
121 // Purge all discardable memory in the system. This call has global effects | 113 // Purge all discardable memory in the system. This call has global effects |
122 // across all running processes, so it should only be used for testing! | 114 // across all running processes, so it should only be used for testing! |
123 static void PurgeForTesting(); | 115 static void PurgeForTesting(); |
124 }; | 116 }; |
125 | 117 |
126 } // namespace base | 118 } // namespace base |
127 | 119 |
128 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 120 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
OLD | NEW |