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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« 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