OLD | NEW |
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 "sync/api/sync_change.h" | 5 #include "sync/api/sync_change.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 namespace syncer { | 9 namespace syncer { |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 SyncChange::~SyncChange() {} | 24 SyncChange::~SyncChange() {} |
25 | 25 |
26 bool SyncChange::IsValid() const { | 26 bool SyncChange::IsValid() const { |
27 if (change_type_ == ACTION_INVALID || !sync_data_.IsValid()) | 27 if (change_type_ == ACTION_INVALID || !sync_data_.IsValid()) |
28 return false; | 28 return false; |
29 | 29 |
30 // Data from the syncer must always have valid specifics. | 30 // Data from the syncer must always have valid specifics. |
31 if (!sync_data_.IsLocal()) | 31 if (!sync_data_.IsLocal()) |
32 return IsRealDataType(sync_data_.GetDataType()); | 32 return IsRealDataType(sync_data_.GetDataType()); |
33 | 33 |
| 34 SyncDataLocal sync_data_local(sync_data_.AsLocal()); |
| 35 |
34 // Local changes must always have a tag and specify a valid datatype. | 36 // Local changes must always have a tag and specify a valid datatype. |
35 if (sync_data_.GetTag().empty() || | 37 if (sync_data_local.GetTag().empty() || |
36 !IsRealDataType(sync_data_.GetDataType())) { | 38 !IsRealDataType(sync_data_.GetDataType())) { |
37 return false; | 39 return false; |
38 } | 40 } |
39 | 41 |
40 // Adds and updates must have a non-unique-title. | 42 // Adds and updates must have a non-unique-title. |
41 if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE) | 43 if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE) |
42 return (!sync_data_.GetTitle().empty()); | 44 return (!sync_data_.GetTitle().empty()); |
43 | 45 |
44 return true; | 46 return true; |
45 } | 47 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return "{ " + location_.ToString() + ", changeType: " + | 79 return "{ " + location_.ToString() + ", changeType: " + |
78 ChangeTypeToString(change_type_) + ", syncData: " + | 80 ChangeTypeToString(change_type_) + ", syncData: " + |
79 sync_data_.ToString() + "}"; | 81 sync_data_.ToString() + "}"; |
80 } | 82 } |
81 | 83 |
82 void PrintTo(const SyncChange& sync_change, std::ostream* os) { | 84 void PrintTo(const SyncChange& sync_change, std::ostream* os) { |
83 *os << sync_change.ToString(); | 85 *os << sync_change.ToString(); |
84 } | 86 } |
85 | 87 |
86 } // namespace syncer | 88 } // namespace syncer |
OLD | NEW |