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, syncable::GET_BY_SERVER_TAG, tag); |
87 if (!entry_->good()) | 87 if (!entry_->good()) |
88 return INIT_FAILED_ENTRY_NOT_GOOD; | 88 return INIT_FAILED_ENTRY_NOT_GOOD; |
89 if (entry_->GetIsDel()) | 89 if (entry_->GetIsDel()) |
90 return INIT_FAILED_ENTRY_IS_DEL; | 90 return INIT_FAILED_ENTRY_IS_DEL; |
91 ModelType model_type = GetModelType(); | 91 ModelType model_type = GetModelType(); |
92 LOG_IF(WARNING, model_type == UNSPECIFIED || model_type == TOP_LEVEL_FOLDER) | 92 DCHECK_EQ(model_type, BOOKMARKS) |
93 << "SyncAPI InitByTagLookup referencing unusually typed object."; | 93 << "InitByTagLookup deprecated for all types except bookmarks."; |
94 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; | 94 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
95 } | 95 } |
96 | 96 |
| 97 BaseNode::InitByLookupResult ReadNode::InitTypeRoot(ModelType type) { |
| 98 DCHECK(!entry_) << "Init called twice"; |
| 99 if (!IsRealDataType(type)) |
| 100 return INIT_FAILED_PRECONDITION; |
| 101 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 102 entry_ = new syncable::Entry(trans, syncable::GET_TYPE_ROOT, type); |
| 103 if (!entry_->good()) |
| 104 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 105 if (entry_->GetIsDel()) |
| 106 return INIT_FAILED_ENTRY_IS_DEL; |
| 107 ModelType found_model_type = GetModelType(); |
| 108 LOG_IF(WARNING, found_model_type == UNSPECIFIED || |
| 109 found_model_type == TOP_LEVEL_FOLDER) |
| 110 << "SyncAPI InitTypeRoot referencing unusually typed object."; |
| 111 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
| 112 } |
| 113 |
97 } // namespace syncer | 114 } // namespace syncer |
OLD | NEW |