summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authoralbertb@google.com <albertb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:04:38 +0000
committeralbertb@google.com <albertb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:04:38 +0000
commitafd22b28ea27824638b134dc2451079dd67fd909 (patch)
treedbcd0d197163ccf8ba0427b864561aa902d5e9a8 /chrome/browser/sync
parentb490a67b695991d21113a71322e7c204081beaaa (diff)
downloadchromium_src-afd22b28ea27824638b134dc2451079dd67fd909.zip
chromium_src-afd22b28ea27824638b134dc2451079dd67fd909.tar.gz
chromium_src-afd22b28ea27824638b134dc2451079dd67fd909.tar.bz2
When creating preference sync node, set the node title to the name of the
preference. BUG=none TEST=unit tests Review URL: http://codereview.chromium.org/661113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/glue/preference_change_processor.cc8
-rw-r--r--chrome/browser/sync/glue/preference_change_processor.h2
-rw-r--r--chrome/browser/sync/glue/preference_model_associator.cc1
-rw-r--r--chrome/browser/sync/profile_sync_service_preference_unittest.cc4
4 files changed, 9 insertions, 6 deletions
diff --git a/chrome/browser/sync/glue/preference_change_processor.cc b/chrome/browser/sync/glue/preference_change_processor.cc
index 6c79c9b..4f86c75 100644
--- a/chrome/browser/sync/glue/preference_change_processor.cc
+++ b/chrome/browser/sync/glue/preference_change_processor.cc
@@ -54,8 +54,7 @@ void PreferenceChangeProcessor::Observe(NotificationType type,
}
}
- if (!WritePreference(&node, WideToUTF8(*name),
- preference->GetValue())) {
+ if (!WritePreference(&node, *name, preference->GetValue())) {
LOG(ERROR) << "Failed to update preference node.";
error_handler()->OnUnrecoverableError();
return;
@@ -108,7 +107,7 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel(
bool PreferenceChangeProcessor::WritePreference(
sync_api::WriteNode* node,
- const std::string& name,
+ const std::wstring& name,
const Value* value) {
std::string serialized;
JSONStringValueSerializer json(&serialized);
@@ -119,9 +118,10 @@ bool PreferenceChangeProcessor::WritePreference(
}
sync_pb::PreferenceSpecifics preference;
- preference.set_name(name);
+ preference.set_name(WideToUTF8(name));
preference.set_value(serialized);
node->SetPreferenceSpecifics(preference);
+ node->SetTitle(name);
return true;
}
diff --git a/chrome/browser/sync/glue/preference_change_processor.h b/chrome/browser/sync/glue/preference_change_processor.h
index dbd548a..eaae008 100644
--- a/chrome/browser/sync/glue/preference_change_processor.h
+++ b/chrome/browser/sync/glue/preference_change_processor.h
@@ -45,7 +45,7 @@ class PreferenceChangeProcessor : public ChangeProcessor,
private:
bool WritePreference(sync_api::WriteNode* node,
- const std::string& name,
+ const std::wstring& name,
const Value* value);
Value* ReadPreference(sync_api::ReadNode* node, std::string* name);
diff --git a/chrome/browser/sync/glue/preference_model_associator.cc b/chrome/browser/sync/glue/preference_model_associator.cc
index dece295..bb75707 100644
--- a/chrome/browser/sync/glue/preference_model_associator.cc
+++ b/chrome/browser/sync/glue/preference_model_associator.cc
@@ -111,6 +111,7 @@ bool PreferenceModelAssociator::AssociateModels() {
preference.set_name(tag);
preference.set_value(serialized);
node.SetPreferenceSpecifics(preference);
+ node.SetTitle(*it);
Associate(pref, node.GetId());
}
}
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
index a451988..579ab4f 100644
--- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
@@ -26,7 +26,7 @@ using sync_api::SyncManager;
class TestPreferenceModelAssociator
: public TestModelAssociator<PreferenceModelAssociator> {
public:
- TestPreferenceModelAssociator(ProfileSyncService* service)
+ explicit TestPreferenceModelAssociator(ProfileSyncService* service)
: TestModelAssociator<PreferenceModelAssociator>(service) {
}
};
@@ -87,6 +87,7 @@ class ProfileSyncServicePreferenceTest : public testing::Test {
int64 node_id = model_associator_->GetSyncIdFromChromeId(name);
EXPECT_NE(sync_api::kInvalidId, node_id);
EXPECT_TRUE(node.InitByIdLookup(node_id));
+ EXPECT_EQ(name, node.GetTitle());
const sync_pb::PreferenceSpecifics& specifics(
node.GetPreferenceSpecifics());
@@ -113,6 +114,7 @@ class ProfileSyncServicePreferenceTest : public testing::Test {
preference.set_name(WideToUTF8(name));
preference.set_value(serialized);
node.SetPreferenceSpecifics(preference);
+ node.SetTitle(name);
SyncManager::ChangeRecord* record = new SyncManager::ChangeRecord();
record->action = SyncManager::ChangeRecord::ACTION_UPDATE;