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

Side by Side Diff: chrome/browser/themes/theme_syncable_service.cc

Issue 15701022: [Sync] Add support for sync Persistence Errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move bookmark change into separate patch Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/themes/theme_syncable_service.h" 5 #include "chrome/browser/themes/theme_syncable_service.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return list; 128 return list;
129 } 129 }
130 130
131 syncer::SyncError ThemeSyncableService::ProcessSyncChanges( 131 syncer::SyncError ThemeSyncableService::ProcessSyncChanges(
132 const tracked_objects::Location& from_here, 132 const tracked_objects::Location& from_here,
133 const syncer::SyncChangeList& change_list) { 133 const syncer::SyncChangeList& change_list) {
134 DCHECK(thread_checker_.CalledOnValidThread()); 134 DCHECK(thread_checker_.CalledOnValidThread());
135 135
136 if (!sync_processor_.get()) { 136 if (!sync_processor_.get()) {
137 return syncer::SyncError(FROM_HERE, 137 return syncer::SyncError(FROM_HERE,
138 syncer::SyncError::DATATYPE_ERROR,
138 "Theme syncable service is not started.", 139 "Theme syncable service is not started.",
139 syncer::THEMES); 140 syncer::THEMES);
140 } 141 }
141 142
142 // TODO(akalin): Normally, we should only have a single change and 143 // TODO(akalin): Normally, we should only have a single change and
143 // it should be an update. However, the syncapi may occasionally 144 // it should be an update. However, the syncapi may occasionally
144 // generates multiple changes. When we fix syncapi to not do that, 145 // generates multiple changes. When we fix syncapi to not do that,
145 // we can remove the extra logic below. See: 146 // we can remove the extra logic below. See:
146 // http://code.google.com/p/chromium/issues/detail?id=41696 . 147 // http://code.google.com/p/chromium/issues/detail?id=41696 .
147 if (change_list.size() != 1) { 148 if (change_list.size() != 1) {
(...skipping 25 matching lines...) Expand all
173 ++theme_change) { 174 ++theme_change) {
174 if (theme_change->sync_data().GetSpecifics().has_theme() && 175 if (theme_change->sync_data().GetSpecifics().has_theme() &&
175 (theme_change->change_type() == syncer::SyncChange::ACTION_ADD || 176 (theme_change->change_type() == syncer::SyncChange::ACTION_ADD ||
176 theme_change->change_type() == syncer::SyncChange::ACTION_UPDATE)) { 177 theme_change->change_type() == syncer::SyncChange::ACTION_UPDATE)) {
177 MaybeSetTheme(current_specifics, theme_change->sync_data()); 178 MaybeSetTheme(current_specifics, theme_change->sync_data());
178 return syncer::SyncError(); 179 return syncer::SyncError();
179 } 180 }
180 } 181 }
181 182
182 return syncer::SyncError(FROM_HERE, 183 return syncer::SyncError(FROM_HERE,
183 base::StringPrintf( 184 syncer::SyncError::DATATYPE_ERROR,
184 "Didn't find valid theme specifics."), 185 "Didn't find valid theme specifics",
185 syncer::THEMES); 186 syncer::THEMES);
186 } 187 }
187 188
188 void ThemeSyncableService::MaybeSetTheme( 189 void ThemeSyncableService::MaybeSetTheme(
189 const sync_pb::ThemeSpecifics& current_specs, 190 const sync_pb::ThemeSpecifics& current_specs,
190 const syncer::SyncData& sync_data) { 191 const syncer::SyncData& sync_data) {
191 const sync_pb::ThemeSpecifics& sync_theme = sync_data.GetSpecifics().theme(); 192 const sync_pb::ThemeSpecifics& sync_theme = sync_data.GetSpecifics().theme();
192 use_system_theme_by_default_ = sync_theme.use_system_theme_by_default(); 193 use_system_theme_by_default_ = sync_theme.use_system_theme_by_default();
193 DVLOG(1) << "Set current theme from specifics: " << sync_data.ToString(); 194 DVLOG(1) << "Set current theme from specifics: " << sync_data.ToString();
194 if (!AreThemeSpecificsEqual(current_specs, sync_theme, 195 if (!AreThemeSpecificsEqual(current_specs, sync_theme,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 syncer::SyncChange(FROM_HERE, change_type, 330 syncer::SyncChange(FROM_HERE, change_type,
330 syncer::SyncData::CreateLocalData( 331 syncer::SyncData::CreateLocalData(
331 kCurrentThemeClientTag, kCurrentThemeNodeTitle, 332 kCurrentThemeClientTag, kCurrentThemeNodeTitle,
332 entity_specifics))); 333 entity_specifics)));
333 334
334 DVLOG(1) << "Update theme specifics from current theme: " 335 DVLOG(1) << "Update theme specifics from current theme: "
335 << changes.back().ToString(); 336 << changes.back().ToString();
336 337
337 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 338 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
338 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698