OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 27 matching lines...) Loading... |
38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class SharedBuffer; | 42 class SharedBuffer; |
43 | 43 |
44 class PLATFORM_EXPORT SharedBufferChunkReader final { | 44 class PLATFORM_EXPORT SharedBufferChunkReader final { |
45 DISALLOW_NEW(); | 45 DISALLOW_NEW(); |
46 WTF_MAKE_NONCOPYABLE(SharedBufferChunkReader); | 46 WTF_MAKE_NONCOPYABLE(SharedBufferChunkReader); |
47 public: | 47 public: |
48 SharedBufferChunkReader(SharedBuffer*, const Vector<char>& separator); | 48 SharedBufferChunkReader(PassRefPtr<SharedBuffer>, const Vector<char>& separa
tor); |
49 SharedBufferChunkReader(SharedBuffer*, const char* separator); | 49 SharedBufferChunkReader(PassRefPtr<SharedBuffer>, const char* separator); |
50 | 50 |
51 void setSeparator(const Vector<char>&); | 51 void setSeparator(const Vector<char>&); |
52 void setSeparator(const char*); | 52 void setSeparator(const char*); |
53 | 53 |
54 // Returns false when the end of the buffer was reached. | 54 // Returns false when the end of the buffer was reached. |
55 bool nextChunk(Vector<char>& data, bool includeSeparator = false); | 55 bool nextChunk(Vector<char>& data, bool includeSeparator = false); |
56 | 56 |
57 // Returns a null string when the end of the buffer has been reached. | 57 // Returns a null string when the end of the buffer has been reached. |
58 String nextChunkAsUTF8StringWithLatin1Fallback(bool includeSeparator = false
); | 58 String nextChunkAsUTF8StringWithLatin1Fallback(bool includeSeparator = false
); |
59 | 59 |
60 // Reads size bytes at the current location in the buffer, without changing
the buffer position. | 60 // Reads size bytes at the current location in the buffer, without changing
the buffer position. |
61 // Returns the number of bytes read. That number might be less than the spec
ified size if the end of the buffer was reached. | 61 // Returns the number of bytes read. That number might be less than the spec
ified size if the end of the buffer was reached. |
62 size_t peek(Vector<char>&, size_t); | 62 size_t peek(Vector<char>&, size_t); |
63 | 63 |
64 private: | 64 private: |
65 SharedBuffer* m_buffer; | 65 RefPtr<SharedBuffer> m_buffer; |
66 size_t m_bufferPosition; | 66 size_t m_bufferPosition; |
67 const char* m_segment; | 67 const char* m_segment; |
68 size_t m_segmentLength; | 68 size_t m_segmentLength; |
69 size_t m_segmentIndex; | 69 size_t m_segmentIndex; |
70 bool m_reachedEndOfFile; | 70 bool m_reachedEndOfFile; |
71 Vector<char> m_separator; | 71 Vector<char> m_separator; |
72 size_t m_separatorIndex; | 72 size_t m_separatorIndex; |
73 }; | 73 }; |
74 | 74 |
75 } // namespace blink | 75 } // namespace blink |
76 | 76 |
77 #endif | 77 #endif |
OLD | NEW |