| 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 22 matching lines...) Expand all Loading... |
| 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 | 42 |
| 43 } // namespace blink | |
| 44 | |
| 45 namespace blink { | |
| 46 | |
| 47 // A simple vector implementation that supports purgeable memory. The vector is | 43 // A simple vector implementation that supports purgeable memory. The vector is |
| 48 // already locked at construction and locking uses an internal counter which | 44 // already locked at construction and locking uses an internal counter which |
| 49 // means that N calls to lock() must be followed by N+1 calls to unlock() to | 45 // means that N calls to lock() must be followed by N+1 calls to unlock() to |
| 50 // actually make the vector purgeable. | 46 // actually make the vector purgeable. |
| 51 class PLATFORM_EXPORT PurgeableVector { | 47 class PLATFORM_EXPORT PurgeableVector { |
| 52 WTF_MAKE_NONCOPYABLE(PurgeableVector); | 48 WTF_MAKE_NONCOPYABLE(PurgeableVector); |
| 53 public: | 49 public: |
| 54 enum PurgeableOption { | 50 enum PurgeableOption { |
| 55 NotPurgeable, | 51 NotPurgeable, |
| 56 Purgeable, | 52 Purgeable, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 104 |
| 109 bool reservePurgeableCapacity(size_t capacity, PurgeableAllocationStrategy); | 105 bool reservePurgeableCapacity(size_t capacity, PurgeableAllocationStrategy); |
| 110 | 106 |
| 111 size_t adjustPurgeableCapacity(size_t capacity) const; | 107 size_t adjustPurgeableCapacity(size_t capacity) const; |
| 112 | 108 |
| 113 // Vector used when the instance is constructed without the purgeability | 109 // Vector used when the instance is constructed without the purgeability |
| 114 // hint or when discardable memory allocation fails. | 110 // hint or when discardable memory allocation fails. |
| 115 // Note that there can't be data both in |m_vector| and | 111 // Note that there can't be data both in |m_vector| and |
| 116 // |m_discardable|, i.e. only one of them is used at a given time. | 112 // |m_discardable|, i.e. only one of them is used at a given time. |
| 117 Vector<char> m_vector; | 113 Vector<char> m_vector; |
| 118 OwnPtr<blink::WebDiscardableMemory> m_discardable; | 114 OwnPtr<WebDiscardableMemory> m_discardable; |
| 119 size_t m_discardableCapacity; | 115 size_t m_discardableCapacity; |
| 120 size_t m_discardableSize; | 116 size_t m_discardableSize; |
| 121 bool m_isPurgeable; | 117 bool m_isPurgeable; |
| 122 int m_locksCount; | 118 int m_locksCount; |
| 123 }; | 119 }; |
| 124 | 120 |
| 125 } // namespace blink | 121 } // namespace blink |
| 126 | 122 |
| 127 #endif // PurgeableVector_h | 123 #endif // PurgeableVector_h |
| OLD | NEW |