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

Side by Side Diff: chrome/browser/sync/syncable/syncable.h

Issue 8396022: [Sync] Add HasChildren() function and use it instead of GetFirstChildId() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <bitset> 10 #include <bitset>
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 // Returns the child meta handles for given parent id. Clears 913 // Returns the child meta handles for given parent id. Clears
914 // |result| if there are no children. 914 // |result| if there are no children.
915 void GetChildHandlesById(BaseTransaction*, const Id& parent_id, 915 void GetChildHandlesById(BaseTransaction*, const Id& parent_id,
916 ChildHandles* result); 916 ChildHandles* result);
917 917
918 // Returns the child meta handles for given meta handle. Clears 918 // Returns the child meta handles for given meta handle. Clears
919 // |result| if there are no children. 919 // |result| if there are no children.
920 void GetChildHandlesByHandle(BaseTransaction*, int64 handle, 920 void GetChildHandlesByHandle(BaseTransaction*, int64 handle,
921 ChildHandles* result); 921 ChildHandles* result);
922 922
923 // Returns true iff |id| has children.
rlarocque 2011/10/26 22:43:18 Should we mention that self-looped children are no
akalin 2011/10/27 00:19:21 I don't think so, since deleted == self-looped. H
924 bool HasChildren(BaseTransaction* trans, const Id& id);
925
923 // Find the first or last child in the positional ordering under a parent, 926 // Find the first or last child in the positional ordering under a parent,
924 // and return its id. Returns a root Id if parent has no children. 927 // and return its id. Returns a root Id if parent has no children.
925 virtual Id GetFirstChildId(BaseTransaction* trans, const Id& parent_id); 928 Id GetFirstChildId(BaseTransaction* trans, const Id& parent_id);
926 Id GetLastChildId(BaseTransaction* trans, const Id& parent_id); 929 Id GetLastChildId(BaseTransaction* trans, const Id& parent_id);
927 930
928 // Compute a local predecessor position for |update_item|. The position 931 // Compute a local predecessor position for |update_item|. The position
929 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|, 932 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|,
930 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date 933 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date
931 // children of |parent_id|. 934 // children of |parent_id|.
932 Id ComputePrevIdFromServerPosition( 935 Id ComputePrevIdFromServerPosition(
933 const EntryKernel* update_item, 936 const EntryKernel* update_item,
934 const syncable::Id& parent_id); 937 const syncable::Id& parent_id);
935 938
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 // children of |parent_id| in the kernel's parent_id_child_index. 1145 // children of |parent_id| in the kernel's parent_id_child_index.
1143 ParentIdChildIndex::iterator GetParentChildIndexUpperBound( 1146 ParentIdChildIndex::iterator GetParentChildIndexUpperBound(
1144 const ScopedKernelLock& lock, 1147 const ScopedKernelLock& lock,
1145 const Id& parent_id); 1148 const Id& parent_id);
1146 1149
1147 // Append the handles of the children of |parent_id| to |result|. 1150 // Append the handles of the children of |parent_id| to |result|.
1148 void AppendChildHandles( 1151 void AppendChildHandles(
1149 const ScopedKernelLock& lock, 1152 const ScopedKernelLock& lock,
1150 const Id& parent_id, Directory::ChildHandles* result); 1153 const Id& parent_id, Directory::ChildHandles* result);
1151 1154
1155 // Returns a pointer to what is probably (but not certainly) the
1156 // first child of |parent_id|, or NULL if |parent_id| definitely has
1157 // no children.
1158 EntryKernel* GetPossibleFirstChild(
1159 const ScopedKernelLock& lock, const Id& parent_id);
1160
1152 Kernel* kernel_; 1161 Kernel* kernel_;
1153 1162
1154 DirectoryBackingStore* store_; 1163 DirectoryBackingStore* store_;
1155 }; 1164 };
1156 1165
1157 class ScopedKernelLock { 1166 class ScopedKernelLock {
1158 public: 1167 public:
1159 explicit ScopedKernelLock(const Directory*); 1168 explicit ScopedKernelLock(const Directory*);
1160 ~ScopedKernelLock() {} 1169 ~ScopedKernelLock() {}
1161 1170
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); 1256 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid);
1248 1257
1249 // This function sets only the flags needed to get this entry to sync. 1258 // This function sets only the flags needed to get this entry to sync.
1250 void MarkForSyncing(syncable::MutableEntry* e); 1259 void MarkForSyncing(syncable::MutableEntry* e);
1251 1260
1252 } // namespace syncable 1261 } // namespace syncable
1253 1262
1254 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1263 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1255 1264
1256 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1265 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698