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 | |
51 // Returns a consecutive buffer that carries the data starting | 49 // Returns a consecutive buffer that carries the data starting |
52 // at |dataPosition| with |length| bytes. | 50 // at |dataPosition| with |length| bytes. |
53 // This method returns a pointer to a memory segment stored in | 51 // This method returns a pointer to a memory segment stored in |
54 // |m_data| if such a consecutive buffer can be found. | 52 // |m_data| if such a consecutive buffer can be found. |
55 // Otherwise copies into |buffer| and returns it. | 53 // Otherwise copies into |buffer| and returns it. |
56 // Caller must ensure there are enough bytes in |m_data| and |buffer|. | 54 // Caller must ensure there are enough bytes in |m_data| and |buffer|. |
57 const char* getConsecutiveData(size_t dataPosition, size_t length, char* buf
fer) const; | 55 const char* getConsecutiveData(size_t dataPosition, size_t length, char* buf
fer) const; |
58 | 56 |
59 // Wraps SharedBuffer::getSomeData(). | 57 // Wraps SharedBuffer::getSomeData(). |
60 size_t getSomeData(const char*& someData, size_t dataPosition) const; | 58 size_t getSomeData(const char*& someData, size_t dataPosition) const; |
(...skipping 20 matching lines...) Expand all Loading... |
81 mutable const char* m_segment; | 79 mutable const char* m_segment; |
82 mutable size_t m_segmentLength; | 80 mutable size_t m_segmentLength; |
83 | 81 |
84 // Data position in |m_data| pointed to by |m_segment|. | 82 // Data position in |m_data| pointed to by |m_segment|. |
85 mutable size_t m_dataPosition; | 83 mutable size_t m_dataPosition; |
86 }; | 84 }; |
87 | 85 |
88 } // namespace blink | 86 } // namespace blink |
89 | 87 |
90 #endif | 88 #endif |
OLD | NEW |