| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 size_t position = 0; | 140 size_t position = 0; |
| 141 while (size_t length = data->getSomeData(segment, position)) { | 141 while (size_t length = data->getSomeData(segment, position)) { |
| 142 append(segment, length); | 142 append(segment, length); |
| 143 position += length; | 143 position += length; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void SharedBuffer::append(const char* data, unsigned length) | 147 void SharedBuffer::append(const char* data, unsigned length) |
| 148 { | 148 { |
| 149 ASSERT(!m_purgeableBuffer); | 149 ASSERT(!m_purgeableBuffer); |
| 150 if (!length) |
| 151 return; |
| 150 | 152 |
| 151 maybeTransferPlatformData(); | 153 maybeTransferPlatformData(); |
| 152 | 154 |
| 153 unsigned positionInSegment = offsetInSegment(m_size - m_buffer.size()); | 155 unsigned positionInSegment = offsetInSegment(m_size - m_buffer.size()); |
| 154 m_size += length; | 156 m_size += length; |
| 155 | 157 |
| 156 if (m_size <= segmentSize) { | 158 if (m_size <= segmentSize) { |
| 157 // No need to use segments for small resource data | 159 // No need to use segments for small resource data |
| 158 m_buffer.append(data, length); | 160 m_buffer.append(data, length); |
| 159 return; | 161 return; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 const UChar* d = string.characters(); | 345 const UChar* d = string.characters(); |
| 344 WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d,
d + length, &p, p + buffer.size(), true); | 346 WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d,
d + length, &p, p + buffer.size(), true); |
| 345 if (result != WTF::Unicode::conversionOK) | 347 if (result != WTF::Unicode::conversionOK) |
| 346 return 0; | 348 return 0; |
| 347 | 349 |
| 348 buffer.shrink(p - buffer.data()); | 350 buffer.shrink(p - buffer.data()); |
| 349 return SharedBuffer::adoptVector(buffer); | 351 return SharedBuffer::adoptVector(buffer); |
| 350 } | 352 } |
| 351 | 353 |
| 352 } // namespace WebCore | 354 } // namespace WebCore |
| OLD | NEW |