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 SyncChange::SyncChange() : change_type_(ACTION_INVALID) { |
| 8 } |
| 9 |
| 10 SyncChange::SyncChange(SyncChangeType change_type, const SyncData& sync_data) |
| 11 : change_type_(change_type), |
| 12 sync_data_(sync_data) { |
| 13 DCHECK(IsValid()); |
| 14 } |
| 15 |
| 16 SyncChange::~SyncChange() {} |
| 17 |
| 18 bool SyncChange::IsValid() const { |
| 19 if (change_type_ == ACTION_INVALID || !sync_data_.IsValid()) |
| 20 return false; |
| 21 |
| 22 // Data from the syncer must always have specifics. |
| 23 if (!sync_data_.IsLocal()) |
| 24 return (sync_data_.GetDataType() != syncable::UNSPECIFIED); |
| 25 |
| 26 // Local changes must always have a tag. |
| 27 if (sync_data_.GetTag().empty()) |
| 28 return false; |
| 29 |
| 30 // Adds and updates must have valid specifics (checked by GetDataType()) |
| 31 if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE) |
| 32 return (sync_data_.GetDataType() != syncable::UNSPECIFIED); |
| 33 |
| 34 return true; |
| 35 } |
| 36 |
| 37 SyncChange::SyncChangeType SyncChange::change_type() const { |
| 38 return change_type_; |
| 39 } |
| 40 |
| 41 SyncData SyncChange::sync_data() const { |
| 42 return sync_data_; |
| 43 } |
OLD | NEW |