| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/read_node.h" | 5 #include "sync/internal_api/public/read_node.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "sync/internal_api/public/base_transaction.h" | 8 #include "sync/internal_api/public/base_transaction.h" |
| 9 #include "sync/syncable/entry.h" | 9 #include "sync/syncable/entry.h" |
| 10 #include "sync/syncable/syncable_base_transaction.h" | 10 #include "sync/syncable/syncable_base_transaction.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 const syncable::Entry* ReadNode::GetEntry() const { | 72 const syncable::Entry* ReadNode::GetEntry() const { |
| 73 return entry_; | 73 return entry_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 const BaseTransaction* ReadNode::GetTransaction() const { | 76 const BaseTransaction* ReadNode::GetTransaction() const { |
| 77 return transaction_; | 77 return transaction_; |
| 78 } | 78 } |
| 79 | 79 |
| 80 BaseNode::InitByLookupResult ReadNode::InitByTagLookup( | 80 BaseNode::InitByLookupResult ReadNode::InitByTagLookupForBookmarks( |
| 81 const std::string& tag) { | 81 const std::string& tag) { |
| 82 DCHECK(!entry_) << "Init called twice"; | 82 DCHECK(!entry_) << "Init called twice"; |
| 83 if (tag.empty()) | 83 if (tag.empty()) |
| 84 return INIT_FAILED_PRECONDITION; | 84 return INIT_FAILED_PRECONDITION; |
| 85 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); | 85 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 86 entry_ = new syncable::Entry(trans, syncable::GET_BY_SERVER_TAG, tag); | 86 entry_ = new syncable::Entry(trans, |
| 87 syncable::GET_BY_SERVER_TAG_DEPRECATED, |
| 88 tag); |
| 87 if (!entry_->good()) | 89 if (!entry_->good()) |
| 88 return INIT_FAILED_ENTRY_NOT_GOOD; | 90 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 89 if (entry_->GetIsDel()) | 91 if (entry_->GetIsDel()) |
| 90 return INIT_FAILED_ENTRY_IS_DEL; | 92 return INIT_FAILED_ENTRY_IS_DEL; |
| 91 ModelType model_type = GetModelType(); | 93 ModelType model_type = GetModelType(); |
| 92 LOG_IF(WARNING, model_type == UNSPECIFIED || model_type == TOP_LEVEL_FOLDER) | 94 DCHECK_EQ(model_type, BOOKMARKS) |
| 93 << "SyncAPI InitByTagLookup referencing unusually typed object."; | 95 << "InitByTagLookup deprecated for all types except bookmarks."; |
| 94 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; | 96 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
| 95 } | 97 } |
| 96 | 98 |
| 99 BaseNode::InitByLookupResult ReadNode::InitTypeRoot(ModelType type) { |
| 100 DCHECK(!entry_) << "Init called twice"; |
| 101 if (!IsRealDataType(type)) |
| 102 return INIT_FAILED_PRECONDITION; |
| 103 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 104 entry_ = new syncable::Entry(trans, syncable::GET_TYPE_ROOT, type); |
| 105 if (!entry_->good()) |
| 106 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 107 if (entry_->GetIsDel()) |
| 108 return INIT_FAILED_ENTRY_IS_DEL; |
| 109 ModelType found_model_type = GetModelType(); |
| 110 LOG_IF(WARNING, found_model_type == UNSPECIFIED || |
| 111 found_model_type == TOP_LEVEL_FOLDER) |
| 112 << "SyncAPI InitTypeRoot referencing unusually typed object."; |
| 113 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
| 114 } |
| 115 |
| 97 } // namespace syncer | 116 } // namespace syncer |
| OLD | NEW |