Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: sync/internal_api/read_node.cc

Issue 302173004: sync: Specialize functions that fetch type root (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/GET_BY_SERVER_TAG_DEPRECATED/GET_BY_SERVER_TAG/ Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/internal_api/public/write_node.h ('k') | sync/internal_api/sync_backup_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/read_node.cc
diff --git a/sync/internal_api/read_node.cc b/sync/internal_api/read_node.cc
index ec85af64121f2b325d6f7bd1fdb0590e4167f3d8..c162800df0c0e1e1801d6dacb5dc70f02dd92251 100644
--- a/sync/internal_api/read_node.cc
+++ b/sync/internal_api/read_node.cc
@@ -77,7 +77,7 @@ const BaseTransaction* ReadNode::GetTransaction() const {
return transaction_;
}
-BaseNode::InitByLookupResult ReadNode::InitByTagLookup(
+BaseNode::InitByLookupResult ReadNode::InitByTagLookupForBookmarks(
const std::string& tag) {
DCHECK(!entry_) << "Init called twice";
if (tag.empty())
@@ -89,8 +89,25 @@ BaseNode::InitByLookupResult ReadNode::InitByTagLookup(
if (entry_->GetIsDel())
return INIT_FAILED_ENTRY_IS_DEL;
ModelType model_type = GetModelType();
- LOG_IF(WARNING, model_type == UNSPECIFIED || model_type == TOP_LEVEL_FOLDER)
- << "SyncAPI InitByTagLookup referencing unusually typed object.";
+ DCHECK_EQ(model_type, BOOKMARKS)
+ << "InitByTagLookup deprecated for all types except bookmarks.";
+ return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY;
+}
+
+BaseNode::InitByLookupResult ReadNode::InitTypeRoot(ModelType type) {
+ DCHECK(!entry_) << "Init called twice";
+ if (!IsRealDataType(type))
+ return INIT_FAILED_PRECONDITION;
+ syncable::BaseTransaction* trans = transaction_->GetWrappedTrans();
+ entry_ = new syncable::Entry(trans, syncable::GET_TYPE_ROOT, type);
+ if (!entry_->good())
+ return INIT_FAILED_ENTRY_NOT_GOOD;
+ if (entry_->GetIsDel())
+ return INIT_FAILED_ENTRY_IS_DEL;
+ ModelType found_model_type = GetModelType();
+ LOG_IF(WARNING, found_model_type == UNSPECIFIED ||
+ found_model_type == TOP_LEVEL_FOLDER)
+ << "SyncAPI InitTypeRoot referencing unusually typed object.";
return DecryptIfNecessary() ? INIT_OK : INIT_FAILED_DECRYPT_IF_NECESSARY;
}
« no previous file with comments | « sync/internal_api/public/write_node.h ('k') | sync/internal_api/sync_backup_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698