summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 01:41:26 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 01:41:26 +0000
commit7af60c5bcc6456545324a676bcfce381210620ac (patch)
treead46b25305f414fd9c7868b751fed439d356b20d /chrome/browser
parentde5bc35e8c0835ba223c3ffcda1099e50f708274 (diff)
downloadchromium_src-7af60c5bcc6456545324a676bcfce381210620ac.zip
chromium_src-7af60c5bcc6456545324a676bcfce381210620ac.tar.gz
chromium_src-7af60c5bcc6456545324a676bcfce381210620ac.tar.bz2
Made ThemeChangeProcessor handle multiple updates to work around
a problem with the syncapi. BUG=41439 TEST=manual Review URL: http://codereview.chromium.org/1622030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/sync/glue/theme_change_processor.cc45
1 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/sync/glue/theme_change_processor.cc b/chrome/browser/sync/glue/theme_change_processor.cc
index 01cebfb..ec61f65 100644
--- a/chrome/browser/sync/glue/theme_change_processor.cc
+++ b/chrome/browser/sync/glue/theme_change_processor.cc
@@ -138,28 +138,41 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel(
if (!running()) {
return;
}
- StopObserving();
- if (change_count != 1) {
- LOG(ERROR) << "Unexpected number of theme changes";
+ // TODO(akalin): Normally, we should only have a single change and
+ // it should be an update. However, the syncapi may occasionally
+ // generates multiple changes. When we fix syncapi to not do that,
+ // we can remove the extra logic below. See:
+ // http://code.google.com/p/chromium/issues/detail?id=41696 .
+ if (change_count < 1) {
+ LOG(ERROR) << "Unexpected change_count: " << change_count;
error_handler()->OnUnrecoverableError();
return;
}
- const sync_api::SyncManager::ChangeRecord& change = changes[0];
+ if (change_count > 1) {
+ LOG(WARNING) << change_count << " theme changes detected; "
+ << "only applying the last one";
+ }
+ const sync_api::SyncManager::ChangeRecord& change =
+ changes[change_count - 1];
if (change.action != sync_api::SyncManager::ChangeRecord::ACTION_UPDATE) {
- LOG(ERROR) << "Unexpected change.action " << change.action;
- error_handler()->OnUnrecoverableError();
- return;
+ LOG(WARNING) << "strange theme change.action: " << change.action;
}
- sync_api::ReadNode node(trans);
- if (!node.InitByIdLookup(change.id)) {
- LOG(ERROR) << "Theme node lookup failed";
- error_handler()->OnUnrecoverableError();
- return;
+ sync_pb::ThemeSpecifics theme_specifics;
+ // If the action is a delete, simply use the default values for
+ // ThemeSpecifics, which would cause the default theme to be set.
+ if (change.action != sync_api::SyncManager::ChangeRecord::ACTION_DELETE) {
+ sync_api::ReadNode node(trans);
+ if (!node.InitByIdLookup(change.id)) {
+ LOG(ERROR) << "Theme node lookup failed";
+ error_handler()->OnUnrecoverableError();
+ return;
+ }
+ DCHECK_EQ(node.GetModelType(), syncable::THEMES);
+ DCHECK(profile_);
+ theme_specifics = node.GetThemeSpecifics();
}
- DCHECK_EQ(node.GetModelType(), syncable::THEMES);
- DCHECK(profile_);
- SetCurrentThemeFromThemeSpecificsIfNecessary(
- node.GetThemeSpecifics(), profile_);
+ StopObserving();
+ SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, profile_);
StartObserving();
}