| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 WTF_MAKE_NONCOPYABLE(ArrayBufferContents); | 37 WTF_MAKE_NONCOPYABLE(ArrayBufferContents); |
| 38 public: | 38 public: |
| 39 enum InitializationPolicy { | 39 enum InitializationPolicy { |
| 40 ZeroInitialize, | 40 ZeroInitialize, |
| 41 DontInitialize | 41 DontInitialize |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 ArrayBufferContents(); | 44 ArrayBufferContents(); |
| 45 ArrayBufferContents(unsigned numElements, unsigned elementByteSize, ArrayBuf
ferContents::InitializationPolicy); | 45 ArrayBufferContents(unsigned numElements, unsigned elementByteSize, ArrayBuf
ferContents::InitializationPolicy); |
| 46 | 46 |
| 47 // Use with care. data must be allocated with allocateMemory. | |
| 48 // ArrayBufferContents will take ownership of the data and free it (using fr
eeMemorY) | |
| 49 // upon destruction. | |
| 50 ArrayBufferContents(void* data, unsigned sizeInBytes); | |
| 51 | |
| 52 ~ArrayBufferContents(); | 47 ~ArrayBufferContents(); |
| 53 | 48 |
| 54 void clear(); | 49 void clear(); |
| 55 | 50 |
| 56 void* data() const { return m_data; } | 51 void* data() const { return m_data; } |
| 57 unsigned sizeInBytes() const { return m_sizeInBytes; } | 52 unsigned sizeInBytes() const { return m_sizeInBytes; } |
| 58 | 53 |
| 59 bool hasDeallocationObserver() const { return !!m_deallocationObserver; } | 54 bool hasDeallocationObserver() const { return !!m_deallocationObserver; } |
| 60 void setDeallocationObserver(ArrayBufferDeallocationObserver* observer) { m_
deallocationObserver = observer; } | 55 void setDeallocationObserver(ArrayBufferDeallocationObserver* observer) { m_
deallocationObserver = observer; } |
| 61 | 56 |
| 62 void transfer(ArrayBufferContents& other); | 57 void transfer(ArrayBufferContents& other); |
| 63 | 58 |
| 64 static bool allocateMemory(size_t, InitializationPolicy, void*& data); | |
| 65 static void freeMemory(void* data); | |
| 66 | |
| 67 private: | 59 private: |
| 68 void* m_data; | 60 void* m_data; |
| 69 unsigned m_sizeInBytes; | 61 unsigned m_sizeInBytes; |
| 70 ArrayBufferDeallocationObserver* m_deallocationObserver; | 62 ArrayBufferDeallocationObserver* m_deallocationObserver; |
| 71 }; | 63 }; |
| 72 | 64 |
| 73 } // namespace WTF | 65 } // namespace WTF |
| 74 | 66 |
| 75 #endif // ArrayBufferContents_h | 67 #endif // ArrayBufferContents_h |
| OLD | NEW |