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/internal_api/public/write_node.h" | 5 #include "sync/internal_api/public/write_node.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 CHECK(!new_value.password().has_client_only_encrypted_data()); | 156 CHECK(!new_value.password().has_client_only_encrypted_data()); |
157 DCHECK_NE(new_specifics_type, UNSPECIFIED); | 157 DCHECK_NE(new_specifics_type, UNSPECIFIED); |
158 DVLOG(1) << "Writing entity specifics of type " | 158 DVLOG(1) << "Writing entity specifics of type " |
159 << ModelTypeToString(new_specifics_type); | 159 << ModelTypeToString(new_specifics_type); |
160 DCHECK_EQ(new_specifics_type, GetModelType()); | 160 DCHECK_EQ(new_specifics_type, GetModelType()); |
161 | 161 |
162 // Preserve unknown fields. | 162 // Preserve unknown fields. |
163 const sync_pb::EntitySpecifics& old_specifics = entry_->GetSpecifics(); | 163 const sync_pb::EntitySpecifics& old_specifics = entry_->GetSpecifics(); |
164 sync_pb::EntitySpecifics new_specifics; | 164 sync_pb::EntitySpecifics new_specifics; |
165 new_specifics.CopyFrom(new_value); | 165 new_specifics.CopyFrom(new_value); |
166 new_specifics.mutable_unknown_fields()->MergeFrom( | 166 new_specifics.mutable_unknown_fields() |
167 old_specifics.unknown_fields()); | 167 ->append(old_specifics.unknown_fields()); |
168 | 168 |
169 // Will update the entry if encryption was necessary. | 169 // Will update the entry if encryption was necessary. |
170 if (!UpdateEntryWithEncryption(GetTransaction()->GetWrappedTrans(), | 170 if (!UpdateEntryWithEncryption(GetTransaction()->GetWrappedTrans(), |
171 new_specifics, | 171 new_specifics, |
172 entry_)) { | 172 entry_)) { |
173 return; | 173 return; |
174 } | 174 } |
175 if (entry_->GetSpecifics().has_encrypted()) { | 175 if (entry_->GetSpecifics().has_encrypted()) { |
176 // EncryptIfNecessary already updated the entry for us and marked for | 176 // EncryptIfNecessary already updated the entry for us and marked for |
177 // syncing if it was needed. Now we just make a copy of the unencrypted | 177 // syncing if it was needed. Now we just make a copy of the unencrypted |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 syncable::Id predecessor_id = | 467 syncable::Id predecessor_id = |
468 predecessor ? predecessor->GetSyncId() : syncable::Id(); | 468 predecessor ? predecessor->GetSyncId() : syncable::Id(); |
469 return entry_->PutPredecessor(predecessor_id); | 469 return entry_->PutPredecessor(predecessor_id); |
470 } | 470 } |
471 | 471 |
472 void WriteNode::MarkForSyncing() { | 472 void WriteNode::MarkForSyncing() { |
473 syncable::MarkForSyncing(entry_); | 473 syncable::MarkForSyncing(entry_); |
474 } | 474 } |
475 | 475 |
476 } // namespace syncer | 476 } // namespace syncer |
OLD | NEW |