| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 305 } |
| 306 ASSERT(position == clone->size()); | 306 ASSERT(position == clone->size()); |
| 307 } | 307 } |
| 308 return clone.release(); | 308 return clone.release(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void SharedBuffer::mergeSegmentsIntoBuffer() const | 311 void SharedBuffer::mergeSegmentsIntoBuffer() const |
| 312 { | 312 { |
| 313 unsigned bufferSize = m_buffer.size(); | 313 unsigned bufferSize = m_buffer.size(); |
| 314 if (m_size > bufferSize) { | 314 if (m_size > bufferSize) { |
| 315 m_buffer.reserveCapacity(m_size); | |
| 316 unsigned bytesLeft = m_size - bufferSize; | 315 unsigned bytesLeft = m_size - bufferSize; |
| 317 for (unsigned i = 0; i < m_segments.size(); ++i) { | 316 for (unsigned i = 0; i < m_segments.size(); ++i) { |
| 318 unsigned bytesToCopy = std::min(bytesLeft, segmentSize); | 317 unsigned bytesToCopy = std::min(bytesLeft, segmentSize); |
| 319 m_buffer.append(m_segments[i], bytesToCopy); | 318 m_buffer.append(m_segments[i], bytesToCopy); |
| 320 bytesLeft -= bytesToCopy; | 319 bytesLeft -= bytesToCopy; |
| 321 freeSegment(m_segments[i]); | 320 freeSegment(m_segments[i]); |
| 322 } | 321 } |
| 323 m_segments.clear(); | 322 m_segments.clear(); |
| 324 } | 323 } |
| 325 } | 324 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 mergeSegmentsIntoBuffer(); | 406 mergeSegmentsIntoBuffer(); |
| 408 m_buffer.unlock(); | 407 m_buffer.unlock(); |
| 409 } | 408 } |
| 410 | 409 |
| 411 bool SharedBuffer::isLocked() const | 410 bool SharedBuffer::isLocked() const |
| 412 { | 411 { |
| 413 return m_buffer.isLocked(); | 412 return m_buffer.isLocked(); |
| 414 } | 413 } |
| 415 | 414 |
| 416 } // namespace blink | 415 } // namespace blink |
| OLD | NEW |