| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef); | 74 static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef); |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 // Calling this function will force internal segmented buffers | 77 // Calling this function will force internal segmented buffers |
| 78 // to be merged into a flat buffer. Use getSomeData() whenever possible | 78 // to be merged into a flat buffer. Use getSomeData() whenever possible |
| 79 // for better performance. | 79 // for better performance. |
| 80 const char* data() const; | 80 const char* data() const; |
| 81 | 81 |
| 82 unsigned size() const; | 82 unsigned size() const; |
| 83 | 83 |
| 84 // Calling this function will force internal segmented buffers | |
| 85 // to be merged into a flat buffer. Use getSomeData() whenever possible | |
| 86 // for better performance. | |
| 87 const Vector<char>& buffer() const; | |
| 88 | 84 |
| 89 bool isEmpty() const { return !size(); } | 85 bool isEmpty() const { return !size(); } |
| 90 | 86 |
| 91 void append(const char*, unsigned); | 87 void append(const char*, unsigned); |
| 92 void clear(); | 88 void clear(); |
| 93 const char* platformData() const; | 89 const char* platformData() const; |
| 94 unsigned platformDataSize() const; | 90 unsigned platformDataSize() const; |
| 95 | 91 |
| 96 PassRefPtr<SharedBuffer> copy() const; | 92 PassRefPtr<SharedBuffer> copy() const; |
| 97 | 93 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 112 // // Use the data. for example: decoder->decode(segment, length); | 108 // // Use the data. for example: decoder->decode(segment, length); |
| 113 // pos += length; | 109 // pos += length; |
| 114 // } | 110 // } |
| 115 unsigned getSomeData(const char*& data, unsigned position = 0) const; | 111 unsigned getSomeData(const char*& data, unsigned position = 0) const; |
| 116 | 112 |
| 117 private: | 113 private: |
| 118 SharedBuffer(); | 114 SharedBuffer(); |
| 119 SharedBuffer(const char*, int); | 115 SharedBuffer(const char*, int); |
| 120 SharedBuffer(const unsigned char*, int); | 116 SharedBuffer(const unsigned char*, int); |
| 121 | 117 |
| 118 // Calling this function will force internal segmented buffers |
| 119 // to be merged into a flat buffer. Use getSomeData() whenever possible |
| 120 // for better performance. |
| 121 // As well, be aware that this method does *not* return any purgeable |
| 122 // memory, which can be a source of bugs. |
| 123 const Vector<char>& buffer() const; |
| 124 |
| 122 void clearPlatformData(); | 125 void clearPlatformData(); |
| 123 void maybeTransferPlatformData(); | 126 void maybeTransferPlatformData(); |
| 124 bool hasPlatformData() const; | 127 bool hasPlatformData() const; |
| 125 | 128 |
| 126 unsigned m_size; | 129 unsigned m_size; |
| 127 mutable Vector<char> m_buffer; | 130 mutable Vector<char> m_buffer; |
| 128 mutable Vector<char*> m_segments; | 131 mutable Vector<char*> m_segments; |
| 129 OwnPtr<PurgeableBuffer> m_purgeableBuffer; | 132 OwnPtr<PurgeableBuffer> m_purgeableBuffer; |
| 130 #if PLATFORM(CF) | 133 #if PLATFORM(CF) |
| 131 SharedBuffer(CFDataRef); | 134 SharedBuffer(CFDataRef); |
| 132 RetainPtr<CFDataRef> m_cfData; | 135 RetainPtr<CFDataRef> m_cfData; |
| 133 #endif | 136 #endif |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 } | 139 } |
| 137 | 140 |
| 138 #endif // SharedBuffer_h | 141 #endif // SharedBuffer_h |
| OLD | NEW |