OLD | NEW |
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> |
11 #include <cstddef> | 11 #include <cstddef> |
12 #include <iosfwd> | 12 #include <iosfwd> |
13 #include <limits> | 13 #include <limits> |
14 #include <map> | 14 #include <map> |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/atomicops.h" | 19 #include "base/atomicops.h" |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 21 #include "base/compiler_specific.h" |
21 #include "base/file_path.h" | 22 #include "base/file_path.h" |
22 #include "base/gtest_prod_util.h" | 23 #include "base/gtest_prod_util.h" |
23 #include "base/location.h" | 24 #include "base/location.h" |
24 #include "base/logging.h" | 25 #include "base/logging.h" |
25 #include "base/memory/ref_counted.h" | 26 #include "base/memory/ref_counted.h" |
26 #include "base/observer_list_threadsafe.h" | 27 #include "base/observer_list_threadsafe.h" |
27 #include "base/synchronization/lock.h" | 28 #include "base/synchronization/lock.h" |
28 #include "base/time.h" | 29 #include "base/time.h" |
29 #include "chrome/browser/sync/protocol/sync.pb.h" | 30 #include "chrome/browser/sync/protocol/sync.pb.h" |
30 #include "chrome/browser/sync/syncable/blob.h" | 31 #include "chrome/browser/sync/syncable/blob.h" |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 919 |
919 // Returns the child meta handles (even those for deleted/unlinked | 920 // Returns the child meta handles (even those for deleted/unlinked |
920 // nodes) for given meta handle. Clears |result| if there are no | 921 // nodes) for given meta handle. Clears |result| if there are no |
921 // children. | 922 // children. |
922 void GetChildHandlesByHandle(BaseTransaction*, int64 handle, | 923 void GetChildHandlesByHandle(BaseTransaction*, int64 handle, |
923 ChildHandles* result); | 924 ChildHandles* result); |
924 | 925 |
925 // Returns true iff |id| has children. | 926 // Returns true iff |id| has children. |
926 bool HasChildren(BaseTransaction* trans, const Id& id); | 927 bool HasChildren(BaseTransaction* trans, const Id& id); |
927 | 928 |
928 // Find the first or last child in the positional ordering under a parent, | 929 // Find the first child in the positional ordering under a parent, |
929 // and return its id. Returns a root Id if parent has no children. | 930 // and fill in |*first_child_id| with its id. Fills in a root Id if |
930 Id GetFirstChildId(BaseTransaction* trans, const Id& parent_id); | 931 // parent has no children. Returns true if the first child was |
931 Id GetLastChildId(BaseTransaction* trans, const Id& parent_id); | 932 // successfully found, or false if an error was encountered. |
| 933 bool GetFirstChildId(BaseTransaction* trans, const Id& parent_id, |
| 934 Id* first_child_id) WARN_UNUSED_RESULT; |
| 935 |
| 936 // Find the last child in the positional ordering under a parent, |
| 937 // and fill in |*first_child_id| with its id. Fills in a root Id if |
| 938 // parent has no children. Returns true if the first child was |
| 939 // successfully found, or false if an error was encountered. |
| 940 bool GetLastChildIdForTest(BaseTransaction* trans, const Id& parent_id, |
| 941 Id* last_child_id) WARN_UNUSED_RESULT; |
932 | 942 |
933 // Compute a local predecessor position for |update_item|. The position | 943 // Compute a local predecessor position for |update_item|. The position |
934 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|, | 944 // is determined by the SERVER_POSITION_IN_PARENT value of |update_item|, |
935 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date | 945 // as well as the SERVER_POSITION_IN_PARENT values of any up-to-date |
936 // children of |parent_id|. | 946 // children of |parent_id|. |
937 Id ComputePrevIdFromServerPosition( | 947 Id ComputePrevIdFromServerPosition( |
938 const EntryKernel* update_item, | 948 const EntryKernel* update_item, |
939 const syncable::Id& parent_id); | 949 const syncable::Id& parent_id); |
940 | 950 |
941 // SaveChanges works by taking a consistent snapshot of the current Directory | 951 // SaveChanges works by taking a consistent snapshot of the current Directory |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 // children of |parent_id| in the kernel's parent_id_child_index. | 1157 // children of |parent_id| in the kernel's parent_id_child_index. |
1148 ParentIdChildIndex::iterator GetParentChildIndexUpperBound( | 1158 ParentIdChildIndex::iterator GetParentChildIndexUpperBound( |
1149 const ScopedKernelLock& lock, | 1159 const ScopedKernelLock& lock, |
1150 const Id& parent_id); | 1160 const Id& parent_id); |
1151 | 1161 |
1152 // Append the handles of the children of |parent_id| to |result|. | 1162 // Append the handles of the children of |parent_id| to |result|. |
1153 void AppendChildHandles( | 1163 void AppendChildHandles( |
1154 const ScopedKernelLock& lock, | 1164 const ScopedKernelLock& lock, |
1155 const Id& parent_id, Directory::ChildHandles* result); | 1165 const Id& parent_id, Directory::ChildHandles* result); |
1156 | 1166 |
1157 // Returns a pointer to what is probably (but not certainly) the | 1167 // Return a pointer to what is probably (but not certainly) the |
1158 // first child of |parent_id|, or NULL if |parent_id| definitely has | 1168 // first child of |parent_id|, or NULL if |parent_id| definitely has |
1159 // no children. | 1169 // no children. |
1160 EntryKernel* GetPossibleFirstChild( | 1170 EntryKernel* GetPossibleFirstChild( |
1161 const ScopedKernelLock& lock, const Id& parent_id); | 1171 const ScopedKernelLock& lock, const Id& parent_id); |
1162 | 1172 |
| 1173 // Return a pointer to what is probably (but not certainly) the last |
| 1174 // child of |parent_id|, or NULL if |parent_id| definitely has no |
| 1175 // children. |
| 1176 EntryKernel* GetPossibleLastChildForTest( |
| 1177 const ScopedKernelLock& lock, const Id& parent_id); |
| 1178 |
1163 Kernel* kernel_; | 1179 Kernel* kernel_; |
1164 | 1180 |
1165 DirectoryBackingStore* store_; | 1181 DirectoryBackingStore* store_; |
1166 }; | 1182 }; |
1167 | 1183 |
1168 class ScopedKernelLock { | 1184 class ScopedKernelLock { |
1169 public: | 1185 public: |
1170 explicit ScopedKernelLock(const Directory*); | 1186 explicit ScopedKernelLock(const Directory*); |
1171 ~ScopedKernelLock() {} | 1187 ~ScopedKernelLock() {} |
1172 | 1188 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); | 1274 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); |
1259 | 1275 |
1260 // This function sets only the flags needed to get this entry to sync. | 1276 // This function sets only the flags needed to get this entry to sync. |
1261 void MarkForSyncing(syncable::MutableEntry* e); | 1277 void MarkForSyncing(syncable::MutableEntry* e); |
1262 | 1278 |
1263 } // namespace syncable | 1279 } // namespace syncable |
1264 | 1280 |
1265 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1281 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
1266 | 1282 |
1267 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1283 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
OLD | NEW |