| 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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "sync/internal_api/public/base_transaction.h" | 10 #include "sync/internal_api/public/base_transaction.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), | 304 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), |
| 305 syncable::GET_BY_CLIENT_TAG, hash); | 305 syncable::GET_BY_CLIENT_TAG, hash); |
| 306 if (!entry_->good()) | 306 if (!entry_->good()) |
| 307 return INIT_FAILED_ENTRY_NOT_GOOD; | 307 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 308 if (entry_->GetIsDel()) | 308 if (entry_->GetIsDel()) |
| 309 return INIT_FAILED_ENTRY_IS_DEL; | 309 return INIT_FAILED_ENTRY_IS_DEL; |
| 310 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; | 310 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
| 311 } | 311 } |
| 312 | 312 |
| 313 BaseNode::InitByLookupResult WriteNode::InitByTagLookup( | 313 BaseNode::InitByLookupResult WriteNode::InitTypeRoot(ModelType type) { |
| 314 const std::string& tag) { | |
| 315 DCHECK(!entry_) << "Init called twice"; | 314 DCHECK(!entry_) << "Init called twice"; |
| 316 if (tag.empty()) | 315 if (!IsRealDataType(type)) |
| 317 return INIT_FAILED_PRECONDITION; | 316 return INIT_FAILED_PRECONDITION; |
| 318 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), | 317 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), |
| 319 syncable::GET_BY_SERVER_TAG, tag); | 318 syncable::GET_TYPE_ROOT, type); |
| 320 if (!entry_->good()) | 319 if (!entry_->good()) |
| 321 return INIT_FAILED_ENTRY_NOT_GOOD; | 320 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 322 if (entry_->GetIsDel()) | 321 if (entry_->GetIsDel()) |
| 323 return INIT_FAILED_ENTRY_IS_DEL; | 322 return INIT_FAILED_ENTRY_IS_DEL; |
| 324 ModelType model_type = GetModelType(); | 323 ModelType model_type = GetModelType(); |
| 325 DCHECK_EQ(model_type, NIGORI); | 324 DCHECK_EQ(model_type, NIGORI); |
| 326 return INIT_OK; | 325 return INIT_OK; |
| 327 } | 326 } |
| 328 | 327 |
| 329 // Create a new node with default properties, and bind this WriteNode to it. | 328 // Create a new node with default properties, and bind this WriteNode to it. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 MarkForSyncing(); | 504 MarkForSyncing(); |
| 506 | 505 |
| 507 return true; | 506 return true; |
| 508 } | 507 } |
| 509 | 508 |
| 510 void WriteNode::MarkForSyncing() { | 509 void WriteNode::MarkForSyncing() { |
| 511 syncable::MarkForSyncing(entry_); | 510 syncable::MarkForSyncing(entry_); |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace syncer | 513 } // namespace syncer |
| OLD | NEW |