Chromium Code Reviews| Index: webkit/glue/glue_serialize.cc |
| =================================================================== |
| --- webkit/glue/glue_serialize.cc (revision 12361) |
| +++ webkit/glue/glue_serialize.cc (working copy) |
| @@ -45,8 +45,9 @@ |
| // data, but not vice versa. |
| // 3: Version 2 was broken, it stored number of UChars, not number of bytes. |
| // This version checks and reads v1 and v2 correctly. |
| +// 4: Adds support for storing FormData::identifier(). |
| // Should be const, but unit tests may modify it. |
| -int kVersion = 3; |
| +int kVersion = 4; |
| // A bunch of convenience functions to read/write to SerializeObjects. |
| // The serializers assume the input data is in the correct format and so does |
| @@ -81,6 +82,16 @@ |
| return tmp; |
| } |
| +inline void WriteInteger64(int64 data, SerializeObject* obj) { |
| + obj->pickle.WriteInt64(data); |
| +} |
| + |
| +inline int64 ReadInteger64(const SerializeObject* obj) { |
| + int64 tmp; |
|
sky
2009/03/24 20:34:40
should you set this to 0, just in case ReadInt64 f
darin (slow to review)
2009/03/24 21:12:15
Good idea!
|
| + obj->pickle.ReadInt64(&obj->iter, &tmp); |
| + return tmp; |
| +} |
| + |
| inline void WriteReal(double data, SerializeObject* obj) { |
| WriteData(&data, sizeof(double), obj); |
| } |
| @@ -124,8 +135,8 @@ |
| data.length() * sizeof(UChar)); |
| } |
| break; |
| - case 3: |
| - // Version 3 writes <length in bytes><string data>. |
| + default: |
| + // Version 3+ writes <length in bytes><string data>. |
| // It uses -1 in the length field to mean String(). |
| if (data.isNull()) { |
| obj->pickle.WriteInt(-1); |
| @@ -135,9 +146,6 @@ |
| data.length() * sizeof(UChar)); |
| } |
| break; |
| - default: |
| - NOTREACHED(); |
| - break; |
| } |
| } |
| @@ -199,6 +207,7 @@ |
| WriteString(e.m_filename, obj); |
| } |
| } |
| + WriteInteger64(form_data->identifier(), obj); |
| } |
| static PassRefPtr<FormData> ReadFormData(const SerializeObject* obj) { |
| @@ -219,6 +228,8 @@ |
| form_data->appendFile(ReadString(obj)); |
| } |
| } |
| + if (obj->version >= 4) |
| + form_data->setIdentifier(ReadInteger64(obj)); |
| return form_data.release(); |
| } |
| @@ -264,7 +275,7 @@ |
| // See note in WriteHistoryItem. on this. |
| obj->version = ReadInteger(obj); |
| - if (obj->version > kVersion) |
| + if (obj->version > kVersion || obj->version < 1) |
| return NULL; |
| RefPtr<HistoryItem> item = HistoryItem::create(); |