| 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 <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "sync/internal_api/public/base_transaction.h" | 10 #include "sync/internal_api/public/base_transaction.h" |
| 9 #include "sync/syncable/entry.h" | 11 #include "sync/syncable/entry.h" |
| 10 #include "sync/syncable/syncable_base_transaction.h" | 12 #include "sync/syncable/syncable_base_transaction.h" |
| 11 #include "sync/syncable/syncable_util.h" | 13 #include "sync/syncable/syncable_util.h" |
| 12 | 14 |
| 13 namespace syncer { | 15 namespace syncer { |
| 14 | 16 |
| 15 ////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////// |
| 16 // ReadNode member definitions | 18 // ReadNode member definitions |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 } | 31 } |
| 30 | 32 |
| 31 void ReadNode::InitByRootLookup() { | 33 void ReadNode::InitByRootLookup() { |
| 32 DCHECK(!entry_) << "Init called twice"; | 34 DCHECK(!entry_) << "Init called twice"; |
| 33 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); | 35 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 34 entry_ = new syncable::Entry(trans, syncable::GET_BY_ID, trans->root_id()); | 36 entry_ = new syncable::Entry(trans, syncable::GET_BY_ID, trans->root_id()); |
| 35 if (!entry_->good()) | 37 if (!entry_->good()) |
| 36 DCHECK(false) << "Could not lookup root node for reading."; | 38 DCHECK(false) << "Could not lookup root node for reading."; |
| 37 } | 39 } |
| 38 | 40 |
| 39 BaseNode::InitByLookupResult ReadNode::InitByIdLookup(int64 id) { | 41 BaseNode::InitByLookupResult ReadNode::InitByIdLookup(int64_t id) { |
| 40 DCHECK(!entry_) << "Init called twice"; | 42 DCHECK(!entry_) << "Init called twice"; |
| 41 DCHECK_NE(id, kInvalidId); | 43 DCHECK_NE(id, kInvalidId); |
| 42 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); | 44 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 43 entry_ = new syncable::Entry(trans, syncable::GET_BY_HANDLE, id); | 45 entry_ = new syncable::Entry(trans, syncable::GET_BY_HANDLE, id); |
| 44 if (!entry_->good()) | 46 if (!entry_->good()) |
| 45 return INIT_FAILED_ENTRY_NOT_GOOD; | 47 return INIT_FAILED_ENTRY_NOT_GOOD; |
| 46 if (entry_->GetIsDel()) | 48 if (entry_->GetIsDel()) |
| 47 return INIT_FAILED_ENTRY_IS_DEL; | 49 return INIT_FAILED_ENTRY_IS_DEL; |
| 48 ModelType model_type = GetModelType(); | 50 ModelType model_type = GetModelType(); |
| 49 LOG_IF(WARNING, model_type == UNSPECIFIED || model_type == TOP_LEVEL_FOLDER) | 51 LOG_IF(WARNING, model_type == UNSPECIFIED || model_type == TOP_LEVEL_FOLDER) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 } | 72 } |
| 71 | 73 |
| 72 const syncable::Entry* ReadNode::GetEntry() const { | 74 const syncable::Entry* ReadNode::GetEntry() const { |
| 73 return entry_; | 75 return entry_; |
| 74 } | 76 } |
| 75 | 77 |
| 76 const BaseTransaction* ReadNode::GetTransaction() const { | 78 const BaseTransaction* ReadNode::GetTransaction() const { |
| 77 return transaction_; | 79 return transaction_; |
| 78 } | 80 } |
| 79 | 81 |
| 80 int64 ReadNode::GetTransactionVersion() const { | 82 int64_t ReadNode::GetTransactionVersion() const { |
| 81 return GetEntry()->GetTransactionVersion(); | 83 return GetEntry()->GetTransactionVersion(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 BaseNode::InitByLookupResult ReadNode::InitByTagLookupForBookmarks( | 86 BaseNode::InitByLookupResult ReadNode::InitByTagLookupForBookmarks( |
| 85 const std::string& tag) { | 87 const std::string& tag) { |
| 86 DCHECK(!entry_) << "Init called twice"; | 88 DCHECK(!entry_) << "Init called twice"; |
| 87 if (tag.empty()) | 89 if (tag.empty()) |
| 88 return INIT_FAILED_PRECONDITION; | 90 return INIT_FAILED_PRECONDITION; |
| 89 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); | 91 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); |
| 90 entry_ = new syncable::Entry(trans, syncable::GET_BY_SERVER_TAG, tag); | 92 entry_ = new syncable::Entry(trans, syncable::GET_BY_SERVER_TAG, tag); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 if (entry_->GetIsDel()) | 111 if (entry_->GetIsDel()) |
| 110 return INIT_FAILED_ENTRY_IS_DEL; | 112 return INIT_FAILED_ENTRY_IS_DEL; |
| 111 ModelType found_model_type = GetModelType(); | 113 ModelType found_model_type = GetModelType(); |
| 112 LOG_IF(WARNING, found_model_type == UNSPECIFIED || | 114 LOG_IF(WARNING, found_model_type == UNSPECIFIED || |
| 113 found_model_type == TOP_LEVEL_FOLDER) | 115 found_model_type == TOP_LEVEL_FOLDER) |
| 114 << "SyncAPI InitTypeRoot referencing unusually typed object."; | 116 << "SyncAPI InitTypeRoot referencing unusually typed object."; |
| 115 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; | 117 return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY; |
| 116 } | 118 } |
| 117 | 119 |
| 118 } // namespace syncer | 120 } // namespace syncer |
| OLD | NEW |