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

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

Issue 10696083: sync: Move MarkForSyncing to mutable_entry.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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
« no previous file with comments | « sync/syncable/mutable_entry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/syncable_util.h" 5 #include "sync/syncable/syncable_util.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "sync/syncable/directory.h" 9 #include "sync/syncable/directory.h"
10 #include "sync/syncable/entry.h" 10 #include "sync/syncable/entry.h"
(...skipping 26 matching lines...) Expand all
37 if (!SyncAssert(new_parent.good(), 37 if (!SyncAssert(new_parent.good(),
38 FROM_HERE, 38 FROM_HERE,
39 "Invalid new parent", 39 "Invalid new parent",
40 trans)) 40 trans))
41 return false; 41 return false;
42 ancestor_id = new_parent.Get(PARENT_ID); 42 ancestor_id = new_parent.Get(PARENT_ID);
43 } 43 }
44 return true; 44 return true;
45 } 45 }
46 46
47 // This function sets only the flags needed to get this entry to sync.
48 bool MarkForSyncing(MutableEntry* e) {
49 DCHECK_NE(static_cast<MutableEntry*>(NULL), e);
50 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing.";
51 if (!(e->Put(IS_UNSYNCED, true)))
52 return false;
53 e->Put(SYNCING, false);
54 return true;
55 }
56
57 void ChangeEntryIDAndUpdateChildren( 47 void ChangeEntryIDAndUpdateChildren(
58 WriteTransaction* trans, 48 WriteTransaction* trans,
59 MutableEntry* entry, 49 MutableEntry* entry,
60 const Id& new_id) { 50 const Id& new_id) {
61 Id old_id = entry->Get(ID); 51 Id old_id = entry->Get(ID);
62 if (!entry->Put(ID, new_id)) { 52 if (!entry->Put(ID, new_id)) {
63 Entry old_entry(trans, GET_BY_ID, new_id); 53 Entry old_entry(trans, GET_BY_ID, new_id);
64 CHECK(old_entry.good()); 54 CHECK(old_entry.good());
65 LOG(FATAL) << "Attempt to change ID to " << new_id 55 LOG(FATAL) << "Attempt to change ID to " << new_id
66 << " conflicts with existing entry.\n\n" 56 << " conflicts with existing entry.\n\n"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 BaseTransaction* trans) { 97 BaseTransaction* trans) {
108 if (!condition) { 98 if (!condition) {
109 trans->OnUnrecoverableError(location, msg); 99 trans->OnUnrecoverableError(location, msg);
110 return false; 100 return false;
111 } 101 }
112 return true; 102 return true;
113 } 103 }
114 104
115 } // namespace syncable 105 } // namespace syncable
116 } // namespace syncer 106 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/mutable_entry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698