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

Side by Side 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: Changed server_position to server_ordinal in DB 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/syncable/mutable_entry.h" 5 #include "sync/syncable/mutable_entry.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "sync/syncable/directory.h" 8 #include "sync/syncable/directory.h"
9 #include "sync/syncable/scoped_index_updater.h" 9 #include "sync/syncable/scoped_index_updater.h"
10 #include "sync/syncable/scoped_kernel_lock.h" 10 #include "sync/syncable/scoped_kernel_lock.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (!is_del) 134 if (!is_del)
135 // Restores position to the 0th index. 135 // Restores position to the 0th index.
136 if (!PutPredecessor(Id())) { 136 if (!PutPredecessor(Id())) {
137 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. 137 // TODO(lipalani) : Propagate the error to caller. crbug.com/100444.
138 NOTREACHED(); 138 NOTREACHED();
139 } 139 }
140 140
141 return true; 141 return true;
142 } 142 }
143 143
144 bool MutableEntry::Put(Int64Field field, const int64& value) { 144 bool MutableEntry::Put(OrdinalField field, const NodeOrdinal& value) {
145 DCHECK(kernel_); 145 DCHECK(kernel_);
146 write_transaction_->SaveOriginal(kernel_); 146 write_transaction_->SaveOriginal(kernel_);
147 if (kernel_->ref(field) != value) { 147 if(!kernel_->ref(field).Equals(value)) {
148 ScopedKernelLock lock(dir()); 148 ScopedKernelLock lock(dir());
149 if (SERVER_POSITION_IN_PARENT == field) { 149 if (SERVER_ORDINAL_IN_PARENT == field) {
150 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(lock, kernel_, 150 ScopedIndexUpdater<ParentIdAndHandleIndexer> updater(
151 dir()->kernel_->parent_id_child_index); 151 lock, kernel_, dir()->kernel_->parent_id_child_index);
rlarocque 2012/10/05 19:02:55 nit: This indent is off by one. I think you should
152 kernel_->put(field, value); 152 kernel_->put(field, value);
153 } else { 153 } else {
154 kernel_->put(field, value); 154 kernel_->put(field, value);
155 } 155 }
156 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); 156 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
157 } 157 }
158 return true; 158 return true;
159 } 159 }
160 160
161 bool MutableEntry::Put(Int64Field field, const int64& value) {
162 DCHECK(kernel_);
163 write_transaction_->SaveOriginal(kernel_);
164 if (kernel_->ref(field) != value) {
165 ScopedKernelLock lock(dir());
166 kernel_->put(field, value);
167 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
168 }
169 return true;
170 }
171
161 bool MutableEntry::Put(TimeField field, const base::Time& value) { 172 bool MutableEntry::Put(TimeField field, const base::Time& value) {
162 DCHECK(kernel_); 173 DCHECK(kernel_);
163 write_transaction_->SaveOriginal(kernel_); 174 write_transaction_->SaveOriginal(kernel_);
164 if (kernel_->ref(field) != value) { 175 if (kernel_->ref(field) != value) {
165 kernel_->put(field, value); 176 kernel_->put(field, value);
166 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles); 177 kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
167 } 178 }
168 return true; 179 return true;
169 } 180 }
170 181
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); 422 DCHECK_NE(static_cast<MutableEntry*>(NULL), e);
412 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; 423 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing.";
413 if (!(e->Put(IS_UNSYNCED, true))) 424 if (!(e->Put(IS_UNSYNCED, true)))
414 return false; 425 return false;
415 e->Put(SYNCING, false); 426 e->Put(SYNCING, false);
416 return true; 427 return true;
417 } 428 }
418 429
419 } // namespace syncable 430 } // namespace syncable
420 } // namespace syncer 431 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698