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

Side by Side Diff: sync/syncable/mutable_entry.cc

Issue 805633004: Enable Null Syncable ID which is different than Root ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 6 years 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
« no previous file with comments | « sync/syncable/entry_kernel.h ('k') | sync/syncable/nigori_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/internal_api/public/base/unique_position.h" 8 #include "sync/internal_api/public/base/unique_position.h"
9 #include "sync/syncable/directory.h" 9 #include "sync/syncable/directory.h"
10 #include "sync/syncable/scoped_kernel_lock.h" 10 #include "sync/syncable/scoped_kernel_lock.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 DCHECK(value.IsValid()); 220 DCHECK(value.IsValid());
221 ScopedKernelLock lock(dir()); 221 ScopedKernelLock lock(dir());
222 ScopedParentChildIndexUpdater updater( 222 ScopedParentChildIndexUpdater updater(
223 lock, kernel_, &dir()->kernel_->parent_child_index); 223 lock, kernel_, &dir()->kernel_->parent_child_index);
224 kernel_->put(UNIQUE_POSITION, value); 224 kernel_->put(UNIQUE_POSITION, value);
225 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); 225 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles);
226 } 226 }
227 } 227 }
228 228
229 bool MutableEntry::PutPredecessor(const Id& predecessor_id) { 229 bool MutableEntry::PutPredecessor(const Id& predecessor_id) {
230 MutableEntry predecessor(write_transaction(), GET_BY_ID, predecessor_id); 230 if (predecessor_id.IsNull()) {
231 if (!predecessor.good()) 231 dir()->PutPredecessor(kernel_, NULL);
232 return false; 232 } else {
233 dir()->PutPredecessor(kernel_, predecessor.kernel_); 233 MutableEntry predecessor(write_transaction(), GET_BY_ID, predecessor_id);
234 if (!predecessor.good())
235 return false;
236 dir()->PutPredecessor(kernel_, predecessor.kernel_);
237 }
234 return true; 238 return true;
235 } 239 }
236 240
237 void MutableEntry::PutAttachmentMetadata( 241 void MutableEntry::PutAttachmentMetadata(
238 const sync_pb::AttachmentMetadata& attachment_metadata) { 242 const sync_pb::AttachmentMetadata& attachment_metadata) {
239 DCHECK(kernel_); 243 DCHECK(kernel_);
240 write_transaction()->TrackChangesTo(kernel_); 244 write_transaction()->TrackChangesTo(kernel_);
241 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() != 245 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() !=
242 attachment_metadata.SerializeAsString()) { 246 attachment_metadata.SerializeAsString()) {
243 dir()->UpdateAttachmentIndex(GetMetahandle(), 247 dir()->UpdateAttachmentIndex(GetMetahandle(),
(...skipping 27 matching lines...) Expand all
271 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); 275 DCHECK_NE(static_cast<MutableEntry*>(NULL), e);
272 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; 276 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing.";
273 if (!(e->PutIsUnsynced(true))) 277 if (!(e->PutIsUnsynced(true)))
274 return false; 278 return false;
275 e->PutSyncing(false); 279 e->PutSyncing(false);
276 return true; 280 return true;
277 } 281 }
278 282
279 } // namespace syncable 283 } // namespace syncable
280 } // namespace syncer 284 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/entry_kernel.h ('k') | sync/syncable/nigori_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698