Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: Source/WebCore/platform/SharedBuffer.cpp

Issue 11316005: Merge 131315 - Calling WebCore::SharedBuffer::append(data, 0) on a shared buffer when (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/mhtml/shared_buffer_bug-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « LayoutTests/mhtml/shared_buffer_bug-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698