Chromium Code Reviews| Index: components/autofill/core/common/form_field_data.cc |
| diff --git a/components/autofill/core/common/form_field_data.cc b/components/autofill/core/common/form_field_data.cc |
| index 3b80be255c4e99ea5f8e181842b5060e5a7f7336..94c6c7198160bcc15aec8f7d1264495aa2294231 100644 |
| --- a/components/autofill/core/common/form_field_data.cc |
| +++ b/components/autofill/core/common/form_field_data.cc |
| @@ -10,7 +10,9 @@ |
| namespace { |
| -const int kPickleVersion = 1; |
| +// Increment this anytime pickle format is modified as well as provide |
| +// deserialization routine from previous kPickleVersion format. |
| +const int kPickleVersion = 2; |
| void AddVectorToPickle(std::vector<base::string16> strings, |
| Pickle* pickle) { |
| @@ -37,12 +39,12 @@ bool ReadStringVector(PickleIterator* iter, |
| } |
| template <typename T> |
| -bool ReadAsInt(PickleIterator* iter, T* direction) { |
| +bool ReadAsInt(PickleIterator* iter, T* target_value) { |
| int pickle_data; |
| if (!iter->ReadInt(&pickle_data)) |
| return false; |
| - *direction = static_cast<T>(pickle_data); |
| + *target_value = static_cast<T>(pickle_data); |
| return true; |
| } |
| @@ -156,6 +158,26 @@ bool DeserializeFormFieldData(PickleIterator* iter, |
| !iter->ReadBool(&field_data->is_checkable) || |
| !iter->ReadBool(&field_data->is_focusable) || |
| !iter->ReadBool(&field_data->should_autocomplete) || |
| + !ReadAsInt(iter, &field_data->text_direction) || |
| + !ReadStringVector(iter, &field_data->option_values) || |
| + !ReadStringVector(iter, &field_data->option_contents)) { |
| + LOG(ERROR) << "Could not deserialize FormFieldData from pickle"; |
| + return false; |
| + } |
| + break; |
| + } |
| + case 2: { |
| + if (!iter->ReadString16(&field_data->label) || |
| + !iter->ReadString16(&field_data->name) || |
| + !iter->ReadString16(&field_data->value) || |
| + !iter->ReadString(&field_data->form_control_type) || |
| + !iter->ReadString(&field_data->autocomplete_attribute) || |
| + !iter->ReadSizeT(&field_data->max_length) || |
| + !iter->ReadBool(&field_data->is_autofilled) || |
| + !iter->ReadBool(&field_data->is_checked) || |
| + !iter->ReadBool(&field_data->is_checkable) || |
| + !iter->ReadBool(&field_data->is_focusable) || |
| + !iter->ReadBool(&field_data->should_autocomplete) || |
| !ReadAsInt(iter, &field_data->role) || |
|
Lei Zhang
2015/01/23 06:43:01
I wish you put "role" at the end, so (de)serializi
|
| !ReadAsInt(iter, &field_data->text_direction) || |
| !ReadStringVector(iter, &field_data->option_values) || |