Commit e67ce755 authored by mnissler@chromium.org's avatar mnissler@chromium.org

Handle sync values of wrong type more graceful.

Clear prefs that the server reports TYPE_NULL values for and log a warning if the type is off otherwise.

BUG=none
TEST=compiles and passes tests

Review URL: http://codereview.chromium.org/6288016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72786 0039d316-1c4b-4281-b951-d872f2087c98
parent 934c6e54
......@@ -73,8 +73,15 @@ bool PreferenceModelAssociator::InitPrefNodeAndAssociate(
// Update the local preference based on what we got from the
// sync server.
if (!pref->GetValue()->Equals(new_value.get()))
if (new_value->IsType(Value::TYPE_NULL)) {
pref_service->ClearPref(pref_name.c_str());
} else if (!new_value->IsType(pref->GetType())) {
LOG(WARNING) << "Synced value for " << preference.name()
<< " is of type " << new_value->GetType()
<< " which doesn't match pref type " << pref->GetType();
} else if (!pref->GetValue()->Equals(new_value.get())) {
pref_service->Set(pref_name.c_str(), *new_value);
}
AfterUpdateOperations(pref_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment