Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/sync/api/sync_change.h" | |
| 6 | |
| 7 #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.
| |
| 8 | |
| 9 SyncChange::SyncChange() : change_type_(ACTION_INVALID) { | |
| 10 } | |
| 11 | |
| 12 SyncChange::SyncChange(SyncChangeType change_type, const SyncData& sync_data) | |
| 13 : change_type_(change_type), | |
| 14 sync_data_(sync_data) { | |
| 15 DCHECK(IsValid()); | |
| 16 } | |
| 17 | |
| 18 SyncChange::~SyncChange() {} | |
| 19 | |
| 20 bool SyncChange::IsValid() const { | |
| 21 if (change_type_ == ACTION_INVALID || !sync_data_.IsValid()) | |
| 22 return false; | |
| 23 | |
| 24 // Data from the syncer must always have specifics. | |
| 25 if (!sync_data_.IsLocal()) { | |
| 26 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.
| |
| 27 return false; | |
| 28 else | |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 // Local changes must always have a tag. | |
| 33 if (sync_data_.GetTag().empty()) | |
| 34 return false; | |
| 35 | |
| 36 // Adds and updates must have valid specifics (checked by GetDataType()) | |
| 37 if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE) { | |
| 38 if (sync_data_.GetDataType() != syncable::UNSPECIFIED) | |
|
akalin
2011/05/20 00:19:39
here, too.
Nicolas Zea
2011/05/20 02:00:28
Done.
| |
| 39 return true; | |
| 40 else | |
| 41 return false; | |
| 42 } else { // ACTION_DELETE only requires tag. | |
| 43 return true; | |
| 44 } | |
| 45 | |
| 46 return true; | |
| 47 } | |
| 48 | |
| 49 SyncChange::SyncChangeType SyncChange::change_type() const { | |
| 50 return change_type_; | |
| 51 } | |
| 52 | |
| 53 SyncData SyncChange::sync_data() const { | |
| 54 return sync_data_; | |
| 55 } | |
| OLD | NEW |