| 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "sync/engine/nigori_util.h" | 9 #include "sync/engine/nigori_util.h" |
| 10 #include "sync/internal_api/public/base_transaction.h" | 10 #include "sync/internal_api/public/base_transaction.h" |
| 11 #include "sync/internal_api/public/write_transaction.h" | 11 #include "sync/internal_api/public/write_transaction.h" |
| 12 #include "sync/internal_api/syncapi_internal.h" | 12 #include "sync/internal_api/syncapi_internal.h" |
| 13 #include "sync/protocol/app_specifics.pb.h" | 13 #include "sync/protocol/app_specifics.pb.h" |
| 14 #include "sync/protocol/autofill_specifics.pb.h" | 14 #include "sync/protocol/autofill_specifics.pb.h" |
| 15 #include "sync/protocol/bookmark_specifics.pb.h" | 15 #include "sync/protocol/bookmark_specifics.pb.h" |
| 16 #include "sync/protocol/extension_specifics.pb.h" | 16 #include "sync/protocol/extension_specifics.pb.h" |
| 17 #include "sync/protocol/password_specifics.pb.h" | 17 #include "sync/protocol/password_specifics.pb.h" |
| 18 #include "sync/protocol/session_specifics.pb.h" | 18 #include "sync/protocol/session_specifics.pb.h" |
| 19 #include "sync/protocol/theme_specifics.pb.h" | 19 #include "sync/protocol/theme_specifics.pb.h" |
| 20 #include "sync/protocol/typed_url_specifics.pb.h" | 20 #include "sync/protocol/typed_url_specifics.pb.h" |
| 21 #include "sync/syncable/mutable_entry.h" | 21 #include "sync/syncable/mutable_entry.h" |
| 22 #include "sync/util/cryptographer.h" | 22 #include "sync/util/cryptographer.h" |
| 23 | 23 |
| 24 using csync::Cryptographer; | 24 using syncer::Cryptographer; |
| 25 using std::string; | 25 using std::string; |
| 26 using std::vector; | 26 using std::vector; |
| 27 using syncable::kEncryptedString; | 27 using syncable::kEncryptedString; |
| 28 using syncable::SPECIFICS; | 28 using syncable::SPECIFICS; |
| 29 | 29 |
| 30 namespace csync { | 30 namespace syncer { |
| 31 | 31 |
| 32 static const char kDefaultNameForNewNodes[] = " "; | 32 static const char kDefaultNameForNewNodes[] = " "; |
| 33 | 33 |
| 34 void WriteNode::SetIsFolder(bool folder) { | 34 void WriteNode::SetIsFolder(bool folder) { |
| 35 if (entry_->Get(syncable::IS_DIR) == folder) | 35 if (entry_->Get(syncable::IS_DIR) == folder) |
| 36 return; // Skip redundant changes. | 36 return; // Skip redundant changes. |
| 37 | 37 |
| 38 entry_->Put(syncable::IS_DIR, folder); | 38 entry_->Put(syncable::IS_DIR, folder); |
| 39 MarkForSyncing(); | 39 MarkForSyncing(); |
| 40 } | 40 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 syncable::GetModelTypeFromSpecifics(new_value); | 198 syncable::GetModelTypeFromSpecifics(new_value); |
| 199 DCHECK_NE(new_specifics_type, syncable::UNSPECIFIED); | 199 DCHECK_NE(new_specifics_type, syncable::UNSPECIFIED); |
| 200 DVLOG(1) << "Writing entity specifics of type " | 200 DVLOG(1) << "Writing entity specifics of type " |
| 201 << syncable::ModelTypeToString(new_specifics_type); | 201 << syncable::ModelTypeToString(new_specifics_type); |
| 202 // GetModelType() can be unspecified if this is the first time this | 202 // GetModelType() can be unspecified if this is the first time this |
| 203 // node is being initialized (see PutModelType()). Otherwise, it | 203 // node is being initialized (see PutModelType()). Otherwise, it |
| 204 // should match |new_specifics_type|. | 204 // should match |new_specifics_type|. |
| 205 if (GetModelType() != syncable::UNSPECIFIED) { | 205 if (GetModelType() != syncable::UNSPECIFIED) { |
| 206 DCHECK_EQ(new_specifics_type, GetModelType()); | 206 DCHECK_EQ(new_specifics_type, GetModelType()); |
| 207 } | 207 } |
| 208 csync::Cryptographer* cryptographer = | 208 syncer::Cryptographer* cryptographer = |
| 209 GetTransaction()->GetCryptographer(); | 209 GetTransaction()->GetCryptographer(); |
| 210 | 210 |
| 211 // Preserve unknown fields. | 211 // Preserve unknown fields. |
| 212 const sync_pb::EntitySpecifics& old_specifics = entry_->Get(SPECIFICS); | 212 const sync_pb::EntitySpecifics& old_specifics = entry_->Get(SPECIFICS); |
| 213 sync_pb::EntitySpecifics new_specifics; | 213 sync_pb::EntitySpecifics new_specifics; |
| 214 new_specifics.CopyFrom(new_value); | 214 new_specifics.CopyFrom(new_value); |
| 215 new_specifics.mutable_unknown_fields()->MergeFrom( | 215 new_specifics.mutable_unknown_fields()->MergeFrom( |
| 216 old_specifics.unknown_fields()); | 216 old_specifics.unknown_fields()); |
| 217 | 217 |
| 218 // Will update the entry if encryption was necessary. | 218 // Will update the entry if encryption was necessary. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 void WriteNode::SetFaviconBytes(const vector<unsigned char>& bytes) { | 502 void WriteNode::SetFaviconBytes(const vector<unsigned char>& bytes) { |
| 503 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics(); | 503 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics(); |
| 504 new_value.set_favicon(bytes.empty() ? NULL : &bytes[0], bytes.size()); | 504 new_value.set_favicon(bytes.empty() ? NULL : &bytes[0], bytes.size()); |
| 505 SetBookmarkSpecifics(new_value); | 505 SetBookmarkSpecifics(new_value); |
| 506 } | 506 } |
| 507 | 507 |
| 508 void WriteNode::MarkForSyncing() { | 508 void WriteNode::MarkForSyncing() { |
| 509 syncable::MarkForSyncing(entry_); | 509 syncable::MarkForSyncing(entry_); |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace csync | 512 } // namespace syncer |
| OLD | NEW |