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

Unified Diff: chrome/browser/sync/api/sync_change.cc

Issue 6995008: Implement new SyncAPI and convert Preferences to it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix compile Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/api/sync_change.h ('k') | chrome/browser/sync/api/sync_change_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/api/sync_change.cc
diff --git a/chrome/browser/sync/api/sync_change.cc b/chrome/browser/sync/api/sync_change.cc
new file mode 100644
index 0000000000000000000000000000000000000000..320dd537f2c2066b8260ae6117352955b5c81c61
--- /dev/null
+++ b/chrome/browser/sync/api/sync_change.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/api/sync_change.h"
+
+SyncChange::SyncChange() : change_type_(ACTION_INVALID) {
+}
+
+SyncChange::SyncChange(SyncChangeType change_type, const SyncData& sync_data)
+ : change_type_(change_type),
+ sync_data_(sync_data) {
+ DCHECK(IsValid());
+}
+
+SyncChange::~SyncChange() {}
+
+bool SyncChange::IsValid() const {
+ if (change_type_ == ACTION_INVALID || !sync_data_.IsValid())
+ return false;
+
+ // Data from the syncer must always have specifics.
+ if (!sync_data_.IsLocal())
+ return (sync_data_.GetDataType() != syncable::UNSPECIFIED);
+
+ // Local changes must always have a tag.
+ if (sync_data_.GetTag().empty())
+ return false;
+
+ // Adds and updates must have valid specifics (checked by GetDataType())
+ if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE)
+ return (sync_data_.GetDataType() != syncable::UNSPECIFIED);
+
+ return true;
+}
+
+SyncChange::SyncChangeType SyncChange::change_type() const {
+ return change_type_;
+}
+
+SyncData SyncChange::sync_data() const {
+ return sync_data_;
+}
« no previous file with comments | « chrome/browser/sync/api/sync_change.h ('k') | chrome/browser/sync/api/sync_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698