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 "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 << "might be running against an out-of-date server."; | 44 << "might be running against an out-of-date server."; |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 base::JSONReader reader; | 48 base::JSONReader reader; |
49 for (std::set<std::wstring>::iterator it = synced_preferences_.begin(); | 49 for (std::set<std::wstring>::iterator it = synced_preferences_.begin(); |
50 it != synced_preferences_.end(); ++it) { | 50 it != synced_preferences_.end(); ++it) { |
51 std::string tag = WideToUTF8(*it); | 51 std::string tag = WideToUTF8(*it); |
52 | 52 |
53 sync_api::ReadNode node(&trans); | 53 sync_api::ReadNode node(&trans); |
54 if (node.InitByClientTagLookup(tag)) { | 54 if (node.InitByClientTagLookup(syncable::PREFERENCES, tag)) { |
55 const sync_pb::PreferenceSpecifics& preference( | 55 const sync_pb::PreferenceSpecifics& preference( |
56 node.GetPreferenceSpecifics()); | 56 node.GetPreferenceSpecifics()); |
57 DCHECK_EQ(tag, preference.name()); | 57 DCHECK_EQ(tag, preference.name()); |
58 | 58 |
59 scoped_ptr<Value> value( | 59 scoped_ptr<Value> value( |
60 reader.JsonToValue(preference.value(), false, false)); | 60 reader.JsonToValue(preference.value(), false, false)); |
61 std::wstring pref_name = UTF8ToWide(preference.name()); | 61 std::wstring pref_name = UTF8ToWide(preference.name()); |
62 if (!value.get()) { | 62 if (!value.get()) { |
63 LOG(ERROR) << "Failed to deserialize preference value: " | 63 LOG(ERROR) << "Failed to deserialize preference value: " |
64 << reader.error_message(); | 64 << reader.error_message(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 sync_service_->OnUnrecoverableError(); | 214 sync_service_->OnUnrecoverableError(); |
215 return; | 215 return; |
216 } | 216 } |
217 // TODO(sync): Make ExternalId a string? | 217 // TODO(sync): Make ExternalId a string? |
218 // sync_node.SetExternalId(id_map_inverse_[*iter]); | 218 // sync_node.SetExternalId(id_map_inverse_[*iter]); |
219 } | 219 } |
220 dirty_associations_sync_ids_.clear(); | 220 dirty_associations_sync_ids_.clear(); |
221 } | 221 } |
222 | 222 |
223 } // namespace browser_sync | 223 } // namespace browser_sync |
OLD | NEW |