| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 // This class is used by image decoders to avoid memory consolidation and | 41 // This class is used by image decoders to avoid memory consolidation and |
| 42 // therefore minimizes the cost of memory copying when the decoders | 42 // therefore minimizes the cost of memory copying when the decoders |
| 43 // repeatedly read from a buffer that is continually growing due to network | 43 // repeatedly read from a buffer that is continually growing due to network |
| 44 // traffic. | 44 // traffic. |
| 45 class PLATFORM_EXPORT FastSharedBufferReader { | 45 class PLATFORM_EXPORT FastSharedBufferReader { |
| 46 public: | 46 public: |
| 47 FastSharedBufferReader(PassRefPtr<SharedBuffer> data); | 47 FastSharedBufferReader(PassRefPtr<SharedBuffer> data); |
| 48 | 48 |
| 49 void setData(PassRefPtr<SharedBuffer>); |
| 50 |
| 49 // Returns a consecutive buffer that carries the data starting | 51 // Returns a consecutive buffer that carries the data starting |
| 50 // at |dataPosition| with |length| bytes. | 52 // at |dataPosition| with |length| bytes. |
| 51 // This method returns a pointer to a memory segment stored in | 53 // This method returns a pointer to a memory segment stored in |
| 52 // |m_data| if such a consecutive buffer can be found. | 54 // |m_data| if such a consecutive buffer can be found. |
| 53 // Otherwise copies into |buffer| and returns it. | 55 // Otherwise copies into |buffer| and returns it. |
| 54 // Caller must ensure there are enough bytes in |m_data| and |buffer|. | 56 // Caller must ensure there are enough bytes in |m_data| and |buffer|. |
| 55 const char* getConsecutiveData(size_t dataPosition, size_t length, char* buf
fer); | 57 const char* getConsecutiveData(size_t dataPosition, size_t length, char* buf
fer); |
| 56 | 58 |
| 57 // Wraps SharedBuffer::getSomeData(). | 59 // Wraps SharedBuffer::getSomeData(). |
| 58 size_t getSomeData(const char*& someData, size_t dataPosition); | 60 size_t getSomeData(const char*& someData, size_t dataPosition); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 79 const char* m_segment; | 81 const char* m_segment; |
| 80 size_t m_segmentLength; | 82 size_t m_segmentLength; |
| 81 | 83 |
| 82 // Data position in |m_data| pointed to by |m_segment|. | 84 // Data position in |m_data| pointed to by |m_segment|. |
| 83 size_t m_dataPosition; | 85 size_t m_dataPosition; |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 } // namespace blink | 88 } // namespace blink |
| 87 | 89 |
| 88 #endif | 90 #endif |
| OLD | NEW |