Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/sync/glue/preference_model_associator.cc

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/preference_change_processor.cc ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698