diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 21:45:30 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 21:45:30 +0000 |
commit | f480367d1f52722c41fd2c8f7b79084088356b34 (patch) | |
tree | 9f5d8c74f955ed2b51875f3d41e986ee1f16a7b0 /webkit/glue/glue_serialize.cc | |
parent | 6ad4293c3bec41942397436dc54a5b764d014521 (diff) | |
download | chromium_src-f480367d1f52722c41fd2c8f7b79084088356b34.zip chromium_src-f480367d1f52722c41fd2c8f7b79084088356b34.tar.gz chromium_src-f480367d1f52722c41fd2c8f7b79084088356b34.tar.bz2 |
Add support for serializing a FormData structure that has no elements. This is
important for supporting cached form submissions of empty data, which occurs
with some sites like Gmail.
R=sky
Review URL: http://codereview.chromium.org/56011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/glue_serialize.cc')
-rw-r--r-- | webkit/glue/glue_serialize.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index 60eab9f9..0850e1b 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -46,8 +46,9 @@ struct SerializeObject { // 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(). +// 5: Adds support for empty FormData // Should be const, but unit tests may modify it. -int kVersion = 4; +int kVersion = 5; // A bunch of convenience functions to read/write to SerializeObjects. // The serializers assume the input data is in the correct format and so does @@ -191,10 +192,10 @@ static void ReadStringVector(const SerializeObject* obj, Vector<String>* data) { // Writes a FormData object into a SerializeObject for serialization. static void WriteFormData(const FormData* form_data, SerializeObject* obj) { - if (form_data == NULL) { - WriteInteger(0, obj); + WriteBoolean(form_data != NULL, obj); + + if (!form_data) return; - } WriteInteger(static_cast<int>(form_data->elements().size()), obj); for (size_t i = 0, c = form_data->elements().size(); i < c; ++i) { @@ -211,8 +212,13 @@ static void WriteFormData(const FormData* form_data, SerializeObject* obj) { } static PassRefPtr<FormData> ReadFormData(const SerializeObject* obj) { + // In newer versions, an initial boolean indicates if we have form data. + if (obj->version >= 5 && !ReadBoolean(obj)) + return NULL; + + // In older versions, 0 elements implied no form data. int num_elements = ReadInteger(obj); - if (num_elements == 0) + if (num_elements == 0 && obj->version < 5) return NULL; RefPtr<FormData> form_data = FormData::create(); |