summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-18 00:05:48 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-18 00:05:48 +0000
commitd58c29dfbdb1f77c51c9a754639b880577a2825f (patch)
tree0c4ced484cbf48342a7cc7647554ddc1c371bda8
parentcb7ba12ebb87bc3e3fcda1d00129a69e52cbfb11 (diff)
downloadchromium_src-d58c29dfbdb1f77c51c9a754639b880577a2825f.zip
chromium_src-d58c29dfbdb1f77c51c9a754639b880577a2825f.tar.gz
chromium_src-d58c29dfbdb1f77c51c9a754639b880577a2825f.tar.bz2
Allow InitByTagLookup for WriteNodes.
BUG=none TEST=Modified the Nigori permanent node. Review URL: http://codereview.chromium.org/2844004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50176 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/engine/syncapi.cc15
-rw-r--r--chrome/browser/sync/engine/syncapi.h9
-rw-r--r--chrome/browser/sync/syncable/syncable.cc6
-rw-r--r--chrome/browser/sync/syncable/syncable.h1
4 files changed, 28 insertions, 3 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 76be27a..20d6a2c 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -469,6 +469,21 @@ bool WriteNode::InitByClientTagLookup(syncable::ModelType model_type,
return (entry_->good() && !entry_->Get(syncable::IS_DEL));
}
+bool WriteNode::InitByTagLookup(const std::string& tag) {
+ DCHECK(!entry_) << "Init called twice";
+ if (tag.empty())
+ return false;
+ entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(),
+ syncable::GET_BY_SERVER_TAG, tag);
+ if (!entry_->good())
+ return false;
+ if (entry_->Get(syncable::IS_DEL))
+ return false;
+ syncable::ModelType model_type = GetModelType();
+ DCHECK(model_type == syncable::NIGORI);
+ return true;
+}
+
void WriteNode::PutModelType(syncable::ModelType model_type) {
// Set an empty specifics of the appropriate datatype. The presence
// of the specific extension will identify the model type.
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 56d0834..d7b984f 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -278,6 +278,11 @@ class WriteNode : public BaseNode {
const BaseNode& parent,
const std::string& client_tag);
+ // Each server-created permanent node is tagged with a unique string.
+ // Look up the node with the particular tag. If it does not exist,
+ // return false.
+ bool InitByTagLookup(const std::string& tag);
+
// These Set() functions correspond to the Get() functions of BaseNode.
void SetIsFolder(bool folder);
void SetTitle(const std::wstring& title);
@@ -406,9 +411,7 @@ class ReadNode : public BaseNode {
// Each server-created permanent node is tagged with a unique string.
// Look up the node with the particular tag. If it does not exist,
- // return false. Since these nodes are special, lookup is only
- // provided through ReadNode.
- // TODO(chron): Rename this function.
+ // return false.
bool InitByTagLookup(const std::string& tag);
// Implementation of BaseNode's abstract virtual accessors.
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 42e4867..e694ebe 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -1168,6 +1168,12 @@ MutableEntry::MutableEntry(WriteTransaction* trans, GetByClientTag,
trans->SaveOriginal(kernel_);
}
+MutableEntry::MutableEntry(WriteTransaction* trans, GetByServerTag,
+ const string& tag)
+ : Entry(trans, GET_BY_SERVER_TAG, tag), write_transaction_(trans) {
+ trans->SaveOriginal(kernel_);
+}
+
bool MutableEntry::PutIsDel(bool is_del) {
DCHECK(kernel_);
if (is_del == kernel_->ref(IS_DEL)) {
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index 270d2bf..ff58f1f 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -460,6 +460,7 @@ class MutableEntry : public Entry {
MutableEntry(WriteTransaction* trans, GetByHandle, int64);
MutableEntry(WriteTransaction* trans, GetById, const Id&);
MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag);
+ MutableEntry(WriteTransaction* trans, GetByServerTag, const std::string& tag);
inline WriteTransaction* write_transaction() const {
return write_transaction_;