Chromium Code Reviews| 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..62d62e06af2efbefecd43e112245cc148b488bb3 |
| --- /dev/null |
| +++ b/chrome/browser/sync/api/sync_change.cc |
| @@ -0,0 +1,55 @@ |
| +// 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" |
| + |
| +#include "chrome/browser/sync/api/sync_data.h" |
|
akalin
2011/05/20 00:19:39
no need for this, since you include it in the head
Nicolas Zea
2011/05/20 02:00:28
Done.
|
| + |
| +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()) { |
| + if (sync_data_.GetDataType() == syncable::UNSPECIFIED) |
|
akalin
2011/05/20 00:19:39
return sync_data_.GetDataType() != syncable::UNSPE
Nicolas Zea
2011/05/20 02:00:28
Done.
|
| + return false; |
| + else |
| + return true; |
| + } |
| + |
| + // 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) { |
| + if (sync_data_.GetDataType() != syncable::UNSPECIFIED) |
|
akalin
2011/05/20 00:19:39
here, too.
Nicolas Zea
2011/05/20 02:00:28
Done.
|
| + return true; |
| + else |
| + return false; |
| + } else { // ACTION_DELETE only requires tag. |
| + return true; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +SyncChange::SyncChangeType SyncChange::change_type() const { |
| + return change_type_; |
| +} |
| + |
| +SyncData SyncChange::sync_data() const { |
| + return sync_data_; |
| +} |