OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return m_serializedData.data() + dataStart; | 72 return m_serializedData.data() + dataStart; |
73 } | 73 } |
74 | 74 |
75 size_t size() const | 75 size_t size() const |
76 { | 76 { |
77 if (m_serializedData.size() < dataStart) | 77 if (m_serializedData.size() < dataStart) |
78 return 0; | 78 return 0; |
79 return m_serializedData.size() - dataStart; | 79 return m_serializedData.size() - dataStart; |
80 } | 80 } |
81 | 81 |
82 void reportMemoryUsage(MemoryObjectInfo*) const; | |
83 | |
84 private: | 82 private: |
85 // Reads an unsigned value at position. Returns 0 on error. | 83 // Reads an unsigned value at position. Returns 0 on error. |
86 unsigned readUnsigned(size_t position) const | 84 unsigned readUnsigned(size_t position) const |
87 { | 85 { |
88 if (m_serializedData.size() < position + sizeof(unsigned)) | 86 if (m_serializedData.size() < position + sizeof(unsigned)) |
89 return 0; | 87 return 0; |
90 return *reinterpret_cast_ptr<unsigned*>(const_cast<char*>(m_serializedDa
ta.data() + position)); | 88 return *reinterpret_cast_ptr<unsigned*>(const_cast<char*>(m_serializedDa
ta.data() + position)); |
91 } | 89 } |
92 | 90 |
93 // Appends an unsigned value to the end of the serialized data. | 91 // Appends an unsigned value to the end of the serialized data. |
(...skipping 25 matching lines...) Expand all Loading... |
119 static const size_t dataStart = sizeof(unsigned); | 117 static const size_t dataStart = sizeof(unsigned); |
120 | 118 |
121 // Since the serialization format supports random access, storing it in | 119 // Since the serialization format supports random access, storing it in |
122 // serialized form avoids need for a copy during serialization. | 120 // serialized form avoids need for a copy during serialization. |
123 Vector<char> m_serializedData; | 121 Vector<char> m_serializedData; |
124 }; | 122 }; |
125 | 123 |
126 } | 124 } |
127 | 125 |
128 #endif | 126 #endif |
OLD | NEW |