OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/glue/preference_model_associator.h" | 5 #include "chrome/browser/sync/glue/preference_model_associator.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (node.InitByClientTagLookup(syncable::PREFERENCES, tag)) { | 77 if (node.InitByClientTagLookup(syncable::PREFERENCES, tag)) { |
78 const sync_pb::PreferenceSpecifics& preference( | 78 const sync_pb::PreferenceSpecifics& preference( |
79 node.GetPreferenceSpecifics()); | 79 node.GetPreferenceSpecifics()); |
80 DCHECK_EQ(tag, preference.name()); | 80 DCHECK_EQ(tag, preference.name()); |
81 | 81 |
82 scoped_ptr<Value> value( | 82 scoped_ptr<Value> value( |
83 reader.JsonToValue(preference.value(), false, false)); | 83 reader.JsonToValue(preference.value(), false, false)); |
84 std::wstring pref_name = UTF8ToWide(preference.name()); | 84 std::wstring pref_name = UTF8ToWide(preference.name()); |
85 if (!value.get()) { | 85 if (!value.get()) { |
86 LOG(ERROR) << "Failed to deserialize preference value: " | 86 LOG(ERROR) << "Failed to deserialize preference value: " |
87 << reader.error_message(); | 87 << reader.GetErrorMessage(); |
88 error_handler_->OnUnrecoverableError(); | 88 error_handler_->OnUnrecoverableError(); |
89 return false; | 89 return false; |
90 } | 90 } |
91 | 91 |
92 // Update the local preference based on what we got from the sync server. | 92 // Update the local preference based on what we got from the sync server. |
93 pref_service->Set(pref_name.c_str(), *value); | 93 pref_service->Set(pref_name.c_str(), *value); |
94 Associate(pref, node.GetId()); | 94 Associate(pref, node.GetId()); |
95 } else { | 95 } else { |
96 sync_api::WriteNode node(&trans); | 96 sync_api::WriteNode node(&trans); |
97 if (!node.InitUniqueByCreation(syncable::PREFERENCES, root, tag)) { | 97 if (!node.InitUniqueByCreation(syncable::PREFERENCES, root, tag)) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 sync_api::ReadTransaction trans( | 189 sync_api::ReadTransaction trans( |
190 sync_service_->backend()->GetUserShareHandle()); | 190 sync_service_->backend()->GetUserShareHandle()); |
191 sync_api::ReadNode sync_node(&trans); | 191 sync_api::ReadNode sync_node(&trans); |
192 if (!sync_node.InitByTagLookup(tag.c_str())) | 192 if (!sync_node.InitByTagLookup(tag.c_str())) |
193 return false; | 193 return false; |
194 *sync_id = sync_node.GetId(); | 194 *sync_id = sync_node.GetId(); |
195 return true; | 195 return true; |
196 } | 196 } |
197 | 197 |
198 } // namespace browser_sync | 198 } // namespace browser_sync |
OLD | NEW |