| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #define PurgeableVector_h | 32 #define PurgeableVector_h |
| 33 | 33 |
| 34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
| 36 #include "wtf/Noncopyable.h" | 36 #include "wtf/Noncopyable.h" |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class WebDiscardableMemory; | 41 class WebDiscardableMemory; |
| 42 class WebProcessMemoryDump; |
| 42 | 43 |
| 43 // A simple vector implementation that supports purgeable memory. The vector is | 44 // A simple vector implementation that supports purgeable memory. The vector is |
| 44 // already locked at construction and locking uses an internal counter which | 45 // already locked at construction and locking uses an internal counter which |
| 45 // means that N calls to lock() must be followed by N+1 calls to unlock() to | 46 // means that N calls to lock() must be followed by N+1 calls to unlock() to |
| 46 // actually make the vector purgeable. | 47 // actually make the vector purgeable. |
| 47 class PLATFORM_EXPORT PurgeableVector { | 48 class PLATFORM_EXPORT PurgeableVector { |
| 48 WTF_MAKE_NONCOPYABLE(PurgeableVector); | 49 WTF_MAKE_NONCOPYABLE(PurgeableVector); |
| 49 public: | 50 public: |
| 50 enum PurgeableOption { | 51 enum PurgeableOption { |
| 51 NotPurgeable, | 52 NotPurgeable, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void unlock(); | 84 void unlock(); |
| 84 | 85 |
| 85 bool isLocked() const; | 86 bool isLocked() const; |
| 86 | 87 |
| 87 // Note that this method should be used carefully since it may not use | 88 // Note that this method should be used carefully since it may not use |
| 88 // exponential growth internally. This means that repeated/invalid uses of | 89 // exponential growth internally. This means that repeated/invalid uses of |
| 89 // it can result in O(N^2) append(). If you don't exactly know what you are | 90 // it can result in O(N^2) append(). If you don't exactly know what you are |
| 90 // doing then you should probably not call this method. | 91 // doing then you should probably not call this method. |
| 91 void reserveCapacity(size_t capacity); | 92 void reserveCapacity(size_t capacity); |
| 92 | 93 |
| 94 void onMemoryDump(const String& dumpPrefix, WebProcessMemoryDump*) const; |
| 95 |
| 93 private: | 96 private: |
| 94 enum PurgeableAllocationStrategy { | 97 enum PurgeableAllocationStrategy { |
| 95 UseExactCapacity, | 98 UseExactCapacity, |
| 96 UseExponentialGrowth, | 99 UseExponentialGrowth, |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 // Copies data from the discardable buffer to the vector and clears the | 102 // Copies data from the discardable buffer to the vector and clears the |
| 100 // discardable buffer. | 103 // discardable buffer. |
| 101 void moveDataFromDiscardableToVector(); | 104 void moveDataFromDiscardableToVector(); |
| 102 | 105 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 OwnPtr<WebDiscardableMemory> m_discardable; | 117 OwnPtr<WebDiscardableMemory> m_discardable; |
| 115 size_t m_discardableCapacity; | 118 size_t m_discardableCapacity; |
| 116 size_t m_discardableSize; | 119 size_t m_discardableSize; |
| 117 bool m_isPurgeable; | 120 bool m_isPurgeable; |
| 118 int m_locksCount; | 121 int m_locksCount; |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 } // namespace blink | 124 } // namespace blink |
| 122 | 125 |
| 123 #endif // PurgeableVector_h | 126 #endif // PurgeableVector_h |
| OLD | NEW |