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

Unified Diff: sync/syncable/mutable_entry.cc

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed memory leak error in unittest Created 8 years, 2 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/syncable/mutable_entry.h ('k') | sync/syncable/syncable_columns.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/mutable_entry.cc
diff --git a/sync/syncable/mutable_entry.cc b/sync/syncable/mutable_entry.cc
index 869320f33e20aa487ebbc4ecaefc015ed9f1d90e..5090ad1a9116739a00d89ae6f6952ec9c765acaa 100644
--- a/sync/syncable/mutable_entry.cc
+++ b/sync/syncable/mutable_entry.cc
@@ -5,6 +5,7 @@
#include "sync/syncable/mutable_entry.h"
#include "base/memory/scoped_ptr.h"
+#include "sync/internal_api/public/base/node_ordinal.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/scoped_index_updater.h"
#include "sync/syncable/scoped_kernel_lock.h"
@@ -41,6 +42,7 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
kernel->put(MTIME, now);
// We match the database defaults here
kernel->put(BASE_VERSION, CHANGES_VERSION);
+ kernel->put(SERVER_ORDINAL_IN_PARENT, NodeOrdinal::CreateInitialOrdinal());
if (!trans->directory()->InsertEntry(trans, kernel.get())) {
return; // We failed inserting, nothing more to do.
}
@@ -66,6 +68,7 @@ MutableEntry::MutableEntry(WriteTransaction* trans, CreateNewUpdateItem,
kernel->put(ID, id);
kernel->put(META_HANDLE, trans->directory_->NextMetahandle());
kernel->mark_dirty(trans->directory_->kernel_->dirty_metahandles);
+ kernel->put(SERVER_ORDINAL_IN_PARENT, NodeOrdinal::CreateInitialOrdinal());
kernel->put(IS_DEL, true);
// We match the database defaults here
kernel->put(BASE_VERSION, CHANGES_VERSION);
@@ -146,13 +149,7 @@ bool MutableEntry::Put(Int64Field field, const int64& value) {
write_transaction_->SaveOriginal(kernel_);
if (kernel_->ref(field) != value) {
ScopedKernelLock lock(dir());
- if (SERVER_POSITION_IN_PARENT == field) {
- ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_,
- dir()->kernel_->parent_id_child_index);
- kernel_->put(field, value);
- } else {
- kernel_->put(field, value);
- }
+ kernel_->put(field, value);
kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
}
return true;
@@ -190,6 +187,24 @@ bool MutableEntry::Put(IdField field, const Id& value) {
return true;
}
+bool MutableEntry::Put(OrdinalField field, const NodeOrdinal& value) {
+ DCHECK(kernel_);
+ DCHECK(value.IsValid());
+ write_transaction_->SaveOriginal(kernel_);
+ if(!kernel_->ref(field).Equals(value)) {
+ ScopedKernelLock lock(dir());
+ if (SERVER_ORDINAL_IN_PARENT == field) {
+ ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(
+ lock, kernel_, dir()->kernel_->parent_id_child_index);
+ kernel_->put(field, value);
+ } else {
+ kernel_->put(field, value);
+ }
+ kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
+ }
+ return true;
+}
+
void MutableEntry::PutParentIdPropertyOnly(const Id& parent_id) {
write_transaction_->SaveOriginal(kernel_);
dir()->ReindexParentId(write_transaction(), kernel_, parent_id);
« no previous file with comments | « sync/syncable/mutable_entry.h ('k') | sync/syncable/syncable_columns.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698